Skip to content

Instantly share code, notes, and snippets.

@tizzo
Last active December 17, 2015 21:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tizzo/f291bd93b1d680a6815e to your computer and use it in GitHub Desktop.
Save tizzo/f291bd93b1d680a6815e to your computer and use it in GitHub Desktop.
Node.js streams example
node_modules
line 1
line 2
line 3
line 4
line 5
var through2 = require('through2');
var split2 = require('split2');
var noopStream = through2();
process.stdin
.pipe(noopStream);
noopStream
.pipe(split2())
.pipe(through2(function(data, enc, done) {
data = data + ' I added a thing!!!!!!\n';
done(null, data);
}))
.pipe(process.stdout);
/*
var createWriteStream(path) {
var writeStream = through2();
var s3obj = new AWS.S3({params: {Bucket: this.bucket, Key: path}});
s3obj.upload({Body: writeStream})
//.on('httpUploadProgress', function(evt) { console.log(evt); })
.send(function(err, data) { });
return writeStream;
}
*/
{
"name": "streams-playground",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"split2": "^1.0.0",
"through2": "^2.0.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment