Skip to content

Instantly share code, notes, and snippets.

@walling
Created August 19, 2014 14:38
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 walling/e430f941f31a03d6938c to your computer and use it in GitHub Desktop.
Save walling/e430f941f31a03d6938c to your computer and use it in GitHub Desktop.
Bad Transform Stream
// dd if=/dev/urandom of=file count=10 bs=1m
var through2 = require('through2');
var fs = require('fs');
fs.createReadStream('file').pipe(slowTransform()).pipe(process.stdout);
function slowTransform() {
return through2(function(buffer, encoding, callback) {
var self = this;
setTimeout(function(buffer) {
self.push(buffer.length + '\n');
}, 100, buffer);
callback();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment