TreeArrayNodeAlpha Interface
TreeArrayNode with additional alpha APIs.
To use, import via @fluidframework/tree/alpha.
For more information about our API support guarantees, see here.
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
| Parameter | Constraint | Default | Description |
|---|---|---|---|
| TAllowedTypes | System_Unsafe.ImplicitAllowedTypesUnsafe | ImplicitAllowedTypes | |
| T | [TAllowedTypes] extends [ImplicitAllowedTypes] ? TreeNodeFromImplicitAllowedTypes<TAllowedTypes> : TreeNodeFromImplicitAllowedTypes<ImplicitAllowedTypes> | ||
| TNew | [TAllowedTypes] extends [ImplicitAllowedTypes] ? InsertableTreeNodeFromImplicitAllowedTypes<TAllowedTypes> : InsertableTreeNodeFromImplicitAllowedTypes<ImplicitAllowedTypes> |
Methods
| Method | Alerts | Return Type | Description |
|---|---|---|---|
| at(index) | Alpha | T | undefined | Returns the item located at the specified index. |
| findLast(predicate, thisArg) | Alpha | S | undefined | Returns 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) | Alpha | T | undefined | Returns 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) | Alpha | number | 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. |
| pop() | Alpha | T | undefined | Removes the last item from the array and returns it. |
| shift() | Alpha | T | undefined | Removes the first item from the array and returns it. |
| splice(start, deleteCount, items) | Alpha | T[] | Removes existing item(s) and/or adds new item(s). |
| unshift(value) | Alpha | void | Inserts new item(s) at the start of the array. |
Method Details
at
Returns the item located at the specified index.
For more information about our API support guarantees, see here.
Signature
at(index: number): T | undefined;
Parameters
| Parameter | Type | Description |
|---|---|---|
| index | number | The 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.
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
| Parameter | Constraint | Description |
|---|---|---|
| S | T | The 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
| Parameter | Modifiers | Type | Description |
|---|---|---|---|
| predicate | (value: T, index: number, array: readonly T[]) => value is S | Evaluated 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. | |
| thisArg | optional | unknown | If 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.
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
| Parameter | Modifiers | Type | Description |
|---|---|---|---|
| predicate | (value: T, index: number, array: readonly T[]) => unknown | Evaluated 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. | |
| thisArg | optional | unknown | If 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.
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
| Parameter | Modifiers | Type | Description |
|---|---|---|---|
| predicate | (value: T, index: number, array: readonly T[]) => unknown | Evaluated 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. | |
| thisArg | optional | unknown | If 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.
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.
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).
For more information about our API support guarantees, see here.
Signature
splice(start: number, deleteCount?: number, ...items: readonly (TNew | IterableTreeArrayContent<TNew>)[]): T[];
Parameters
| Parameter | Modifiers | Type | Description |
|---|---|---|---|
| start | number | The 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. | |
| deleteCount | optional | number | The 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. |
| items | readonly (TNew | IterableTreeArrayContent<TNew>)[] | The item(s) to insert at start. |