Gathering detailed insights and metrics for smart-fs
Gathering detailed insights and metrics for smart-fs
Gathering detailed insights and metrics for smart-fs
Gathering detailed insights and metrics for smart-fs
npm install smart-fs
Typescript
Module System
Min. Node Version
Node Version
NPM Version
74.9
Supply Chain
99.3
Quality
77.4
Maintenance
50
Vulnerability
97.6
License
JavaScript (100%)
Total Downloads
527,875
Last Day
192
Last Week
1,559
Last Month
8,774
Last Year
64,637
MIT License
4 Stars
2,031 Commits
2 Forks
1 Watchers
7 Branches
4 Contributors
Updated on Jan 29, 2025
Minified
Minified + Gzipped
Latest Version
5.0.2
Package Id
smart-fs@5.0.2
Unpacked Size
15.88 kB
Size
5.70 kB
File Count
14
NPM Version
10.9.2
Node Version
22.13.1
Published on
Jan 29, 2025
Cumulative downloads
Total Downloads
Last Day
3,740%
192
Compared to previous day
Last Week
-28.8%
1,559
Compared to previous week
Last Month
6.7%
8,774
Compared to previous month
Last Year
21.5%
64,637
Compared to previous year
8
Abstraction Layer for File Management.
Drop in replacement for fs.
$ npm install --save smart-fs
Extends and returns filepath with the file extension as appropriate. Returns null
if no good match was found.
A few notes:
null
when multiple possible extensions are foundTo exclude certain extensions from being matched provide them in the exclude
option.
Iteratively walk dirpath and return relative paths of all files contained.
Will only return entries where fs.lstatSync(...).isFile()
evaluates to true (this excludes symlinks).
Delete file and all empty parent directories.
Core logic of smartRead
but takes content and refPath.
Read and parse file based on file extension.
The following extensions are handled in order:
.json
: Loads file using JSON.parse..xml
: Loads file using xml-js..yml
and .yaml
: Loads file using yaml-boost..js
: Loads file using import. Result is a promise!.*
: Treats file as text file and loads as array of lines.Note that the required cache is not automatically invalidated when loading cached .js
files.
To ignore file extension and force treat the file as a certain type, you can pass the option treatAs
as e.g. json
.
To simply load yml files without resolving them pass resolve
as false
Serialize and write content to file based on file extension.
The file and all necessary folders are created if not present.
The file is only actually written if the content has changed. Returns true if the file was written, false otherwise.
The following extension are handled in order:
.json
: Serialize uses JSON.stringify..xml
: Serialize using xml-js..yml
and .yaml
: Serialize uses yaml-boost..*
: Expects content as array and serializes by joining array using new line character.To ignore file extension and force treat the file as a certain type, you can pass the option treatAs
as e.g. json
.
The mergeStrategy
option can be used to customize how the new content is merged if the target file already exists.
By default the file is simply overwritten.
When create
is set to false
no action is taken if the file does not already exist.
When pretty
is set to true
, the output is formatted more compact.
When keepOrder
is set to true
and a file is overwritten,
the new content is ordered according to the existing content (e.g. for json
and yml
)
To resolve
the original file before overwrite merging pass the option as true
.
Do not use this library for loading if you don't trust the source of the files you are loading!
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
4 existing vulnerabilities detected
Details
Reason
Found 8/17 approved changesets -- score normalized to 4
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-16
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More