Function slice

  • Works like Array.prototype.slice, returns a new slice of this iterator.

    Type Parameters

    Parameters

    • arg: T

      The input iterator to slice.

    • start: number

      The index to start at (inclusive).

    • Optionalend: number

      The index to end at (exclusive).

    Returns IterableIterator<IterSource<T>>

    A new iterator that only includes the elements between start and end.

    This does not support negative start and end indices, as it's not possible to know the length of the iterator while iterating.

  • Works like Array.prototype.slice, returns a new slice of this iterator.

    Type Parameters

    Parameters

    • start: number

      The index to start at (inclusive).

    • Optionalend: number

      The index to end at (exclusive).

    Returns (arg: T) => IterableIterator<IterSource<T>>

    A new iterator that only includes the elements between start and end.

    This does not support negative start and end indices, as it's not possible to know the length of the iterator while iterating.