mongodb-js / hijack-stream

Temporarily take over a readable stream

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

About

Temporarily take over a readable stream

License:Apache License 2.0


Languages

Language:TypeScript 100.0%