takeWhile
Import from @varavel/vdl-plugin-sdk/utils/arrays.
Returns a new array containing the leading elements of the provided array that satisfy the provided predicate function. It stops taking elements as soon as an element does not satisfy the predicate.
Type Parameters
| Type Parameter | Description |
|---|---|
T |
The type of elements in the array. |
Parameters
| Parameter | Type | Description |
|---|---|---|
arr |
readonly T[] |
The array to process. |
shouldContinueTaking |
(element, index, array) => boolean |
The predicate function that is called with each element, its index, and the array. Elements are included in the result as long as this function returns true. |
Returns
T[]
A new array containing the leading elements that satisfy the predicate.