Skip to content

Instantly share code, notes, and snippets.

@kvasdopil
Created June 15, 2018 08:33
Show Gist options
  • Select an option

  • Save kvasdopil/3212dc1f55a4b2fa0763b893e005b160 to your computer and use it in GitHub Desktop.

Select an option

Save kvasdopil/3212dc1f55a4b2fa0763b893e005b160 to your computer and use it in GitHub Desktop.
function filter(args, func, cb) {
const results = args.map(i => null);
const count = 0;
const error = null;
args.map((item, j) =>
func(item, (err, res) => {
count++;
if (err) {
error = err;
} else {
results[j] = res;
}
if(count === args.length) {
cb(error, results.filter(r => r));
}
});
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment