You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is the wrong tool for most tasks! Prefer async APIs whenever possible.
The benefit of this package over packages like deasync is that this one is not a native Node.js addon (which comes with a lot of problems). Instead, this package executes the given function synchronously in a worker or subprocess.
importmakeSynchronousfrom'make-synchronous/subprocess';makeSynchronous(async()=>{// Runs in a subprocess.});
Subprocess execution is slower, but has the benefit of full process isolation.
API
makeSynchronous(asyncFunction | string)
Returns a wrapped version of the given async function or a string representation to a async function which executes synchronously. This means no other code will execute (not even async code) until the given async function is done.
The function is executed in a worker or subprocess, so you cannot access variables or imports from outside its scope. Use await import(…) to import dependencies inside the function.
Uses MessagePort#postMessage() or the V8 serialization API to transfer arguments, return values, errors between the worker or subprocess and the current process. Most values are supported — except functions and symbols.
Related
make-asynchronous - Make a synchronous function asynchronous by running it in a worker