Skip to content

Commit

Permalink
Convert appropriate functions from fs module
Browse files Browse the repository at this point in the history
Handle undeclared callback parameter
  • Loading branch information
kriszyp committed Feb 23, 2010
1 parent c5ed65d commit 607bf8a
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions fs-promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
*/

var fs = require("fs"),
convertNodeAsyncFunction = require("promise").convertNodeAsyncFunction;
for(var i in fs) {
exports[i] = convertNodeAsyncFunction(fs[i]);
}
convertNodeAsyncFunction = require("./promise").convertNodeAsyncFunction;

// convert all the non-sync functions
for (var i in fs) {
if (!(i.match(/Sync$/))) {
exports[i] = convertNodeAsyncFunction(fs[i]);
}
}

// convert the functions that don't have a declared callback
exports.writeFile = convertNodeAsyncFunction(fs.writeFile, true);
exports.readFile = convertNodeAsyncFunction(fs.readFile, true);

0 comments on commit 607bf8a

Please sign in to comment.