@metreeca/flow - v0.10.0
    Preparing search index...

    Function pipe

    • Creates a pipe.

      Brackets a feed, the tasks chained to it and the Sink optionally closing them, declaring the composition a pipe so that it reads as one unit rather than as a run of juxtaposed calls.

      Type Parameters

      • V extends Feed<unknown> | Promise<unknown>

        The type of the composition, either the Feed a pipe left open ends with or the promise the closing sink reports

      Parameters

      • source: V

        The composition to bracket

      Returns V

      source, as handed in: a feed ready for manual iteration, or a promise resolving to the result the closing sink computes over the items

      await pipe(
      (items([1, 2, 3]))
      (map(n => n*2))
      (toArray())
      ); // [2, 4, 6], as the closing sink resolves the pipe

      for await (const item of pipe(
      (range(1, 4))
      (map(n => n*2))
      )) {
      console.log(item); // 2, 4, 6, drawn from the feed a pipe left open ends with
      }