limitSet()function

limitSet(set: ImmutableSet<T>, limit: number): ImmutableSet<T>
ParamType
setImmutableSet<T>
The set to limit. required
limitnumber
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 }