-
-
Save lvivski/2853647 to your computer and use it in GitHub Desktop.
All you need to manage queues
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
function Queue(q) {"use strict"; | |
// (C) WebReflection - Mit Style License | |
var | |
next = function next() { | |
return (callback = q.shift()) ? !!callback(q) || !0 : !1; | |
}, | |
callback | |
; | |
(q.wait = function wait(condition, delay) { | |
condition || callback && q.unshift(callback); | |
setTimeout(q.next = next, delay || 0); | |
})(1); | |
return q; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment