Last active
November 18, 2015 06:06
-
-
Save reportbase/f6ace8977fe6adc3f4b6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var readable = fs.createReadStream('data'); | |
readable.setEncoding('utf8'); | |
readable | |
.on('data', function (data) { console.log('Data!', data); }) | |
.on('error', function (err) { console.error('Error', err); }) | |
.on('end', function () { console.log('All done!'); }); | |
### | |
var readable = fs.createReadStream('a.txt'), | |
writable = fs.createWriteStream('b.txt'); | |
readable.pipe(writable) | |
.on('finish', function () { writable.write('an extra line'); }); | |
### | |
var fs = require("fs"); | |
var split = require("split"); | |
var args = process.argv.slice(2); | |
var lines = ""; | |
process.stdin.resume(); | |
process.stdin.setEncoding('utf8'); | |
process.stdin.on('data', function(a) | |
{ | |
lines += a; | |
}); | |
process.stdin.on('end', function() | |
{ | |
lines = lines.split("\n"); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment