

enfspatch
Additional methods and patches for node fs module
enfs stands for [E]asy [N]ode [fs]
Description
This module will change some behaviors of fs module from node
such as creating a queue for opening files when limit is reached,
catching the error's and proceeding with the process when possible.
- This module will add following methods to node fs module:
- existStat
- existLStat
- existFStat
- existStatSync
- existLStatSync
- existFStatSync
- existAccess
- existAccessSync
- And will change the behaviour of:
Usage
enfspatch
is a drop-in replacement for native fs
module, you just need to include
it instead of the native module.
Use this
var enfs = require("esnofspatch");
instead of
var fs = require("fs");
and all the methods from native fs module are available
Errors
All the methods follows the node culture.
- Async: Every async method returns an Error in the first callback parameter
- Sync: Every sync method throws an Error.
Additional Methods
exists
Change the natural behaviour of fs.exists to the node culture, it will return an error
in the first callback parameter.
As exists is deprecated if it cease to exist then exists will use (#existStat) instead
Sync:
enfs.exists("/etc/passwd", function(err, itemExists){
console.log(itemExists ? 'it\'s there' : 'no passwd!');
});
check: fs.exists
existAccess
- existAccess(path, [mode], callback)
Will use fs.access to check if the item exists in the file system and if the process
as access to the item.
Sync:
- existAccessSync(path, [mode])
enfs.existAccess("/etc/passwd", function(err,itemExists){
console.log(itemExists ? "it\'s there and have access" : "don\'t exist or don\'t have access");
});
check: fs.access
existStat
existLStat
- existStat(path,callback)
- existLStat(path,callback)
Will use fs.stat to check if the item exists in the file system.
Sync:
- existStatSync(path)
- existLStatSync(path)
enfs.existStat("/etc/passwd", function(err,itemExists){
console.log(itemExists ? "it\'s there" : "don\'t exist");
});
check: fs.stat
enfs.existLStat("/etc/passwd", function(err,itemExists){
console.log(itemExists ? "it\'s there" : "don\'t exist");
});
check: fs.lstat
existFStat
Will use fs.fstat to check if the item exists in the file system.
Sync:
enfs.existFStat("/etc/passwd", function(err,itemExists){
console.log(itemExists ? "it\'s there" : "don\'t exist");
});
check: fs.fstat
Credit
This module is based on graceful-fs
License
Creative Commons Attribution 4.0 International License
Copyright (c) 2016 Joao Parreira joaofrparreira@gmail.com GitHub
This work is licensed under the Creative Commons Attribution 4.0 International License.
To view a copy of this license, visit CC-BY-4.0.