Created
June 1, 2019 13:08
-
-
Save Semigradsky/da3e5d1884feab7290b8ab76d80f43cf to your computer and use it in GitHub Desktop.
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
module.exports = function (servers, check) { | |
let promise = Promise.resolve(); | |
for (const server of servers) { | |
promise = promise | |
.then(() => check(server)) | |
.then(res => { | |
if (res === false) { | |
throw server | |
} | |
}) | |
} | |
return promise.catch(err => err); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment