ts-iterable-functions
    Preparing search index...

    Function _take

    • Produces up to the specified number of elements from the beginning of the source iterable.

      Type Parameters

      • T

        Element type produced by the source iterable.

      Parameters

      • src: Iterable<T>

        Source iterable to enumerate.

      • numItems: number

        Maximum number of elements to yield; non-positive values return an empty iterable.

      Returns Iterable<T>

      A deferred iterable yielding at most numItems elements from src.

      const firstTwo = [..._take([1, 2, 3, 4], 2)];
      console.log(firstTwo); // [1, 2]

      or using the curried version:

      const firstTwo = [
      ...pipeInto(
      [1, 2, 3, 4],
      take(2)
      ),
      ];
      console.log(firstTwo); // [1, 2]