filterArray()function
filterArray(input: ImmutableArray<T>, match: Match<[T, ...A]>, ...args: A): ImmutableArray<T>
| Param | Type | |
|---|---|---|
input | ImmutableArray<T> | Array of items to filter. required |
match | Match<[T, ...A]> | Matcher called with each item (plus any extra args); items it returns true for are kept. required |
args | A | Extra arguments passed to match after each item. required |
| Return | |
|---|---|
ImmutableArray<T> | A filtered array, or the same input instance if nothing was removed. |
Filter an array (immutably) using a matcher.
- Returns the exact same array instance if no items were removed (for referential stability).
Examples
filterArray([1, 2, 3], n => n > 1) // [2, 3]