Skip to content

Instantly share code, notes, and snippets.

@azu
Created February 20, 2014 14:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save azu/9114925 to your computer and use it in GitHub Desktop.
Save azu/9114925 to your computer and use it in GitHub Desktop.
Promise.filter
var listTree = FS.listTree("../../data/", function isIndexHTML(filePath, stat) {
if (stat.isDirectory()) {
return false;
}
return path.basename(filePath) === "index.html";
}).then(function (fileList) {
var promiseMap = Promise.filter(fileList, function (filePath) {
return FS.exists(path.join(path.dirname(filePath), "index.json")).then(function(result){
return !result;
});
});
return Promise.all(promiseMap).then(function (res) {
console.log(res);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment