limitSet()function
limitSet(set: ImmutableSet<T>, limit: number): ImmutableSet<T>
| Param | Type | |
|---|---|---|
set | ImmutableSet<T> | The set to limit. required |
limit | number | The maximum number of items to keep. required |
| Return | |
|---|---|
ImmutableSet<T> | A set containing at most limit items. |
Apply a limit to a set.
- Returns the input unchanged when it already fits within
limit.
Examples
limitSet(new Set([1, 2, 3]), 2) // Set { 1, 2 }