Skip to main content
Version: v2

TreeArrayNodeAlpha Interface

TreeArrayNode with additional alpha APIs.

This API is provided as an alpha preview and may change without notice.

To use, import via fluid-framework/alpha.

For more information about our API support guarantees, see here.

Sealed

This type is "sealed," meaning that code outside of the library defining it should not implement or extend it. Future versions of this type may add members or make typing of readonly members more specific.

Signature​

/** @sealed */
export interface TreeArrayNodeAlpha<TAllowedTypes extends System_Unsafe.ImplicitAllowedTypesUnsafe = ImplicitAllowedTypes, out T = [TAllowedTypes] extends [ImplicitAllowedTypes] ? TreeNodeFromImplicitAllowedTypes<TAllowedTypes> : TreeNodeFromImplicitAllowedTypes<ImplicitAllowedTypes>, in TNew = [TAllowedTypes] extends [ImplicitAllowedTypes] ? InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes> : InsertableTreeNodeFromImplicitAllowedTypes<ImplicitAllowedTypes>> extends TreeArrayNode<TAllowedTypes, T, TNew>

Extends: TreeArrayNode<TAllowedTypes, T, TNew>

Type Parameters​

ParameterConstraintDefaultDescription
TAllowedTypesSystem_Unsafe.ImplicitAllowedTypesUnsafeImplicitAllowedTypes
T[TAllowedTypes] extends [ImplicitAllowedTypes] ? TreeNodeFromImplicitAllowedTypes<TAllowedTypes> : TreeNodeFromImplicitAllowedTypes<ImplicitAllowedTypes>
TNew[TAllowedTypes] extends [ImplicitAllowedTypes] ? InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes> : InsertableTreeNodeFromImplicitAllowedTypes<ImplicitAllowedTypes>

Methods​

MethodAlertsReturn TypeDescription
at(index)AlphaT | undefinedReturns the item located at the specified index.
findLast(predicate, thisArg)AlphaS | undefinedReturns the last item in the array for which the given type guard returns true, searching from the last item to the first.
findLast(predicate, thisArg)AlphaT | undefinedReturns the last item in the array for which the given predicate returns a truthy value, searching from the last item to the first.
findLastIndex(predicate, thisArg)AlphanumberReturns the index of the last item in the array for which the given predicate returns a truthy value, searching from the last item to the first.
pop()AlphaT | undefinedRemoves the last item from the array and returns it.
shift()AlphaT | undefinedRemoves the first item from the array and returns it.
splice(start, deleteCount, items)AlphaT[]Removes existing item(s) and/or adds new item(s).
unshift(value)AlphavoidInserts new item(s) at the start of the array.

Method Details​

at​

Returns the item located at the specified index.

This API is provided as an alpha preview and may change without notice.

For more information about our API support guarantees, see here.

Signature​

at(index: number): T | undefined;

Parameters​

ParameterTypeDescription
indexnumberThe zero-based index of the item to retrieve. Negative indices count back from the last item in the array: for index < 0, index + array.length is used.

Returns​

The item at the specified index, or undefined if the index is out of bounds.

Return type: T | undefined

findLast​

Returns the last item in the array for which the given type guard returns true, searching from the last item to the first.

This API is provided as an alpha preview and may change without notice.

For more information about our API support guarantees, see here.

Signature​

findLast<S extends T>(predicate: (value: T, index: number, array: readonly T[]) => value is S, thisArg?: unknown): S | undefined;
Type Parameters​
ParameterConstraintDescription
STThe subtype of T asserted by the predicate type guard.

Remarks​

The array's length is captured when the search begins; items are read live as the search progresses. If predicate edits the array, behavior matches Array.prototype.findLast.

Parameters​

ParameterModifiersTypeDescription
predicate(value: T, index: number, array: readonly T[]) => value is SEvaluated once per item, starting from the last item and moving towards the first, until it returns true. Receives the item, its index, and the array being searched.
thisArgoptionalunknownIf provided, used as this when invoking predicate.

Returns​

The last item for which predicate returns true (narrowed to the guarded type), or undefined if there is no such item.

Return type: S | undefined

findLast​

Returns the last item in the array for which the given predicate returns a truthy value, searching from the last item to the first.

This API is provided as an alpha preview and may change without notice.

For more information about our API support guarantees, see here.

Signature​

findLast(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: unknown): T | undefined;

Remarks​

The array's length is captured when the search begins; items are read live as the search progresses. If predicate edits the array, behavior matches Array.prototype.findLast.

Parameters​

ParameterModifiersTypeDescription
predicate(value: T, index: number, array: readonly T[]) => unknownEvaluated once per item, starting from the last item and moving towards the first, until it returns a truthy value. Receives the item, its index, and the array being searched.
thisArgoptionalunknownIf provided, used as this when invoking predicate.

Returns​

The last item for which predicate returns a truthy value, or undefined if there is no such item.

Return type: T | undefined

findLastIndex​

Returns the index of the last item in the array for which the given predicate returns a truthy value, searching from the last item to the first.

This API is provided as an alpha preview and may change without notice.

For more information about our API support guarantees, see here.

Signature​

findLastIndex(predicate: (value: T, index: number, array: readonly T[]) => unknown, thisArg?: unknown): number;

Remarks​

The array's length is captured when the search begins; items are read live as the search progresses. If predicate edits the array, behavior matches Array.prototype.findLastIndex.

Parameters​

ParameterModifiersTypeDescription
predicate(value: T, index: number, array: readonly T[]) => unknownEvaluated once per item, starting from the last item and moving towards the first, until it returns a truthy value. Receives the item, its index, and the array being searched.
thisArgoptionalunknownIf provided, used as this when invoking predicate.

Returns​

The index of the last item for which predicate returns a truthy value, or -1 if there is no such item.

Return type: number

pop​

Removes the last item from the array and returns it.

This API is provided as an alpha preview and may change without notice.

For more information about our API support guarantees, see here.

Signature​

pop(): T | undefined;

Remarks​

Equivalent to removeAt(array.length - 1), additionally returning the removed item: see removeAt(index) for details, including merge semantics with concurrent edits. In particular, the item removed is the one that is last at the time this method is called, not the one that is last at the time the resulting edit is sequenced.

Returns​

The removed item, or undefined if the array is empty (in which case the array is not modified).

Return type: T | undefined

shift​

Removes the first item from the array and returns it.

This API is provided as an alpha preview and may change without notice.

For more information about our API support guarantees, see here.

Signature​

shift(): T | undefined;

Remarks​

Equivalent to removeAt(0), additionally returning the removed item: see removeAt(index) for details, including merge semantics with concurrent edits. In particular, the item removed is the one that is first at the time this method is called, not the one that is first at the time the resulting edit is sequenced.

Returns​

The removed item, or undefined if the array is empty (in which case the array is not modified).

Return type: T | undefined

splice​

Removes existing item(s) and/or adds new item(s).

This API is provided as an alpha preview and may change without notice.

For more information about our API support guarantees, see here.

Signature​

splice(start: number, deleteCount?: number, ...items: readonly (TNew | IterableTreeArrayContent<TNew>)[]): T[];

Remarks​

See insertAt(index, value) for the merge semantics of the inserted items.

Parameters​

ParameterModifiersTypeDescription
startnumberThe index at which to start changing the array. If negative, it is treated as array.length + start. Must be a positive in bounds index or a negative index such that array.length + start is a positive in bounds index.
deleteCountoptionalnumberThe number of item(s) to remove. If not provided, it defaults to the end of the array. Must be a non-negative integer no greater than the number of items from start to the end of the array.
itemsreadonly (TNew | IterableTreeArrayContent<TNew>)[]The item(s) to insert at start.

Returns​

An array containing the item(s) that were removed.

Return type: T[]

unshift​

Inserts new item(s) at the start of the array.

This API is provided as an alpha preview and may change without notice.

For more information about our API support guarantees, see here.

Signature​

unshift(...value: readonly (TNew | IterableTreeArrayContent<TNew>)[]): void;

Remarks​

Unlike Array.prototype.unshift, this method does not return the new length of the array.

All items inserted by a single call to this method are inserted consecutively. The order of the inserted items relative to other concurrently inserted items is fully specified: Concurrently unshifting [A, B] and [X, Y] will yield [A, B, X, Y] if the edit unshifting [A, B] is sequenced after the edit unshifting [X, Y].

Parameters​

ParameterTypeDescription
valuereadonly (TNew | IterableTreeArrayContent<TNew>)[]The content to insert.