sequence.js
This file
Path
lib/pipe/sequence.js
24 lines · 950 bytes · JavaScript
Last changed by
Not known.
History of this fileTake it
The walk stopped after 200 commits: lines older than c8a6ed7 point at it.
Improve documentation (#1003)ehmickybefore adoptionc8a6ed7
lines 1–24why, one step back1// Like Bash, we await both subprocesses. This is unlike some other shells which only await the destination subprocess.2// Like Bash with the `pipefail` option, if either subprocess fails, the whole pipe fails.3// Like Bash, if both subprocesses fail, we return the failure of the destination.4// This ensures both subprocesses' errors are present, using `error.pipedFrom`.5export const waitForBothSubprocesses = async subprocessPromises => {6 const [7 {status: sourceStatus, reason: sourceReason, value: sourceResult = sourceReason},8 {status: destinationStatus, reason: destinationReason, value: destinationResult = destinationReason},9 ] = await subprocessPromises;1011 if (!destinationResult.pipedFrom.includes(sourceResult)) {12 destinationResult.pipedFrom.push(sourceResult);13 }1415 if (destinationStatus === 'rejected') {16 throw destinationResult;17 }1819 if (sourceStatus === 'rejected') {20 throw sourceResult;21 }2223 return destinationResult;24};