🔗Overview
The arrays module is auto-loaded in every compile, no import needed. Object literals ({k: v}) with $obj.k / $obj.v field access power data-driven loops:
var s = [{k: 0, v: 0}, {k: 1, v: 0.25rem}]
for item in $s:
.p-${$item.k}
padding: $item.v🔗add
Appends an item to an array.
var items = [1, 2]
add($items, 3) /* [1, 2, 3] */🔗delete
Removes the element at the given offset from an array.
var items = [1, 2, 3]
delete($items, 1) /* [1, 3] */🔗insert
Inserts an item at the given offset in an array.
var items = [1, 3]
insert($items, 2, 1) /* [1, 2, 3] */🔗join
Joins a string array into a single string with ", " separator. Returns a string. Strings only.
var s = join(["a", "b", "c"]) /* "a, b, c" */🔗contains
Tests membership of a string in an array. Returns a bool.
var ok = contains($items, "a")🔗find
Returns the first index of an item in an array, or -1 when absent. Returns an int.
var idx = find($items, "b")🔗dedup
Removes duplicates from an array in place, using hash-based comparison.
var items = [1, 2, 2, 3]
dedup($items) /* [1, 2, 3] */