limitMap()function

limitMap(map: ImmutableMap<T>, limit: number): ImmutableMap<T>
ParamType
mapImmutableMap<T>
The map to limit. required
limitnumber
The maximum number of items to keep. required
Return
ImmutableMap<T>
An ImmutableMap with at most limit items (the input map unchanged if it already fits).

Apply a limit to a map.

  • Returns the input map unchanged if the limit is not smaller than its size.

Examples

limitMap(new Map([["a", 1], ["b", 2]]), 1) // Map { "a" => 1 }