idempotent-fs
v1.2.0
Published
fs.unlink() that won't throw if the file is missing + other outcome-aware Node.js fs functions
Downloads
259
Readme
idempotent-fs.js
fs.unlink()
that won't throw if the file is missing + other outcome-aware Node.js "fs" functions
What is this?
We have taken inspiration from idempotent REST APIs.
The functions provided here intentionally mirror the "fs" module that Node.js provides, but will not throw errors under certain outcome-oriented conditions.
We've wrapped any asynchronous functions provided here with the wonderful pify,
you can use either Promise
-style or traditional callback-style.
Internally, we use graceful-fs instead of using the built-in "fs" module directly.
Usage
mkdir()
and mkdirSync()
See the upstream mkdir()
and mkdirSync
"fs" functions in Node.js.
Changed: No "EEXIST" error. Trying to
mkdir()
a directory that already exists is not an error. Mission accomplished!Changed: internally uses mkdirp
rmdir()
and rmdirSync()
See the upstream rmdir()
and rmdirSync
"fs" functions in Node.js.
- Changed: No "ENOENT" error. Trying to
rmdir()
a directory that is already gone is no longer an error. Mission accomplished!
unlink()
and unlinkSync()
See the upstream unlink()
and unlinkSync
"fs" functions in Node.js.
- Changed: No "ENOENT" error. Trying to
unlink()
a file that is already gone is no longer an error. Mission accomplished!
Roadmap
[ ]
chmod()
,fchmod()
,lchmod()
??[ ]
chown()
,fchown()
,lchown()
??[ ]
mkdir()
should also test provided mode (if any)