setup.js
This file
Path
lib/pipe/setup.js
72 lines · 2.2 KiB · JavaScript
Last changed by
Add more code comments (#984)ehmickybefore adoptionfdd8a9f
History of this fileTake it
Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86
line 1why, one step back1import isPlainObject from 'is-plain-obj';Rename files (#977)ehmickybefore adoption4b2e316
line 2why, one step back2import {normalizePipeArguments} from './pipe-arguments.js';Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
line 3why, one step back3import {handlePipeArgumentsError} from './throw.js';Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
lines 4–5why, one step back4import {waitForBothSubprocesses} from './sequence.js';5import {pipeSubprocessStream} from './streaming.js';Improve piping processes (#834)ehmickybefore adoption1a47ea2
lines 6–7why, one step back6import {unpipeOnAbort} from './abort.js';7Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 8why, one step back8// Pipe a subprocess' `stdout`/`stderr`/`stdio` into another subprocess' `stdin`Upgrade xo (#980)ehmickybefore adoptionccfa412
lines 9–10why, one step back9export const pipeToSubprocess = (sourceInfo, ...pipeArguments) => {10 if (isPlainObject(pipeArguments[0])) {Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 11why, one step back11 return pipeToSubprocess.bind(undefined, {Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86
line 12why, one step back12 ...sourceInfo,Upgrade xo (#980)ehmickybefore adoptionccfa412
line 13why, one step back13 boundOptions: {...sourceInfo.boundOptions, ...pipeArguments[0]},Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86
lines 14–16why, one step back14 });15 }16Upgrade xo (#980)ehmickybefore adoptionccfa412
line 17why, one step back17 const {destination, ...normalizedInfo} = normalizePipeArguments(sourceInfo, ...pipeArguments);Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
line 18why, one step back18 const promise = handlePipePromise({...normalizedInfo, destination});Upgrade xo (#980)ehmickybefore adoptionccfa412
lines 19–24why, one step back19 promise.pipe = pipeToSubprocess.bind(undefined, {20 ...sourceInfo,21 source: destination,22 sourcePromise: promise,23 boundOptions: {},24 });Improve piping processes (#834)ehmickybefore adoption1a47ea2
lines 25–27why, one step back25 return promise;26};27Add more code comments (#984)ehmickybefore adoptionfdd8a9f
line 28why, one step back28// Asynchronous logic when piping subprocessesFix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 29–36why, one step back29const handlePipePromise = async ({30 sourcePromise,31 sourceStream,32 sourceOptions,33 sourceError,34 destination,35 destinationStream,36 destinationError,Rename `signal` option to `unpipeSignal` (#852)ehmickybefore adoption9dc1141
line 37why, one step back37 unpipeSignal,Refactor `stdio` option (#927)ehmickybefore adoptionc9cdd2d
line 38why, one step back38 fileDescriptors,Add `result|error.durationMs` (#896)ehmickybefore adoption7088091
line 39why, one step back39 startTime,Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
line 40why, one step back40}) => {Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 41why, one step back41 const subprocessPromises = getSubprocessPromises(sourcePromise, destination);Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
lines 42–46why, one step back42 handlePipeArgumentsError({43 sourceStream,44 sourceError,45 destinationStream,46 destinationError,Refactor `stdio` option (#927)ehmickybefore adoptionc9cdd2d
line 47why, one step back47 fileDescriptors,Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
line 48why, one step back48 sourceOptions,Add `result|error.durationMs` (#896)ehmickybefore adoption7088091
line 49why, one step back49 startTime,Fix errors thrown by `.pipe()` (#854)ehmickybefore adoption46ba4b4
line 50why, one step back50 });Improve piping processes (#834)ehmickybefore adoption1a47ea2
lines 51–52why, one step back51 const maxListenersController = new AbortController();52 try {Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 53why, one step back53 const mergedStream = pipeSubprocessStream(sourceStream, destinationStream, maxListenersController);Improve piping processes (#834)ehmickybefore adoption1a47ea2
line 54why, one step back54 return await Promise.race([Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 55why, one step back55 waitForBothSubprocesses(subprocessPromises),Upgrade xo (#980)ehmickybefore adoptionccfa412
lines 56–62why, one step back56 ...unpipeOnAbort(unpipeSignal, {57 sourceStream,58 mergedStream,59 sourceOptions,60 fileDescriptors,61 startTime,62 }),Improve piping processes (#834)ehmickybefore adoption1a47ea2
lines 63–66why, one step back63 ]);64 } finally {65 maxListenersController.abort();66 }Improve spawning errors (#847)ehmickybefore adoption381dee2
line 67why, one step back67};Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86
line 68why, one step back68Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 69why, one step back69// `.pipe()` awaits the subprocess promises.Improve `.pipe()` method (#859)ehmickybefore adoption2ef9e86
lines 70–71why, one step back70// When invalid arguments are passed to `.pipe()`, we throw an error, which prevents awaiting them.71// We need to ensure this does not create unhandled rejections.Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 72why, one step back72const getSubprocessPromises = (sourcePromise, destination) => Promise.allSettled([sourcePromise, destination]);