Skip to content
Myr

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 file

Take it

Split files (#837)ehmickybefore adoption672c2d7

line 1why, one step back
1import mergeStreams from '@sindresorhus/merge-streams';

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 2why, one step back
2import {waitForSubprocessStream} from './subprocess.js';

Split files (#837)ehmickybefore adoption672c2d7

lines 3–8why, one step back
3
4// `all` interleaves `stdout` and `stderr`5export const makeAllStream = ({stdout, stderr}, {all}) => all && (stdout || stderr)6 ? mergeStreams([stdout, stderr].filter(Boolean))7 : undefined;8

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 9why, one step back
9// Read the contents of `subprocess.all` and|or wait for its completion

Fix `lines` option (#957)ehmickybefore adoption15ab4e6

lines 10–11why, one step back
10export 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 back
12 subprocess,

Rename `index` to `fdNumber` (#862)ehmickybefore adoption295ef40

line 13why, one step back
13 fdNumber: 1,

Split files (#837)ehmickybefore adoption672c2d7

lines 14–16why, one step back
14 encoding,
15 buffer,16 maxBuffer: maxBuffer * 2,

Fix `lines` option (#957)ehmickybefore adoption15ab4e6

lines 17–19why, one step back
17 lines,
18 allMixed: getAllMixed(subprocess),19 stripFinalNewline,

Split files (#837)ehmickybefore adoption672c2d7

lines 20–22why, one step back
20 streamInfo,
21});22

Rename `spawned` and `child process` to `subprocess` (#897)ehmickybefore adoption8fe2343

line 23why, one step back
23// 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 back
24// - `getStreamAsArray()` for the chunks in objectMode, to return as an array without changing each chunk
25// - `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 back
27const getAllMixed = ({all, stdout, stderr}) => all
28 && stdout29 && stderr30 && stdout.readableObjectMode !== stderr.readableObjectMode;