Function takeSync

  • Lazily takes the first n elements from the input sync iterable. Returns a sync iterable that yields the first n elements of the input sync iterable.

    Returns

    A function that accepts an input iterable and returns a sync iterable of the first n elements.

    Example

    const input = [1, 2, 3, 4, 5];
    const firstThreeElements = takeSync(3)(input);

    for (const value of firstThreeElements) {
    console.log(value); // Logs 1, 2, and 3
    }

    Remarks

    Available as take when imported from peter-piper/sync.

    Type Parameters

    • T

      The type of elements in the input iterable.

    Parameters

    • n: number

      The number of elements to take from the input iterable.

    Returns ((input: Iterable<T>) => Iterable<T>)

      • (input: Iterable<T>): Iterable<T>
      • Parameters

        • input: Iterable<T>

        Returns Iterable<T>

Generated using TypeDoc