Prelude API
    Preparing search index...

    Function while

    • Creates a generator that yields values from the source iterable as long as the predicate returns true.

      Type Parameters

      • T

        The type of elements in the source iterable.

      Parameters

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

        Function that tests each element and its index, returning a boolean.

      Returns (values: Iterable<T>) => Generator<T>

      A generator function that takes an iterable and yields elements until the predicate returns false.

      Elements from the source iterable as long as the predicate returns true.

      G.pipe(
      [1, 2, 3, 4, 5, 1, 2],
      G.while_(x => x < 4),
      G.array
      ) // [1, 2, 3]