Created
August 15, 2019 01:11
-
-
Save u27a4/3de1fea31e8ab712d37c91db37aecf31 to your computer and use it in GitHub Desktop.
aescript; non-blocking foreach
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
// non-blocking foreach | |
Application.prototype.asyncEach = function(elements, callback, i) { | |
i = i || 0; | |
var self = this; | |
(function () { | |
if (i < elements.length) { | |
if (!(callback(elements, i++) === false)) { | |
self.setTimeout(arguments.callee, 0); | |
} | |
} | |
})(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment