Skip to content

Instantly share code, notes, and snippets.

@nemisj
Last active August 29, 2015 14:23
Show Gist options
  • Save nemisj/e0524f25fe90b158f5fc to your computer and use it in GitHub Desktop.
Save nemisj/e0524f25fe90b158f5fc to your computer and use it in GitHub Desktop.
promise-some
function someAsPromise(arr, cb) {
var index = -1;
var run = function () {
index++;
if (index < arr.length) {
return cb(arr[index]).then(function (val) {
if (val === true) {
return true;
} else {
return run();
}
});
} else {
return false;
}
};
return run();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment