Dev Helpers
← Back

Decode a stream of bytes

Decode a stream of bytes 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 Array.fromAsync(
    new Blob(["café"]).stream().pipeThrough(new TextDecoderStream()),
  ),
);

Sample output

[ 'café' ]