A lazy sequence. Its steps are only executed when the sequence is iterated. Each item goes through the full pipeline before the next item is processed.

It doesn't expose the constructor, you should create a LazySeq using the lazy function.

The sequence is immutable, so each operation returns a new sequence. It is an Iterable itself, so you can for..of over it, or use the spread operator to convert it to an array.

Remark

This is just a convenient wrapper around iterables that allows you to chain operations together with a nice syntax. You can use the rest of the library in the pipe and fold methods.

Example

import * as it from "@cprecioso/iterable-helpers"

const result =
it.lazy([1, 2, 3])
.pipe(it.map(x => x * 2))
.fold(it.last())

Type Parameters

  • T

    The type of the items in the sequence.

Implements

  • Iterable<T>

Properties

Methods

Properties

#source: Iterable<T>

Methods

  • Connects with the underlying iterable's Iterator.

    This way we can conform to Iterable.

    Returns Iterator<T, any, undefined>

  • Feeds the iterable into a function that reduces it into a single value. The result is the value itself, NOT wrapped by a LazySeq.

    Type Parameters

    • U

      The type of the result.

    Parameters

    Returns U

  • Feeds the iterable into a function that transforms it into another iterable. The result is a new LazySeq that will iterate over the new iterable.

    Type Parameters

    • U

      The type of the items in the new sequence.

    Parameters

    Returns LazySeq<U>

Generated using TypeDoc