1.0.0 • Published 3 years ago

hijack-stream v1.0.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 years ago

hijack-stream

Temporarily take over a readable stream.

import hijackStream from 'hijack-stream';

const { restore } = hijackStream({
  input: process.stdin,
  ondata(chunk) { if (chunk.includes('done')) restore(); },
  onend(error) { if (error !== null) console.warn(error); }
})

Why not use read instead?

Because readdoes not work inside a Node.js REPL.

LICENSE

MIT