Skip to content

Instantly share code, notes, and snippets.

@Semigradsky
Created June 1, 2019 13:08
Show Gist options
  • Save Semigradsky/da3e5d1884feab7290b8ab76d80f43cf to your computer and use it in GitHub Desktop.
Save Semigradsky/da3e5d1884feab7290b8ab76d80f43cf to your computer and use it in GitHub Desktop.
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