Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Originally derived from node-ext package.
$ npm install fs2
Same as fs.access. Returns promise.
Same as fs.chmod. Returns promise.
Not available on Windows.
Extra options:
Copy file, returns promise but accepts as well regular callback. Eventual options are passed to underlying fs.createWriteStream
Extra options:
null
instead.Copy directory recursively, returns promise but accepts as well regular callback.
Supported options:
Initializes EMFILE errors prevention.
To be used only in main modules. Never require it in generic module that may be required in others
How it works? If limit of descriptors is reached it holds the calls to native functions and releases them when taken descriptors are freed.
Internally it provides same solution as fs-graceful module with following differences:
Empty directory synchronously
Supported options:
Conditional version of access
. Returns promise.
Supported options:
mode
argument to access
null
instead.Whether path points to a directory
Resolves with true
if provided path points to a directory, false
if provided path points to a non-directory file, null
if there's no file at path. Returns promise.
Whether path points to existing file
Resolves with true
if provided path points to a file, false
if provided path points to existing non-directory file, null
if there's no file at path. Returns promise.
Whether file is ignored up to predefined rules. Returns promise but regular callback is also supported.
Rules are decided by mode argument. Currently only git
mode is supported, in that case rules are searched in .gitignore files (Rules have effect only if placed in valid git repositories).
Other modes can be easily configured by extending _ignoreModes
module (See lib/fs/_ignore-modes directory to see how it's done).
Supported options:
string|array
- additional global rules. They will be matched as if placed in filesystem root directory, it means that any rules found in existing ignore files may override them.bool
- whether to watch for changes. If ignore state would change, returned promise would emit change
event with new value (true/false)Whether path points to a symlimk
Resolves with true
if provided path points to symlink, false
if provided path points to a non-symlink file, null
if there's no file at path. Returns promise.
Additionally resultion can be fine tuned for specific needs with below options:
Supported options:
string
- Expected linkPath to which symlink should point. If provided and symlink points elsewhere false
is returned.bool
- whether check for matching linkPath
should be applied to final path (so if symlink points to other symlink we check against the final path, and not linked symlink path)Same as fs.lchmod. Returns promise.
Only available on Mac OS X.
Same as fs.lstat. Returns promise.
Supported options:
null
instead of erroring if file doesn't existExtended version of native mkdir. Returns promise
Supported options:
mkir -p
, internal implementation inspired by Substack's node-mkdirpExtended version of native fs.readFile. Returns promise
Supported options:
Extended version of native fs.readdir. Returns promise
Suported options:
boolean
- Resolve with null
(instead of error) if directory doesn't existnumber
- Level of recurse into subdirectories. Defaults to 0 which resembles behavior of native version. If you want to recurse without any nest limitation just provide Infinityobject
- Which type of files should be returned. By default all files are returned. Stats methods shows how many different types can be returned. To narrow it down provide a hash. e.g. { file: true, symbolicLink: true }
.regexp
- Filter returned files by specific pattern. Pattern should be regular expression that would be matched against full path.bool
- Watch directory for changes. Changes are emitted on returned promise with change
events. event object states which files were added (event.added
) and which were removed (event.removed
), Starting from next release (v0.4) this functionality will most likely be provided as valid Node.js streambool
- Whether to provide data continuously. Currently it's not provided as a stream per se (it would be starting from next release, v0.4), data is emited as change
events on returned promise object, structure of event objects described under watch optionstring|array
- Whether to obey ignore rules found in ignore files. See fs.isIgnored for more informationstring|array
- Global rules that complement ignoreRules. See fs.isIgnored for more information.function|regexp
- Filter out directories into which we should not recurse to. Can be provided as function which having directory name should return boolaen (true
if we should recurse into directory), or as regex which if matches means that directory should be recurse into. Neverthless depth
setting is supported unconditionallySame as fs.readlink. Returns promise.
Supports loose: true
option, which when passed, resolves with null
(instead of exception) if file at path is not a symlink or it doesn't exist.
Same as fs.realpath. Returns promise.
Supports loose: true
option, which when passed, resolves with null
(instead of exception) if path doesn't exist
Same as fs.rename. Returns promise.
Supported options:
Extended version of native rmdir. Returns promise
Supported options:
Extended version of native rmdirSynnc.
Supported options:
Same as fs.stat. Returns promise.
Supported options:
null
instead of erroring if file doesn't existSame as fs.symlink. Returns promise that resolves with true
if symlink was created (false
can be returned with loose
option, when symlink already exists)
Supported options:
Returns type of file according to provided stats object.
Same as fs.unlink. Returns promise.
Supported options:
Same as fs.unlinkSync, but with support for extra options.
Supported options:
Watch specific path for changes. It's about observing specific file path (not directory content). change
events are emitted with event object where event.type
says wether file was created, modified or removed.
Watch file for changes.
fs.watch wrapper that works same way on every platform, always configured in persistent: false mode.
It's aware of open file descriptors limitations, if EMFILE error is approach, switch to alternative mode that pings file stats (see fs.watchFile) is made.
Same as native fs.writeFile but safe for simultaneous calls of write to same file (in such case current write will be abandonded, and new would be started).
Supported options:
$ npm test
FAQs
fs (file system package) extensions
The npm package fs2 receives a total of 732,164 weekly downloads. As such, fs2 popularity was classified as popular.
We found that fs2 demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.