I created await-sync today
it utilize web workers instead of spawning sync processes and data is transfered synchronous over SharedArrayBuffer so less code needs to be copied over.
Therefore it's also more compatible with other enviorments like Deno, Bun, and also Web Workers.
it's as simple as just doing:
import { createWorker } from 'await-sync'
const awaitSync = createWorker()
const fetchSync = awaitSync(async function (...args) {
const res = await fetch(...args)
const ab = await res.arrayBuffer()
return new Uint8Array(ab)
})
const uint8 = fetchSync(url)
const text = new TextDecoder().decode(uint8)
const json = JSON.parse(text)
const blob = new Blob([uint8])
check it out... it's very easy to use.
all the arguments is easily transferable over to the worker cuz it can use structural clone alg instead of passing things around with argv flags. or over stdin/out
so transfering blob / files are very easy. so there is no problem with re-creating a formdata on the worker thread.
I created await-sync today
it utilize web workers instead of spawning sync processes and data is transfered synchronous over
SharedArrayBufferso less code needs to be copied over.Therefore it's also more compatible with other enviorments like Deno, Bun, and also Web Workers.
it's as simple as just doing:
check it out... it's very easy to use.
all the arguments is easily transferable over to the worker cuz it can use structural clone alg instead of passing things around with argv flags. or over stdin/out
so transfering blob / files are very easy. so there is no problem with re-creating a formdata on the worker thread.