Skip to content

Instantly share code, notes, and snippets.

@u27a4
Created August 15, 2019 01:11
Show Gist options
  • Save u27a4/3de1fea31e8ab712d37c91db37aecf31 to your computer and use it in GitHub Desktop.
Save u27a4/3de1fea31e8ab712d37c91db37aecf31 to your computer and use it in GitHub Desktop.
aescript; non-blocking foreach
// 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