Created
August 19, 2014 14:38
-
-
Save walling/e430f941f31a03d6938c to your computer and use it in GitHub Desktop.
Bad Transform Stream
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
// 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