Skip to content

Commit

Permalink
Add pipe variant where destination is PipableCommand (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeLyon authored Dec 10, 2021
1 parent e33964b commit d660d0e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Sources/Script/Pipe.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ public func | <T>(
}
}

/**
Special form of `pipe` which allows piping to a builtin like `map`
*/
public func pipe<SourceOutcome, DestinationOutcome>(
_ outputChannel: Shell.OutputChannel,
of source: () async throws -> SourceOutcome,
to destination: Shell.PipableCommand<DestinationOutcome>
) async throws -> (source: SourceOutcome, destination: DestinationOutcome) {
try await pipe(outputChannel, of: source, to: { try await destination.body() })
}

public func pipe<SourceOutcome, DestinationOutcome>(
_ outputChannel: Shell.OutputChannel,
of source: () async throws -> SourceOutcome,
Expand Down

0 comments on commit d660d0e

Please sign in to comment.