Skip to content

mongodb-js/hijack-stream

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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