Skip to content

Instantly share code, notes, and snippets.

@creationix
Last active December 23, 2015 04:28
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 creationix/5e44b03ec3e24e5daa05 to your computer and use it in GitHub Desktop.
Save creationix/5e44b03ec3e24e5daa05 to your computer and use it in GitHub Desktop.
new streams
var stream = fs.readStream("myfile.txt");
var sync = false;
stream.ondata = function (chunk) {
//
if (!sync) read();
};
stream.onend = function () {
};
stream.onerror = function (err) {
};
read();
function read() {
while (sync = stream.pull());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment