❗ See the comments I overengineered this, my solution is far from ideal. Good discussion in comments!
I am writing a book on tooling! Check it out: https://lachlanmiller.ck.page/92dfa0...
/ lachlan19900
I had an interview recently which featured an interesting question. In this video, I share the question and my solution, along with a construct, the mighty deferred promise. There's a TC39 proposal for it under the name "withResolvers": https://github.com/tc39/proposalprom...
Corrections: 5:00 pdefer isn't necessary here you can just return a promise. pdefer is useful if you want to resolve or reject the promise afterwards, from outside the location it was originally created. Example improvement: https://gist.github.com/lmiller1990/2.... See comments for discussion.