I try to use some JS library with ServiceWorker, without access to Node.JS FileSystem functionality. That original library export result in the same way
Import * as fs from 'fs'
...
JsLib.export(result, fs.createWriteStream("res.pdf"))
I need the same export, but export to byte array, without FileSystem. I have create array in the same way
const Out = (Array as any).create("byte", mysize)
and if I manually fill this byte array with test data, my algorithm working fine further.
But I don’t understand how to correctly create the same stream as Node.JS created, but in memory, in my “Out” array.
There are some example in MDN with WritableStream, but I’m not sure how that examples related to this task. Maybe there is cheap solution like
JsLib.export(result, ...Out)
Or this solution not emulated fs.createWriteStream? Directly using spread syntax is impossible “A spread argument must either have a tuple type or be passed to a rest parameter”. But how to solve this quest correctly?