iterable.js
This file
Path
lib/convert/iterable.js
25 lines · 790 bytes · JavaScript
Last changed by
Fix `lines` option (#957)ehmickybefore adoption15ab4e6
History of this fileTake it
Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9
line 1why, one step back1import {getReadable} from '../pipe/validate.js';Fix `lines` option (#957)ehmickybefore adoption15ab4e6
line 2why, one step back2import {iterateOnSubprocessStream} from './loop.js';Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9
line 3why, one step back3Improve handling of `encoding` option (#926)ehmickybefore adoptiond786fcf
line 4why, one step back4export const createIterable = (subprocess, useBinaryEncoding, {Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9
line 5why, one step back5 from,Prevent handling binary data like text data (#924)ehmickybefore adoptionaf3aefd
line 6why, one step back6 binary: binaryOption = false,Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9
lines 7–8why, one step back7 preserveNewlines = false,8} = {}) => {Improve handling of `encoding` option (#926)ehmickybefore adoptiond786fcf
line 9why, one step back9 const binary = binaryOption || useBinaryEncoding;Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9
line 10why, one step back10 const subprocessStdout = getReadable(subprocess, from);Fix `lines` option (#957)ehmickybefore adoption15ab4e6
line 11why, one step back11 const onStdoutData = iterateOnSubprocessStream({subprocessStdout, subprocess, binary, shouldEncode: true, preserveNewlines});Make subprocess async iterable (#923)ehmickybefore adoption2e8e8c9
lines 12–25why, one step back12 return iterateOnStdoutData(onStdoutData, subprocessStdout, subprocess);13};1415const iterateOnStdoutData = async function * (onStdoutData, subprocessStdout, subprocess) {16 try {17 yield * onStdoutData;18 } finally {19 if (subprocessStdout.readable) {20 subprocessStdout.destroy();21 }2223 await subprocess;24 }25};