limitArray()function
limitArray(list: PossibleArray<T>, limit: number): ImmutableArray<T>
| Param | Type | |
|---|---|---|
list | PossibleArray<T> | The array or iterable to limit. required |
limit | number | The maximum number of items to keep. required |
| Return | |
|---|---|
ImmutableArray<T> | An array of at most limit items, or the same array if it was already within the limit. |
| Throws | |
|---|---|
RequiredError | If list cannot be converted to an array. |
Apply a limit to an array.
Examples
limitArray([1, 2, 3, 4], 2) // [1, 2]