Last active
March 27, 2016 06:50
-
-
Save huyinghuan/8c07df0a4ec4e589a9e6 to your computer and use it in GitHub Desktop.
async
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async = (queue, over)-> | |
next = -> | |
step = queue.shift() | |
if step | |
step.apply(null, arguments.concat(next)) | |
else | |
over and over() | |
next() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var async = (queue, over)=>{ | |
var next = (...args)=>{ | |
let step = queue.shift(); | |
if(step){ | |
let arg = args.concat(next); | |
step.apply(null, arg) | |
}else{ | |
over() | |
} | |
}; | |
next() | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var async = function(queue, over){ | |
var next = function(){ | |
var step = queue.shift(); | |
if(step){ | |
step.apply(null, arguments.concat(next)); | |
}else{ | |
over && over(); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var whilist = (judgeFn, task, finishAll)=>{ | |
if(!judgeFn()){return finishAll();} | |
task(()=> whilist(judgeFn, task, finishAll)) | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment