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

    Function pipe

    • Applies a user-defined pipeline to source and returns the operator's result.

      Type Parameters

      • TElement

        Type of elements within source.

      • TResult

        Result type produced by operator.

      Parameters

      Returns TResult

      The value produced by operator after optionally enumerating source.

      Re-throws any error thrown by operator or during enumeration initiated by the operator.

      The operator chooses how the sequence is consumed, making this helper convenient for custom aggregations, projections, or interop scenarios.

      const numbers = [1, 2, 3, 4, 5];
      const sum = pipe(numbers, e => e.sum());
      console.log(sum); // 15

      const filteredAndDoubled = pipe(numbers, e =>
      e.where(x => x % 2 === 0).select(x => x * 2).toArray()
      );
      console.log(filteredAndDoubled); // [4, 8]