jquery ..... deferred
$.when((_=>{setTimeout(()=>{console.log('---internal----');_.resolve();},5000);return _;})($.Deferred())).done(_=>console.log('**callback**'));
$.when((_=>{setTimeout(()=>{console.log('---internal----');_.resolve();},5000);return _;})($.Deferred())).done(_=>console.log('**callback**'));