Packages > @fluidframework/tree > TreeArrayNodeBase

TreeArrayNodeBase Interface

A generic array type, used to defined types like TreeArrayNode .

Signature

export interface TreeArrayNodeBase<out T, in TNew, in TMoveFrom> extends ReadonlyArray<T>, TreeNode

Extends: ReadonlyArray<T>, TreeNode

Type Parameters

Parameter Description
T
TNew
TMoveFrom

Methods

Method Return Type Description
insertAt(index, value) void Inserts new item(s) at a specified location.
insertAtEnd(value) void Inserts new item(s) at the end of the array.
insertAtStart(value) void Inserts new item(s) at the start of the array.
moveRangeToEnd(sourceStart, sourceEnd) void Moves the specified items to the end of the array.
moveRangeToEnd(sourceStart, sourceEnd, source) void Moves the specified items to the end of the array.
moveRangeToIndex(index, sourceStart, sourceEnd) void Moves the specified items to the desired location within the array.
moveRangeToIndex(index, sourceStart, sourceEnd, source) void Moves the specified items to the desired location within the array.
moveRangeToStart(sourceStart, sourceEnd) void Moves the specified items to the start of the array.
moveRangeToStart(sourceStart, sourceEnd, source) void Moves the specified items to the start of the array.
moveToEnd(sourceIndex) void Moves the specified item to the end of the array.
moveToEnd(sourceIndex, source) void Moves the specified item to the end of the array.
moveToIndex(index, sourceIndex) void Moves the specified item to the desired location in the array.
moveToIndex(index, sourceIndex, source) void Moves the specified item to the desired location in the array.
moveToStart(sourceIndex) void Moves the specified item to the start of the array.
moveToStart(sourceIndex, source) void Moves the specified item to the start of the array.
removeAt(index) void Removes the item at the specified location.
removeRange(start, end) void Removes all items between the specified indices.

Method Details

insertAt

Inserts new item(s) at a specified location.

Signature

insertAt(index: number, ...value: (TNew | IterableTreeArrayContent<TNew>)[]): void;

Parameters

Parameter Type Description
index number The index at which to insert value.
value (TNew | IterableTreeArrayContent<TNew>)[] The content to insert.

Error Handling

Throws if index is not in the range [0, array.length).

insertAtEnd

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

Signature

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

Parameters

Parameter Type Description
value (TNew | IterableTreeArrayContent<TNew>)[] The content to insert.

insertAtStart

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

Signature

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

Parameters

Parameter Type Description
value (TNew | IterableTreeArrayContent<TNew>)[] The content to insert.

moveRangeToEnd

Moves the specified items to the end of the array.

Signature

moveRangeToEnd(sourceStart: number, sourceEnd: number): void;

Parameters

Parameter Type Description
sourceStart number The starting index of the range to move (inclusive).
sourceEnd number The ending index of the range to move (exclusive)

Error Handling

Throws if either of the input indices are not in the range [0, array.length) or if sourceStart is greater than sourceEnd.

moveRangeToEnd

Moves the specified items to the end of the array.

Signature

moveRangeToEnd(sourceStart: number, sourceEnd: number, source: TMoveFrom): void;

Parameters

Parameter Type Description
sourceStart number The starting index of the range to move (inclusive).
sourceEnd number The ending index of the range to move (exclusive)
source TMoveFrom The source array to move items out of.

Error Handling

Throws if the types of any of the items being moved are not allowed in the destination array, if either of the input indices are not in the range [0, array.length) or if sourceStart is greater than sourceEnd.

moveRangeToIndex

Moves the specified items to the desired location within the array.

Signature

moveRangeToIndex(index: number, sourceStart: number, sourceEnd: number): void;

Parameters

Parameter Type Description
index number The index to move the items to. This is based on the state of the array before moving the source items.
sourceStart number The starting index of the range to move (inclusive).
sourceEnd number The ending index of the range to move (exclusive)

Error Handling

Throws if any of the input indices are not in the range [0, array.length) or if sourceStart is greater than sourceEnd.

moveRangeToIndex

Moves the specified items to the desired location within the array.

Signature

moveRangeToIndex(index: number, sourceStart: number, sourceEnd: number, source: TMoveFrom): void;

Parameters

Parameter Type Description
index number The index to move the items to.
sourceStart number The starting index of the range to move (inclusive).
sourceEnd number The ending index of the range to move (exclusive)
source TMoveFrom The source array to move items out of.

Error Handling

Throws if the types of any of the items being moved are not allowed in the destination array, if any of the input indices are not in the range [0, array.length) or if sourceStart is greater than sourceEnd.

moveRangeToStart

Moves the specified items to the start of the array.

Signature

moveRangeToStart(sourceStart: number, sourceEnd: number): void;

Parameters

Parameter Type Description
sourceStart number The starting index of the range to move (inclusive).
sourceEnd number The ending index of the range to move (exclusive)

Error Handling

Throws if either of the input indices are not in the range [0, array.length) or if sourceStart is greater than sourceEnd.

moveRangeToStart

Moves the specified items to the start of the array.

Signature

moveRangeToStart(sourceStart: number, sourceEnd: number, source: TMoveFrom): void;

Parameters

Parameter Type Description
sourceStart number The starting index of the range to move (inclusive).
sourceEnd number The ending index of the range to move (exclusive)
source TMoveFrom The source array to move items out of.

Error Handling

Throws if the types of any of the items being moved are not allowed in the destination array, if either of the input indices are not in the range [0, array.length) or if sourceStart is greater than sourceEnd.

moveToEnd

Moves the specified item to the end of the array.

Signature

moveToEnd(sourceIndex: number): void;

Parameters

Parameter Type Description
sourceIndex number The index of the item to move.

Error Handling

Throws if sourceIndex is not in the range [0, array.length).

moveToEnd

Moves the specified item to the end of the array.

Signature

moveToEnd(sourceIndex: number, source: TMoveFrom): void;

Parameters

Parameter Type Description
sourceIndex number The index of the item to move.
source TMoveFrom The source array to move the item out of.

Error Handling

Throws if sourceIndex is not in the range [0, array.length).

moveToIndex

Moves the specified item to the desired location in the array.

Signature

moveToIndex(index: number, sourceIndex: number): void;

Parameters

Parameter Type Description
index number The index to move the item to. This is based on the state of the array before moving the source item.
sourceIndex number The index of the item to move.

Error Handling

Throws if any of the input indices are not in the range [0, array.length).

moveToIndex

Moves the specified item to the desired location in the array.

Signature

moveToIndex(index: number, sourceIndex: number, source: TMoveFrom): void;

Parameters

Parameter Type Description
index number The index to move the item to.
sourceIndex number The index of the item to move.
source TMoveFrom The source array to move the item out of.

Error Handling

Throws if any of the input indices are not in the range [0, array.length).

moveToStart

Moves the specified item to the start of the array.

Signature

moveToStart(sourceIndex: number): void;

Parameters

Parameter Type Description
sourceIndex number The index of the item to move.

Error Handling

Throws if sourceIndex is not in the range [0, array.length).

moveToStart

Moves the specified item to the start of the array.

Signature

moveToStart(sourceIndex: number, source: TMoveFrom): void;

Parameters

Parameter Type Description
sourceIndex number The index of the item to move.
source TMoveFrom The source array to move the item out of.

Error Handling

Throws if sourceIndex is not in the range [0, array.length).

removeAt

Removes the item at the specified location.

Signature

removeAt(index: number): void;

Parameters

Parameter Type Description
index number The index at which to remove the item.

Error Handling

Throws if index is not in the range [0, array.length).

removeRange

Removes all items between the specified indices.

Signature

removeRange(start?: number, end?: number): void;

Parameters

Parameter Modifiers Type Description
start optional number The starting index of the range to remove (inclusive). Defaults to the start of the array.
end optional number The ending index of the range to remove (exclusive).

Error Handling

Throws if start is not in the range [0, array.length).

Throws if end is less than start. If end is not supplied or is greater than the length of the array, all items after start are removed.