Skip to content
This repository was archived by the owner on Aug 15, 2024. It is now read-only.

Commit 43e8a38

Browse files
committed
Remove extraneous forEach
1 parent 65991b3 commit 43e8a38

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

lib/MemoryFileSystem.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ MemoryFileSystem.prototype.join = function(a, b) {
179179
return a + "/" + b;
180180
};
181181

182-
// sync functions
182+
// async functions
183183

184184
["stat", "readdir", "mkdirp", "mkdir", "rmdir", "unlink"].forEach(function(fn) {
185185
MemoryFileSystem.prototype[fn] = function(path, callback) {
@@ -192,22 +192,20 @@ MemoryFileSystem.prototype.join = function(a, b) {
192192
};
193193
});
194194

195-
["readFile"].forEach(function(fn) {
196-
MemoryFileSystem.prototype[fn] = function(path, optArg, callback) {
197-
if(!callback) {
198-
callback = optArg;
199-
optArg = undefined;
200-
}
201-
try {
202-
var result = this[fn + "Sync"](path, optArg);
203-
} catch(e) {
204-
return callback(e);
205-
}
206-
return callback(null, result);
207-
};
208-
});
195+
MemoryFileSystem.prototype.readFile = function(path, optArg, callback) {
196+
if(!callback) {
197+
callback = optArg;
198+
optArg = undefined;
199+
}
200+
try {
201+
var result = this.readFileSync(path, optArg);
202+
} catch(e) {
203+
return callback(e);
204+
}
205+
return callback(null, result);
206+
};
209207

210-
MemoryFileSystem.prototype.writeFile = function writeFile(path, content, encoding, callback) {
208+
MemoryFileSystem.prototype.writeFile = function (path, content, encoding, callback) {
211209
if(!callback) {
212210
callback = encoding;
213211
encoding = undefined;

0 commit comments

Comments
 (0)