Skip to content
Myr

strip-newline.js

This file

Path

lib/io/strip-newline.js

13 lines · 935 bytes · JavaScript

Last changed by

TweaksSindre Sorhusbefore adoption698a1b8

History of this file

Take it

The walk stopped after 200 commits: lines older than 9f65b86 point at it.

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 1–4why, one step back
1import stripFinalNewlineFunction from 'strip-final-newline';
23// Apply `stripFinalNewline` option, which applies to `result.stdout|stderr|all|stdio[*]`.4// If the `lines` option is used, it is applied on each line, but using a different function.

TweaksSindre Sorhusbefore adoption698a1b8

line 5why, one step back
5export const stripNewline = (value, {stripFinalNewline}, fdNumber, allFds) => value !== undefined && !Array.isArray(value) && getStripFinalNewline(stripFinalNewline, fdNumber, allFds)

100% test coverage (#1018)ehmickybefore adoption9f65b86

lines 6–9why, one step back
6 ? stripFinalNewlineFunction(value)
7 : value;89// Retrieve `stripFinalNewline` option value, including with `subprocess.all`

Fix `result.all` and `subprocess.all` when only some file descriptors are bufferedSindre Sorhusbefore adoption758768f

lines 10–12why, one step back
10// With `subprocess.all`, `allFds` are the file descriptors it actually interleaves. Only those are considered, otherwise a single one would be stripped because another one defaults to being stripped.
11export const getStripFinalNewline = (stripFinalNewline, fdNumber, allFds) => fdNumber === 'all'12 ? allFds.some(allFd => stripFinalNewline[allFd])

100% test coverage (#1018)ehmickybefore adoption9f65b86

line 13why, one step back
13 : stripFinalNewline[fdNumber];