Last active
August 29, 2015 14:23
-
-
Save nemisj/e0524f25fe90b158f5fc to your computer and use it in GitHub Desktop.
promise-some
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
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