-
-
Save calvinmetcalf/cafc789b3440e21ea28c 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
// In this example, I want to create a stream that pipes a file through a | |
// transform, *without* beginning to read data from the file. I want the | |
// whole pipeline to be lazy until I call read() on the end of the pipeline. | |
// | |
// Instead, the console.log() call fires unexpectedly. | |
var fs = require('fs'), | |
stream = require('stream'); | |
var dest = new stream.Transform({highWaterMark:0}); | |
dest._transform = function(chunk, encoding, callback) { | |
console.log(chunk); | |
}; | |
var result = fs.createReadStream('./foo.txt').pipe(dest); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment