• Limit the elements of an Iterable to the first n elements.

    Remarks

    Does not apply any limit if maxSize is negative.

    Example

    Only emit the first 2 elements

    const limitTo2 = limit(2);
    const iterable = limitTo2([1, 2, 3]);
    console.log(iterable); // [1, 2]

    See

    dropWhile, skip and takeWhile for similar operations.

    Returns

    an Iterable that emits only the first maxSize elements

    Type Parameters

    • T

      the Iterable value type

    Parameters

    • maxSize: number

      the number of maximum values to emit

    Returns ((iterable: Iterable<T>) => IterableIterator<T>)

Generated using TypeDoc