window.ENTITIES={'/api/snippets/javascript/node.js%20-%20convert%20uint8array%20to%20stream':[{"result":true,"message":null,"batch":{"type":"javascript","name":"node.js - convert uint8array to stream","items":[{"id":"jo6B3p","type":"javascript","name":"Node.js - convert Uint8Array to Stream","content":"const { Readable } = require('stream');\n\nconst blob = new Blob(\n [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\n {type: 'image/webp'}\n);\n\nconst stream = Readable.from(blob.stream());\n\n\n// See also:\n//\n// 1. https://dirask.com/snippets/JavaScript-convert-uint8array-to-ReadableStream-web-browser-only-DgorlD","source":"","author":{"id":"xaOmA0","name":"Lily","avatar":"1629130172536__xaOmA0__w40px_h40px.jpg","points":548,"role":"BASIC"},"creationTime":1677581971000,"updateTime":1677660577000,"removalTime":null},{"id":"1GMxEp","type":"javascript","name":"Node.js - convert Uint8Array to Stream","content":"const { Readable } = require('node:stream');\n\nconst blob = new Blob(\n [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\n {type: 'image/webp'}\n);\n\nconst stream = Readable.from(blob.stream());\n\n\n// See also:\n//\n// 1. https://dirask.com/snippets/JavaScript-convert-uint8array-to-ReadableStream-web-browser-only-DgorlD","source":"","author":{"id":"YoWmgD","name":"chelsea","avatar":"1629030395354__YoWmgD__w40px_h40px.png","points":806,"role":"BASIC"},"creationTime":1677581983000,"updateTime":1677660580000,"removalTime":null},{"id":"jMXxap","type":"javascript","name":"Node.js - convert Uint8Array to Stream","content":"const { Readable } = require('stream');\n\nconst createStream = (type, array) => {\n const blob = new Blob([array], {type});\n const stream = Readable.from(blob.stream());\n};\n\n\n// Usage example:\n\nconst type = 'image/webp';\nconst array = 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\n\nconst stream = createStream(type, array);\n\n\n// See also:\n//\n// 1. https://dirask.com/snippets/JavaScript-convert-uint8array-to-ReadableStream-web-browser-only-DgorlD","source":"","author":{"id":"b0Z2y0","name":"a_horse","avatar":"1629125843498__b0Z2y0__w40px_h40px.jpg","points":538,"role":"BASIC"},"creationTime":1677582344000,"updateTime":1677660571000,"removalTime":null}]}}]};