Skip to content

Instantly share code, notes, and snippets.

@dcortesnet
Last active February 14, 2023 12:57
Show Gist options
  • Select an option

  • Save dcortesnet/56a270c7af768e18eb9eacec166a9e1e to your computer and use it in GitHub Desktop.

Select an option

Save dcortesnet/56a270c7af768e18eb9eacec166a9e1e to your computer and use it in GitHub Desktop.
Nodejs creación de stream tipo read
const Stream = require('stream');
const readableStream = new Stream.Readable();
readableStream.push('Hola');
readableStream.push(' ');
readableStream.push('Mundo');
readableStream.push(null);
async function getContentReadStream(readable) {
for await (const chunk of readable) {
console.log(chunk);
console.log(chunk.toString());
}
}
getContentReadStream(readableStream);
// <Buffer 48 6f 6c 61 20 4d 75 6e 64 6f>
// Hola Mundo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment