Created
August 12, 2014 22:57
-
-
Save bttmly/4aba241e0f2cd50242f7 to your computer and use it in GitHub Desktop.
promises...
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
var Promise = require("bluebird"); | |
var fs = require("fs"); | |
Promise.promisifyAll(fs); | |
// fs.readFileAsync("file.js", "utf8").then(...) | |
var readFileTree = function ( root ) { | |
var results = []; | |
return new Promise( function ( resolve, reject ) { | |
// do stuff | |
// do stuff | |
if (done) { | |
resolve( results ) | |
} else { | |
repeat | |
} | |
}) | |
} | |
readFileTree().then( function (results) { | |
// | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment