Skip to content

Instantly share code, notes, and snippets.

@apaleslimghost
Last active July 13, 2016 15:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apaleslimghost/8a30aea540ec8f426d31add4ecfe5cad to your computer and use it in GitHub Desktop.
Save apaleslimghost/8a30aea540ec8f426d31add4ecfe5cad to your computer and use it in GitHub Desktop.
const compactSparse = xs => xs.filter(x => typeof x !== 'undefined');
module.exports = function(xs, f) {
const yea = [];
const nay = [];
return Promise.all(xs.map(function(x, i) {
return f(x).then(well => (well ? yea : nay)[i] = x);
})).then(() => [yea, nay].map(compactSparse));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment