npm.io
2.0.1 • Published 2 years ago

hijack-stream

Licence
Apache-2.0
Version
2.0.1
Deps
0
Size
20 kB
Vulns
0
Weekly
0

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 read does not work inside a Node.js REPL.

LICENSE

Apache-2.0

Keywords