Skip to content

Instantly share code, notes, and snippets.

@neovov
Created February 9, 2017 15:28
Show Gist options
  • Save neovov/08189ebf6208de752a9e5ddf9e3059f2 to your computer and use it in GitHub Desktop.
Save neovov/08189ebf6208de752a9e5ddf9e3059f2 to your computer and use it in GitHub Desktop.
ReadableStream piping
// Read a chunk
reader.read().then(function process(result) {
if (result.done) {
return controller.close();
}
console.log('Reading', result.value.length, 'bytes');
controller.enqueue(result.value);
return reader.read().then(process); // Continue reading
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment