Comparing version 0.3.0 to 0.4.0
@@ -7,9 +7,9 @@ var normalize = require("./normalize"); | ||
module.exports = function join(path, request) { | ||
if(request == "") return normalize(path); | ||
if(!request) return normalize(path); | ||
if(absoluteWinRegExp.test(request)) return normalize(request.replace(/\//g, "\\")); | ||
if(absoluteNixRegExp.test(request)) return normalize(request); | ||
if(path == "/") return normalize(path + request); | ||
if(absoluteWinRegExp.test(path)) return normalize(path + "\\" + request.replace(/\//g, "\\")); | ||
if(absoluteWinRegExp.test(path)) return normalize(path.replace(/\//g, "\\") + "\\" + request.replace(/\//g, "\\")); | ||
if(absoluteNixRegExp.test(path)) return normalize(path + "/" + request); | ||
return normalize(path + "/" + request); | ||
}; | ||
}; |
@@ -65,3 +65,3 @@ /* | ||
if(!isDir(current[path[i]])) | ||
return null; | ||
return; | ||
current = current[path[i]]; | ||
@@ -218,3 +218,3 @@ } | ||
MemoryFileSystem.prototype.join = require("./join"); | ||
MemoryFileSystem.prototype.pathToArray = pathToArray; | ||
MemoryFileSystem.prototype.normalize = normalize; | ||
@@ -278,3 +278,3 @@ | ||
["stat", "readdir", "mkdirp", "mkdir", "rmdir", "unlink", "readlink"].forEach(function(fn) { | ||
["stat", "readdir", "mkdirp", "rmdir", "unlink", "readlink"].forEach(function(fn) { | ||
MemoryFileSystem.prototype[fn] = function(path, callback) { | ||
@@ -284,8 +284,35 @@ try { | ||
} catch(e) { | ||
return callback(e); | ||
setImmediate(function() { | ||
callback(e); | ||
}); | ||
return; | ||
} | ||
return callback(null, result); | ||
setImmediate(function() { | ||
callback(null, result); | ||
}); | ||
}; | ||
}); | ||
["mkdir", "readFile"].forEach(function(fn) { | ||
MemoryFileSystem.prototype[fn] = function(path, optArg, callback) { | ||
if(!callback) { | ||
callback = optArg; | ||
optArg = undefined; | ||
} | ||
try { | ||
var result = this[fn + "Sync"](path, optArg); | ||
} catch(e) { | ||
setImmediate(function() { | ||
callback(e); | ||
}); | ||
return; | ||
} | ||
setImmediate(function() { | ||
callback(null, result); | ||
}); | ||
}; | ||
}); | ||
MemoryFileSystem.prototype.exists = function(path, callback) { | ||
@@ -295,15 +322,2 @@ return callback(this.existsSync(path)); | ||
MemoryFileSystem.prototype.readFile = function(path, optArg, callback) { | ||
if(!callback) { | ||
callback = optArg; | ||
optArg = undefined; | ||
} | ||
try { | ||
var result = this.readFileSync(path, optArg); | ||
} catch(e) { | ||
return callback(e); | ||
} | ||
return callback(null, result); | ||
}; | ||
MemoryFileSystem.prototype.writeFile = function (path, content, encoding, callback) { | ||
@@ -310,0 +324,0 @@ if(!callback) { |
{ | ||
"name": "memory-fs", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "A simple in-memory filesystem. Holds data in a javascript object.", | ||
@@ -9,2 +9,5 @@ "main": "lib/MemoryFileSystem.js", | ||
}, | ||
"files": [ | ||
"lib/" | ||
], | ||
"scripts": { | ||
@@ -11,0 +14,0 @@ "test": "mocha", |
@@ -13,3 +13,3 @@ # memory-fs | ||
// Async variantes too | ||
// Async variants too | ||
fs.unlink("/a/test/dir/file.txt", function(err) { | ||
@@ -16,0 +16,0 @@ // ... |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13090
5
343