x-path
Advanced tools
Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "x-path", | ||
"description": "An extention for native node path module.", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"homepage": "https://github.com/node-x-extras/x-path", | ||
@@ -6,0 +6,0 @@ "bugs": "https://github.com/node-x-extras/x-path/issues", |
@@ -34,21 +34,11 @@ /* | ||
path.isDirectory = function(filePath, cb) { | ||
function statAsync(isType, filePath, cb) { | ||
fs.stat(filePath, function (err, stat) { | ||
var exists; | ||
err = err && ['ENOENT', 'ENOTDIR'].indexOf(err.code) < 0 ? err : null; | ||
if (!err) { exists = stat ? stat.isDirectory() : false; } | ||
if (!err) { exists = stat ? stat[isType]() : false; } | ||
cb(err, exists); | ||
}); | ||
}; | ||
path.isFile = function(filePath, cb) { | ||
fs.stat(filePath, function (err, stat) { | ||
var exists; | ||
err = err && ['ENOENT', 'ENOTDIR'].indexOf(err.code) < 0 ? err : null; | ||
if (!err) { exists = stat ? stat.isFile() : false; } | ||
cb(err, exists); | ||
}); | ||
}; | ||
path.isDirectorySync = function(filePath) { | ||
} | ||
function statSync(isType, filePath, cb) { | ||
var stat; | ||
@@ -61,16 +51,18 @@ try { | ||
} | ||
return stat.isDirectory(); | ||
}; | ||
return stat[isType](); | ||
} | ||
path.isFileSync = function(filePath) { | ||
var stat; | ||
try { | ||
stat = fs.statSync(filePath); | ||
} catch (e) { | ||
if (['ENOENT', 'ENOTDIR'].indexOf(e.code) < 0) { throw e; } | ||
return false; | ||
} | ||
return stat.isFile(); | ||
path.isDirectory = function(filePath, cb) { | ||
return statAsync('isDirectory', filePath, cb) | ||
}; | ||
path.isFile = function(filePath, cb) { | ||
return statAsync('isFile', filePath, cb) | ||
}; | ||
path.isDirectorySync = function(filePath, cb) { | ||
return statSync('isDirectory', filePath, cb) | ||
}; | ||
path.isFileSync = function(filePath, cb) { | ||
return statSync('isFile', filePath, cb) | ||
}; | ||
module.exports = path; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
11301
182