A lazy iterator wrapper that adds array-style combinators (map, filter, take, reduce, etc.) over any iterable. Transformations are evaluated lazily and return new Itr instances, so chains do not materialize intermediate arrays.

Type Parameters

  • T

    The element type produced by the iterator.

Implements

  • IterableIterator<T>

Constructors

  • Wrap a source iterable, capturing its iterator for lazy consumption.

    Type Parameters

    • T

    Parameters

    • iterable: Iterable<T>

      The source iterable to wrap.

    Returns Itr<T>

Methods

  • Default iterator to enable for...of usage.

    Returns IterableIterator<T>

    Each element of the underlying iterator in order.

  • Skip the first n elements.

    Parameters

    • n: number

      The number of leading elements to skip.

    Returns Itr<T>

    A new Itr over the elements after the first n.

  • Check if all elements match a condition.

    Parameters

    • callback: (value: T, index: number) => boolean

      Returns true for an element that satisfies the condition.

    Returns boolean

    true if every element matches.

  • Filter values to a new Itr.

    Parameters

    • callback: (value: T, index: number) => boolean

      Returns true for each element to keep.

    Returns Itr<T>

    A new Itr over the matching elements.

  • Find the first element that matches a condition.

    Parameters

    • callback: (value: T, index: number) => boolean

      Returns true for the element to find.

    Returns undefined | T

    The first matching element, or undefined if none match.

  • Apply a function to each element.

    Parameters

    • callback: (value: T, index: number) => void

      Invoked with each element and its index.

    Returns void

  • Check if any element matches the specified value

    Parameters

    • value: T

      The value to search for (strict equality).

    Returns boolean

    true if the value is present.

  • Map values to a new Itr.

    Type Parameters

    • U

    Parameters

    • callback: (value: T, index: number) => U

      Maps each element and its index to a new value.

    Returns Itr<U>

    A new Itr over the mapped values.

  • Return the next element in the iterator.

    Parameters

    • ...args: [] | [undefined]

      Optional value forwarded to the underlying iterator's next.

    Returns IteratorResult<T, any>

    The next iterator result.

  • Reduce to a single value.

    Type Parameters

    • U

    Parameters

    • callback: (accumulator: U, value: T, index: number) => U

      Combines the accumulator with each element and its index.

    • initialValue: U

      The initial accumulator value.

    Returns U

    The final accumulated value.

  • Check if some elements match a condition.

    Parameters

    • callback: (value: T, index: number) => boolean

      Returns true for a matching element.

    Returns boolean

    true if at least one element matches.

  • Take the first n elements.

    Parameters

    • n: number

      The maximum number of elements to yield.

    Returns Itr<T>

    A new Itr over the first n elements.

  • Convert to an array.

    Returns T[]

    An array of all remaining elements.

  • Create a new Itr instance from an iterable.

    Type Parameters

    • U

    Parameters

    • iterable: Iterable<U>

      The source iterable to wrap.

    Returns Itr<U>

    A new Itr over the iterable.