Permalink
Browse files

Convert appropriate functions from fs module

Handle undeclared callback parameter
  • Loading branch information...
1 parent c5ed65d commit 607bf8a98e8c8510c7dfbea1fc018142601df441 @kriszyp committed Feb 23, 2010
Showing with 12 additions and 4 deletions.
  1. +12 −4 fs-promise.js
View
@@ -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.