kollectionjs - v2.0.0
    Preparing search index...

    Function generate

    • Creates an infinite (or finite) Sequence by repeatedly applying next to a seed value. The sequence ends when next returns null or undefined.

      Type Parameters

      • T

        The element type.

      Parameters

      • seed: T

        The first value in the sequence.

      • next: (value: T) => T | null | undefined

        Called with the current value; returning null/undefined ends the sequence.

      Returns Sequence<T>

      generate(1, n => n < 8 ? n * 2 : null).toArray(); // [1, 2, 4, 8]