yta
    Preparing search index...

    Function drop

    • Drop the first n items from the iterator and continue from there.

      import { pipe } from "yta";
      import { asAsync, range } from "andceter/sync";
      import { drop, toArray } from "yta/async";

      await pipe(range(15), asAsync(), drop(10), toArray());
      // => [10, 11, 12, 13, 14]

      If n is negative drop them from the end of the sequence instead. Which is effectively the same as take(length - n) if you know the length of the iterator.

      import { pipe } from "yta";
      import { asAsync, range } from "andceter/sync";
      import { drop, toArray } from "yta/async";

      await pipe(range(15), asAsync() drop(-10), toArray());
      // => [0, 1, 2, 3, 4]

      Note: because the length of the iterator is not known—if you use negative index the entire iterator has to be consumed before yielding the first item. This can result in an infinite loop if the iterator is indefinite.

      See also:

      Type Parameters

      • A

        The item type

      Parameters

      • n: number

        The number of items to drop

      Returns (items: AsyncIterable<A>) => AsyncGenerator<A, void>