Skip to content

Instantly share code, notes, and snippets.

@fujidig
Created September 21, 2011 08:28
Show Gist options
  • Save fujidig/1231565 to your computer and use it in GitHub Desktop.
Save fujidig/1231565 to your computer and use it in GitHub Desktop.
function deferredTimeout(delay) {
var deferred = new Deferred();
setTimeout(function() {
deferred.callback({
called: true
})
},
delay);
return deferred;
}
function a() {
for (var i = 0; i < 4; ++i) {
console.log("a"+i);
await deferredTimeout(1000);
}
}
function b() {
for (var i = 0; i < 4; ++i) {
console.log("b"+i);
await deferredTimeout(1000);
}
}
function main() {
await a();
await b();
}
var d = main().then(function () { console.log('Done!'); });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment