Skip to main content

TreeArrayNodeAlpha Interface

TreeArrayNode with additional alpha APIs.

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

To use, import via @fluidframework/tree/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;

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;

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[];

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.

Equivalent to insertAt(0, ...value): see insertAt(index, value) for details, including merge semantics with concurrent edits.

Parameters

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