Skip to content

Instantly share code, notes, and snippets.

@timoxley
Forked from mhart/test1.js
Created May 3, 2012 13:40
Show Gist options
  • Save timoxley/2585724 to your computer and use it in GitHub Desktop.
Save timoxley/2585724 to your computer and use it in GitHub Desktop.
'cat' in node.js
process.stdin.resume()
process.stdin.on('data', function(data) { process.stdout.write(data) })
process.stdout.on('error', function(err) {
if (err.code === 'EPIPE') process.exit()
else if (!process.stdout.listeners('error').length) process.emit('error', err)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment