Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
node async foreach
Array.prototype.forEachAsync = function (callback, complete) {
var raiseComplete/*: (arg?: bool) => void*/ = complete ? (function (arg) {
complete(arg);
}) : (function () { });
function next (self, index, length) { /* rec */
if (index === length) {
raiseComplete(true);
} else {
process.nextTick(function () {
function closureNext () {
next(self, index + 1, length);
}
var flow = callback(self[index], index, self, closureNext);
if (flow === false) {
raiseComplete(false);
} else if (flow === true) {
return; // closure next
} else {
closureNext();
}
});
}
}
next(Object(this), 0, this.length);
};
@pH200
Owner

JavaScript, Y U NO HAVE PATTERN MATCHING

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.