Dev Helpers
← Back

Read a chunk with a reader

Read a chunk with a reader using Node.js.

Open this example in the interactive library

Source code

const source = () =>
  new ReadableStream({
    start(c) {
      c.enqueue("a");
      c.enqueue("b");
      c.close();
    },
  });
console.log((await source().getReader().read()).value);

Sample output

a