deasync
deasync copied to clipboard
Turns async function into sync via JavaScript wrapper of Node event loop
Node calls the tick callback from two places: [`MakeCallback`](https://github.com/nodejs/node/blob/828f0c838e81096b9debd6e7f55e54b556eb7ef8/src/node.cc#L1274) and [`AsyncWrap::MakeCallback`](https://github.com/nodejs/node/blob/f4fd073f0fc19da226de38eb595007bfee4c17d0/src/async-wrap.cc#L385). Originally, I thought maybe `MakeCallback` could be used within `deasync.cc` to gain the same behavior with purely public APIs....
- Existing APIs rely on explicit callback argument or predicate. This API does not require such prior information, just like how the nodejs main loop continues or terminates. - To...
### What 1. Nesting `deasync.loopWhile` cause endless loop + 100% CPU. 2. Nesting `deasync.sleep` cause endless loop. ### Reproduce https://github.com/loynoir/reproduce-deasync-158.js ### Reproduce ```sh $ git clone https://github.com/loynoir/reproduce-deasync-158.js $ npm install...
var result = null; var isDone = false; const p = new Promise((resolve, reject) => { setTimeout(function(){ console.log("This is set time out") resolve('resolved') }, 4000) }) p.then(res =>{ result =...
If I use deasync + net.createConnection, the following code doesn't work on Windows but works on Mac. I tested in Node.js v5.1.0. Does loopWhile not process io events on Windows?...
When turning a Promise into a synchronous Promise Facing the following error: `async hook stack has become corrupted` ``` Error: async hook stack has become corrupted (actual: 6, expected: 7)...
This seems to be a great solution to a difficult problem, and I thank @abbr for the work. But is the project being maintained anymore? Issues are piling up, and...
Hi, i'm trying to run a build with parcel, but I am getting following error message: (node:27024) UnhandledPromiseRejectionWarning: Error: Could not locate the bindings file. Currently using: - node: 14.15.0...
The message port never fires the `port2.onmessage` after the deasync'ed method was called. Minimal reproduction ```js const deasync = require('deasync') const { Worker, isMainThread, parentPort, workerData } = require('worker_threads'); if...
I'm trying to use it with [Jest](https://jestjs.io/) and I see it hangs when I try something like that in a [VM](https://nodejs.org/api/vm.html): ```javascript deasync( util.callbackify( () => new Promise((resolve) => setTimeout(resolve,...