Skip to content
Myr

output.js

This file

Path

lib/return/output.js

30 lines · 681 bytes · JavaScript

Last changed by

Stricter values for the `encoding` option (#928)ehmickybefore adoption477bbc4

History of this file

Take it

Split files (#837)ehmickybefore adoption672c2d7

lines 1–2why, one step back
1import {Buffer} from 'node:buffer';
2import stripFinalNewline from 'strip-final-newline';

Stricter values for the `encoding` option (#928)ehmickybefore adoption477bbc4

line 3why, one step back
3import {bufferToUint8Array} from '../utils.js';

Print process completion with verbose option (#887)ehmickybefore adoption7264bcf

line 4why, one step back
4import {logFinalResult} from '../verbose/complete.js';

Split files (#837)ehmickybefore adoption672c2d7

lines 5–20why, one step back
5
6export const handleOutput = (options, value) => {7 if (value === undefined || value === null) {8 return;9 }1011 if (Array.isArray(value)) {12 return value;13 }1415 if (Buffer.isBuffer(value)) {16 value = bufferToUint8Array(value);17 }1819 return options.stripFinalNewline ? stripFinalNewline(value) : value;20};

Refactor `reject` option (#868)ehmickybefore adoption1f8a55c

line 21why, one step back
21

Print process completion with verbose option (#887)ehmickybefore adoption7264bcf

lines 22–24why, one step back
22export const handleResult = (result, verboseInfo, {reject}) => {
23 logFinalResult(result, reject, verboseInfo);24

Refactor `reject` option (#868)ehmickybefore adoption1f8a55c

lines 25–30why, one step back
25 if (result.failed && reject) {
26 throw result;27 }2829 return result;30};