Limit the elements of an Iterable to the first n elements.
n
Does not apply any limit if maxSize is negative.
maxSize
Only emit the first 2 elements
2
const limitTo2 = limit(2);const iterable = limitTo2([1, 2, 3]);console.log(iterable); // [1, 2]
dropWhile, skip and takeWhile for similar operations.
an Iterable that emits only the first maxSize elements
the Iterable value type
the number of maximum values to emit
Generated using TypeDoc
Limit the elements of an Iterable to the first
nelements.Remarks
Does not apply any limit if
maxSizeis negative.Example
Only emit the first
2elementsSee
dropWhile, skip and takeWhile for similar operations.
Returns
an Iterable that emits only the first
maxSizeelements