Prelude API
    Preparing search index...

    Function lift

    • Converts an iterator to an iterable (generator) or returns an iterable as is. This is the opposite of extracting an iterator from an iterable.

      Type Parameters

      • T

        The type of elements in the iterator or iterable

      Parameters

      • values: Iterator<T, any, any> | Iterable<T, any, any>

        An iterator or iterable to convert

      Returns Iterable<T>

      The original iterable if input is already iterable, otherwise a new iterable wrapping the iterator

      // Using with an iterator
      const arr = [1, 2, 3];
      const iter = arr[Symbol.iterator]();
      const iterable = G.lift(iter);
      // Now you can use iterable multiple times
      const result1 = Array.from(iterable); // [1, 2, 3]

      // Using with an iterable (passes through)
      const sameArr = G.lift(arr); // Just returns arr

      generator - The underlying function used to wrap an iterator