Returns a new circular array. Immutable. A circular array only keeps up to capacity items.
Old items are overridden with new items.
CircularArray extends the regular JS array. Only use add to change the array if you want
to keep the CircularArray behaviour.
Example: Basic functions
leta = circularArray(10); a = a.add(`hello`); // Because it's immutable, capture the return result of `add` a.isFull; // True if circular array is full a.pointer; // The current position in array it will write to
Since it extends the regular JS array, you can access items as usual:
Example: Accessing
leta = circularArray(10); ... addsomestuff .. a.forEach(item=>// do something with item);
Returns a new circular array. Immutable. A circular array only keeps up to
capacity
items. Old items are overridden with new items.CircularArray
extends the regular JS array. Only useadd
to change the array if you want to keep theCircularArray
behaviour.Example: Basic functions
Since it extends the regular JS array, you can access items as usual:
Example: Accessing