Globals / "src/common/utils/splitArray"
Module: "src/common/utils/splitArray"#
Index#
Functions#
Functions#
splitArray#
▸ splitArray\array: T[], element: T): [T[], T[], boolean]
Defined in src/common/utils/splitArray.ts:13
This function splits an array into two sub arrays on the first instance of
element (from the left). If the array does not contain the element. The
return value is defined to be [array, [], false]. If the element is in
the array then the return value is [left, right, true] where left is
the elements of array from [0, index) and right is (index, length)
Type parameters:
| Name |
|---|
T |
Parameters:
| Name | Type | Description |
|---|---|---|
array |
T[] | the full array to split into two sub-arrays |
element |
T | the element in the middle of the array |
Returns: [T[], T[], boolean]
the left and right sub-arrays which when conjoined with element
is the same as array, and true
Last update: November 10, 2020