[Edit]
+
0
-
0

Node.js - convert Uint8Array to Stream

1 2 3 4 5 6 7 8 9 10 11 12 13
const { Readable } = require('node:stream'); const blob = new Blob( [new Uint8Array([82, 73, 70, 70, 26, 0, 0, 0, 87, 69, 66, 80, 86, 80, 56, 76, 13, 0, 0, 0, 47, 0, 0, 0, 16, 7, 16, 17, 17, 136, 136, 254, 7, 0])], // 1x1 px transparent WEBP image bytes {type: 'image/webp'} ); const stream = Readable.from(blob.stream()); // See also: // // 1. https://dirask.com/snippets/JavaScript-convert-uint8array-to-ReadableStream-web-browser-only-DgorlD