all.js
This file
Path
lib/stream/all.js
30 lines · 1.3 KiB · JavaScript
Last changed by
Fix `lines` option (#957)ehmickybefore adoption15ab4e6
History of this fileTake it
Split files (#837)ehmickybefore adoption672c2d7
line 1why, one step back1import mergeStreams from '@sindresorhus/merge-streams';Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 2why, one step back2import {waitForSubprocessStream} from './subprocess.js';Split files (#837)ehmickybefore adoption672c2d7
lines 3–8why, one step back34// `all` interleaves `stdout` and `stderr`5export const makeAllStream = ({stdout, stderr}, {all}) => all && (stdout || stderr)6 ? mergeStreams([stdout, stderr].filter(Boolean))7 : undefined;8Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 9why, one step back9// Read the contents of `subprocess.all` and|or wait for its completionFix `lines` option (#957)ehmickybefore adoption15ab4e6
lines 10–11why, one step back10export const waitForAllStream = ({subprocess, encoding, buffer, maxBuffer, lines, stripFinalNewline, streamInfo}) => waitForSubprocessStream({11 stream: subprocess.all,Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 12why, one step back12 subprocess,Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40
line 13why, one step back13 fdNumber: 1,Split files (#837)ehmickybefore adoption672c2d7
lines 14–16why, one step back14 encoding,15 buffer,16 maxBuffer: maxBuffer * 2,Fix `lines` option (#957)ehmickybefore adoption15ab4e6
lines 17–19why, one step back17 lines,18 allMixed: getAllMixed(subprocess),19 stripFinalNewline,Split files (#837)ehmickybefore adoption672c2d7
lines 20–22why, one step back20 streamInfo,21});22Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343
line 23why, one step back23// When `subprocess.stdout` is in objectMode but not `subprocess.stderr` (or the opposite), we need to use both:Split files (#837)ehmickybefore adoption672c2d7
lines 24–26why, one step back24// - `getStreamAsArray()` for the chunks in objectMode, to return as an array without changing each chunk25// - `getStreamAsArrayBuffer()` or `getStream()` for the chunks not in objectMode, to convert them from Buffers to string or Uint8Array26// We do this by emulating the Buffer -> string|Uint8Array conversion performed by `get-stream` with our own, which is identical.Fix `lines` option (#957)ehmickybefore adoption15ab4e6
lines 27–30why, one step back27const getAllMixed = ({all, stdout, stderr}) => all28 && stdout29 && stderr30 && stdout.readableObjectMode !== stderr.readableObjectMode;