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

    Function index

    • Enumerates the sequence while exposing the zero-based index alongside each element.

      Type Parameters

      • TElement

        Type of elements within the source iterable.

      Parameters

      • source: Iterable<TElement>

        The source iterable.

      Returns IEnumerable<[number, TElement]>

      A sequence of [index, element] tuples.

      The index is assigned in the order elements are produced. Enumeration is deferred until the result is iterated.

      const letters = ['a', 'b', 'c'];
      const indexed = index(letters).toArray();
      console.log(indexed); // [[0, 'a'], [1, 'b'], [2, 'c']]