Missing opportunities | Sololearn: Learn to code for FREE!

0

Missing opportunities

https://code.sololearn.com/czTke51irn5E/?ref=app

11/16/2020 3:56:12 AM

A I

1 Answer

New Answer

+1

Cannot you just define a simple function wrapAwait like this: function wrapAwait(func){ return function(...args) { return new Promise((resolve, reject)=>{ func(...args, (...callbackArgs)=>{ resolve(callbackArgs); }); }); }; } and use it like const getFromDbA = wrapAwait(getFromDb); let [error, data] = await getFromDbA(1); ? Of course you still have to worry about the original function raising an exception.