MCPcopy Create free account
hub / github.com/ReactTooltip/react-tooltip / pipeChildOutput

Function pipeChildOutput

benchmarks/run-scaling-series.mjs:74–100  ·  view source on GitHub ↗
(stream, prefix)

Source from the content-addressed store, hash-verified

72}
73
74function pipeChildOutput(stream, prefix) {
75 if (!stream) {
76 return () => {}
77 }
78
79 let pending = ''
80 const handleData = (chunk) => {
81 pending += chunk.toString()
82 const lines = pending.split('\n')
83 pending = lines.pop() ?? ''
84 lines.forEach((line) => {
85 if (line.length > 0) {
86 console.log(`${prefix} ${line}`)
87 }
88 })
89 }
90
91 stream.on('data', handleData)
92
93 return () => {
94 if (pending.length > 0) {
95 console.log(`${prefix} ${pending}`)
96 pending = ''
97 }
98 stream.off('data', handleData)
99 }
100}
101
102function runCommand(command, commandArgs, { label } = {}) {
103 return new Promise((resolve, reject) => {

Callers 1

runCommandFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected