When there is no way to avoid callback style functions, named functions can help ease the pain.
functionfight(result){rollForDamage(result,keepFighting,failureCallback);}functionkeepFighting(seasonsLeft){closeTheGate(seasonsLeft,finishHim,failureCallback);}functionfinishHim(result){console.log('Hawkins is safe for '+result+' more seasons.');}fightTheDemogorgon(fight);
Also, if you are using node you can use the promisify utility to convert those to promise based functions.
When there is no way to avoid callback style functions, named functions can help ease the pain.
Also, if you are using node you can use the promisify utility to convert those to promise based functions.
Definitely! Love some bluebird and util. Thanks for commenting Heiker!