@mirei/ts-collections
    Preparing search index...

    Function reverse

    • Returns a deferred sequence that yields the source elements in reverse order.

      Type Parameters

      • TElement

        Type of elements within the source iterable.

      Parameters

      • source: Iterable<TElement>

        The source iterable.

      Returns IEnumerable<TElement>

      A sequence that produces the elements of source in reverse iteration order.

      The implementation materialises the entire sequence into an array before emitting elements, so avoid using it on infinite sequences or when memory usage is a concern.

      const numbers = [1, 2, 3, 4, 5];
      const reversed = reverse(numbers).toArray();
      console.log(reversed); // [5, 4, 3, 2, 1]