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

    Function tap

    • Invokes the specified action for each element while yielding the original elements unchanged.

      Type Parameters

      • TElement

        Type of elements within source.

      Parameters

      Returns IEnumerable<TElement>

      The original sequence, enabling fluent chaining.

      The action executes lazily as the sequence is iterated, making it suitable for logging or instrumentation.

      const numbers = [1, 2, 3];
      const tapped = tap(numbers, x => console.log(`Processing: ${x}`))
      .select(x => x * 2)
      .toArray();
      console.log(tapped); // [2, 4, 6]
      // Expected console output:
      // Processing: 1
      // Processing: 2
      // Processing: 3