Skip to content

Instantly share code, notes, and snippets.

@kessler
Last active December 23, 2015 15:59
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 kessler/6659350 to your computer and use it in GitHub Desktop.
Save kessler/6659350 to your computer and use it in GitHub Desktop.
Are these two patterns to write to a stream equivalent (e.g backpressure handling) ?
//Pattern 1
var stream1 = fs.createWriteStream('some/path1');
function write1() {
var more = stream1.write('something1');
if (more)
write1();
else
stream1.once('drain', write1);
}
write1();
//Pattern 2
var stream2 = fs.createWriteStream('some/path2');
function write2() {
stream2.write('something2', write2);
}
write2();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment