Skip to content

Instantly share code, notes, and snippets.

@why-jay
Last active August 29, 2015 14:12
Show Gist options
  • Save why-jay/1c56f43c939c4acce217 to your computer and use it in GitHub Desktop.
Save why-jay/1c56f43c939c4acce217 to your computer and use it in GitHub Desktop.
const Bluebird = require('bluebird');
const fs = Bluebird.promisifyAll(require('fs'));
const getFilenamesContainingMichaelAsync = Bluebird.coroutine(function* (path) {
const filenames = yield fs.readdirAsync(path);
return filenames.filter(name => name.indexOf('Michael') !== -1);
});
Bluebird.coroutine(function* () {
const filenamesContainingMichael = yield getFilenamesContainingMichaelAsync('~/some_dir');
console.log(filenamesContainingMichael);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment