New answers tagged

2

This async/await code: async function myFunc(doAwait) { doSomething(); if (doAwait) { await doSomethingAsync(); } return doSomethingElse(); } Would be basically equivalent to this: function myFunc(doAwait) { doSomething(); if (doAwait) { return Promise.resolve(doSomethingAsync()).then(doSomethingElse); } ...


3

If I understand correctly, you are trying to implement fibers in JavaScript. If I am wrong, then you just need to look how the JavaScript event loop works. Instead of fibers, you can have promises. As you might expect, you need to partition the stack, so you can preserve the multiple "paths". That is, you need to preserve the execution call stack for each ...


Top 50 recent answers are included