Optionaloptions: ArrayConstraintOptions<T>Static ReadonlyBREAKReturn this from a forEach callback to stop iterating.
Clears this array and cleans up its constraints.
Optionalsilent: boolean
If true, don't invalidate the constraints that depended on it
Whether filter returns a truthy value for every item.
OptionalthisArg: unknownCalls callback once per item. Return cjs.ArrayConstraint.BREAK from it to stop.
The this for callback (default: the global object)
The index of the first item equal to item, or -1.
OptionalequalityCheck: EqualityCheck<T>
How to compare items (default: this array's equality check)
The index of the first item for which filter returns a truthy value, or -1.
The this for filter (default: this array constraint)
With no arguments: a plain array of the items (see toArray). With index: the item at
index. With index and value: sets the item at index and returns value.
With no arguments: a plain array of the items (see toArray). With index: the item at
index. With index and value: sets the item at index and returns value.
A constraint whose value is the item at index (which can itself be a constraint).
The items joined into a string, separated by separator (default: ",").
Optionalseparator: stringThe index of the last item equal to item, or -1.
OptionalequalityCheck: EqualityCheck<T>
How to compare items (default: this array's equality check)
The index of the last item for which filter returns a truthy value, or -1.
The this for filter (default: this array constraint)
Removes the last item and returns it (or undefined if the array is empty).
A reversed (plain) copy of the items. This array constraint is not modified.
Change how items are compared (for indexOf and friends).
Removes the first item and returns it.
A (plain) array of the items from begin up to (but not including) end. Like
Array.prototype.slice, negative indices count back from the end.
Optionalbegin: numberOptionalend: numberWhether filter returns a truthy value for any item.
OptionalthisArg: unknownA plain array of the items.
The items as a string, like Array.prototype.toString.
Note: the preferred way to create an array constraint is with
cjs([...])orcjs.array(options).Emulates a standard array, but with constraints: its methods (
push,pop,slice, ...) keep track of dependencies, so that a constraint that reads an item is only updated when that item (or, for methods likeforEach, the length) changes.Example