I am rewriting some JavaScript code that uses callbacks to async functions. Basically doing:
function doStuff(callbackFn){
var result = foo();
callbackFn(result);
}
//changing in
async function(){
var result = foo();
return result;
}
//So I can change
doStuff(function(x){
doStuffWith(x)
});
//into
doStuff().then(x => doStuffWith(x));
Now I encounter a function where I have
function doStuff(callbackFn){
var result = foo();
var bar = callbackFn(result);
baz(bar);
}
And I have no idea how to start on this one... Any suggestions?