Last active
August 29, 2015 14:12
-
-
Save why-jay/1c56f43c939c4acce217 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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