Created
June 1, 2012 08:30
All you need to manage queues
This file contains hidden or 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
blog post: http://webreflection.blogspot.de/2012/06/working-with-queues.html