8.2.0
Pipes supercharge today! ๐
Features
- Delayed piping. You can fill dependent streams at any time during the origin process lifecycle (even when finished) without losing data. #914
const result = $`echo 1; sleep 1; echo 2; sleep 1; echo 3`
const piped1 = result.pipe`cat`
let piped2
setTimeout(() => {
piped2 = result.pipe`cat`
}, 1500)
await piped1
assert.equal((await piped1).toString(), '1\n2\n3\n')
assert.equal((await piped2).toString(), '1\n2\n3\n')
const file = tempfile()
const fileStream = fs.createWriteStream(file)
const p = $`echo "hello"`
.pipe(
new Transform({
transform(chunk, encoding, callback) {
callback(null, String(chunk).toUpperCase())
},
})
)
.pipe(fileStream)
p instanceof WriteStream // true
await p === fileStream // true
(await fs.readFile(file)).toString() // 'HELLO\n'