The number of elements in the array.
Reflects the total count of elements in the array. This is a read-only property.
Returns the element at the specified index.
Allows access to an element by index, including support for negative indices to count from the end.
The index of the element to retrieve. If negative, counts from the end of the array.
The element at the specified index, or undefined if out of bounds.
Iterates entries while allowing dynamic expansion.
Provides a breadth-first iterator over all entries in the collection, including new items added during the iteration itself. This allows your logic to traverse all known items and process new ones as they are introduced dynamically.
Unlike standard .entries() iteration, which operates over a fixed snapshot of the data,
expandingEntries() reflects live state. As entries are added, they are queued and
subsequently included in the iteration.
The mutating iterator.
Creates a new array with the results of calling a function on each element.
Returns a new array containing the results of applying the callback function to each element. Does not modify the original array.
A new array with transformed elements.
Applies a function against an accumulator and each element to reduce to a single value.
The callback is applied sequentially to each element of the array and the accumulated result is returned.
The final accumulated value.
Safely assign a value at the specified index with lifecycle tracking.
This method replaces the element at the given index and ensures the change is properly tracked for persistence and lifecycle propagation. It integrates with the SoHL system by linking the new value to its parent context and notifying the parent of the update.
This method should always be used instead of direct assignment (array[index] = value).
Direct assignment bypasses lifecycle and persistence hooks, resulting in data that may
not be saved or correctly initialized.
The index in the array to replace.
The new value to assign to the index.
Changes the contents of the array by removing or replacing existing elements.
Removes elements starting at the given index and optionally inserts new elements. Returns an array of the removed elements.
Index at which to start changing the array.
OptionaldeleteCount: numberNumber of elements to remove.
Optional items to insert in place of the removed elements.
An array containing the removed elements.
Adds one or more elements to the beginning of the array.
Inserts the specified elements at the start of the array, shifting existing elements to the right. Returns the new length of the array.
One or more elements to add to the beginning of the array.
The new length of the array after the elements are added.
A tracked array that participates in the SoHL data lifecycle.
SohlArray<T>is an extension of the nativeArray<T>that supports automatic tracking of parent context and persistence. It is used to hold ordered collections of objects such as Effects or Logic items.Remarks
The array tracks its parent context (SohlBeing or SohlLogic) and notifies it when changes occur. All iterator methods return an
Itr<T>object for functional utilities.WARNING
Do not assign directly to an index (e.g.,
arr[0] = value). Instead, usesetAt(index, value)to ensure proper lifecycle tracking.Example