For the complete documentation index, see llms.txt. This page is also available as Markdown.

Slicing & Converting

Take slices of an array or convert it to another shape.

.left(n)array

The first n elements.

.right(n)array

The last n elements.

arr = [1, 2, 3, 4, 5]
log arr.left(2)   // [1, 2]
log arr.right(2)  // [4, 5]

.clone()array

An independent deep copy. (Plain = shares a reference; .clone() does not.)

.getKeys(field)array

For an array of objects, plucks field from each element.

people = [{name: "alice"}, {name: "bob"}]
log people.getKeys("name")  // ["alice", "bob"]

.toSet()set

Converts to a set (unique values). Imports osl/set.

.toEntriesObj()object

Treats the array as a list of [key, value] pairs and builds an object from them.

Arrays also support the universal methods .len (a property), .toStr(), .getType(), .item(i) - see Type & conversion methods.

Last updated