all-sync.js
This file
Path
lib/resolve/all-sync.js
33 lines · 751 bytes · JavaScript
Last changed by
Add more code comments (#984)ehmickybefore adoptionfdd8a9f
History of this fileTake it
12345678910111213141516171819202122232425262728293031323334import {isUint8Array, concatUint8Arrays} from '../utils/uint-array.js';import {stripNewline} from '../io/strip-newline.js';
// Retrieve `result.all` with synchronous methodsexport const getAllSync = ([, stdout, stderr], options) => { if (!options.all) { return; }
if (stdout === undefined) { return stderr; }
if (stderr === undefined) { return stdout; }
if (Array.isArray(stdout)) { return Array.isArray(stderr) ? [...stdout, ...stderr] : [...stdout, stripNewline(stderr, options, 'all')]; }
if (Array.isArray(stderr)) { return [stripNewline(stdout, options, 'all'), ...stderr]; }
if (isUint8Array(stdout) && isUint8Array(stderr)) { return concatUint8Arrays([stdout, stderr]); }
return `${stdout}${stderr}`;};