Gathering detailed insights and metrics for nodejs-fs-utils
Gathering detailed insights and metrics for nodejs-fs-utils
Gathering detailed insights and metrics for nodejs-fs-utils
Gathering detailed insights and metrics for nodejs-fs-utils
@alwatr/node-fs
Enhanced file system operations in Node.js with asynchronous queue to prevent parallel writes.
dir-fs-utils
A NodeJS library that creates several utility functions over the native fs module for directories
kurento-fs
kurento's nodejs of fs utils class
@alwatr/nanolib
Necessary library for all ECMAScript (JavaScript/TypeScript) projects.
A set of extra functionalities for nodejs Modules
npm install nodejs-fs-utils
Typescript
Module System
Node Version
NPM Version
80.7
Supply Chain
99
Quality
76
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Total Downloads
1,140,164
Last Day
1,380
Last Week
6,352
Last Month
22,040
Last Year
197,066
12 Stars
38 Commits
4 Forks
2 Branches
2 Contributors
Updated on May 26, 2023
Minified
Minified + Gzipped
Latest Version
1.2.6
Package Id
nodejs-fs-utils@1.2.6
Unpacked Size
78.74 kB
Size
12.55 kB
File Count
21
NPM Version
6.14.14
Node Version
14.17.5
Published on
Nov 30, 2021
Cumulative downloads
Total Downloads
Last Day
17%
1,380
Compared to previous day
Last Week
38.2%
6,352
Compared to previous week
Last Month
79.9%
22,040
Compared to previous month
Last Year
4.2%
197,066
Compared to previous year
1
NodeJs FileSystem (FS) extra utilities
symbolicLinks
- treat symbolic links as files ( default true
)skipErrors
- skip errors just log them ( default false
)symbolicLinks
- treat symbolic links as files ( default true
)countFolders
- counts and folder inode size ( default true
)countSymbolicLinks
- counts symbolic links inode size ( default true
)logErrors
- log all error in an array ( default false
)skipErrors
- skip errors just log them ( default false
)symlinksKeep
- specify how to treat symlinks
accepted values: *"file", "directory", "all"*
symlinksNormalize
- specify if is needed link normalizing
accepted values: *"auto", "none", "relative", "absolute"*
linkFiles
- for files linking instead of coping
accepted values: *"auto", "none", "relative", "absolute"*
symbolicLinks
- treat symbolic links as files ( default true
)countFolders
- counts and folder inode size ( default true
)countSymbolicLinks
- counts symbolic links inode size ( default true
)logErrors
- log all error in an array ( default false
)skipErrors
- skip errors just log them ( default false
)symlinksKeep
- specify how to treat symlinks
accepted values: *"file", "directory", "all"*
symlinksNormalize
- specify if is needed link normalizingaccepted values: *"auto", "none", "relative", "absolute"*
linkFiles
- for files linking instead of coping
accepted values: *"auto", "none", "relative", "absolute"*
symbolicLinks
- treat symbolic links as files ( default true
)countFolders
- counts and folder inode size ( default true
)countSymbolicLinks
- counts symbolic links inode size ( default true
)logErrors
- log all error in an array ( default false
)skipErrors
- skip errors just log them ( default false
)optional can be send fs module in
"fs"
option, P.S. it removes link files or directories.
1 var fsUtils = require("nodejs-fs-utils"); 2 3 //removing a folder 4 fsUtils.rmdirs("test/folder", function (err) { 5 // callback code 6 }); 7 8 // removing a folder and remove recursive in symbolic links 9 // treat the as folders if necessary 10 fsUtils.rmdirs("test/folder", function (err) { 11 // callback code 12 }, { 13 symbolicLinks : false 14 }); 15 16 // try to remove, skip errors 17 fsUtils.rmdirs("test/folder", function (err) { 18 // callback code 19 }, { 20 skipErrors : true 21 });
1 var fsUtils = require("nodejs-fs-utils"); 2 3 // removing a folder 4 // symbolic links will be unlinked instead of removing files from them 5 fsUtils.rmdirsSync("test/folder"); 6 7 // removing a folder and remove recursive in symbolic links 8 // treat the symbolic links as folders if these links to directories 9 fsUtils.rmdirsSync("test/folder", { 10 symbolicLinks : false 11 }); 12 13 // try to remove, skip errors 14 fsUtils.rmdirsSync("test/folder", { 15 skipErrors : true 16 });
remove contents of a directory
1 var fsUtils = require("nodejs-fs-utils"); 2 3 // removing folder's contents 4 fsUtils.emptyDir("test/folder", function (err) { 5 // callback code 6 });
remove contents of a directory, synchronous
1 var fsUtils = require("nodejs-fs-utils"); 2 3 // removing folder's contents 4 fsUtils.emptyDirSync("test/folder");
checks if folder is empty
1 var fsUtils = require("nodejs-fs-utils"); 2 3 // return state = true if folder is empty 4 fsUtils.isEmpty("test/folder", function (err, state) { 5 // callback code 6 });
checks if folder is empty, synchronous
1 var fsUtils = require("nodejs-fs-utils"); 2 3 // return state = true if folder is empty 4 fsUtils.isEmptySync("test/folder");
optional can be send fs module in
"fs"
option
1 var fsUtils = require("nodejs-fs-utils"); 2 3 // removing a folder 4 // the function will stop an exception on symlink detection 5 fsUtils.mkdirs("newfolder/folder/subfolder", function (err) { 6 // callback code 7 }); 8 9 // treat the symbolic links as folders if these links to directories 10 fsUtils.rmdirs("newfolder/folder/symbolic-link/subfolder", { 11 symbolicLinks : false 12 }, function (err) { 13 // callback code 14 });
1 var fsUtils = require("nodejs-fs-utils"); 2 3 // removing a folder 4 // the function will throw an exception on symlink detection 5 fsUtils.mkdirs("newfolder/folder/subfolder"); 6 7 // treat the symbolic links as folders if these links to directories 8 fsUtils.rmdirs("newfolder/folder/symbolic-link/subfolder", { 9 symbolicLinks : false 10 });
removing file or directories
removing file or directories
optional can be send fs module in
"fs"
option
1 var fsUtils = require("nodejs-fs-utils"); 2 3 // return file size 4 fsUtils.fsize("videos/video.mp4", function (err, size) { 5 // callback code 6 }); 7 8 9 // the function will stop on a symlink detection 10 fsUtils.fsize("newfolder/folder/subfolder", function (err, size) { 11 // callback code 12 }); 13 14 15 // treat the symbolic links as folders if these links to directories 16 fsUtils.fsize("newfolder/folder/symbolic-link/subfolder", { 17 symbolicLinks : false 18 }, function (err, size) { 19 // callback code 20 }); 21 22 23 // don't stop scanning on errors 24 fsUtils.fsize("newfolder/folder/symbolic-link/subfolder", { 25 skipErrors : true 26 }, function (err, size) { 27 // callback code 28 }); 29 30 31 // don't stop scanning on errors 32 // return an array of all errors 33 fsUtils.fsize("newfolder/folder/symbolic-link/subfolder", { 34 skipErrors : true, 35 logErrors : true 36 }, function (err, size) { 37 // callback code 38 }); 39 40 41 // don't count folders size 42 fsUtils.fsize("newfolder/folder/symbolic-link/subfolder", { 43 countFolders : false 44 }, function (err, size) { 45 // callback code 46 }); 47 48 49 // don't scan links and don't count links size 50 fsUtils.fsize("newfolder/folder/symbolic-link/subfolder", { 51 countSymbolicLinks : false 52 }, function (err, size) { 53 // callback code 54 });
1 var fsUtils = require("nodejs-fs-utils"); 2 3 // return file size 4 var size = fsUtils.fsizeSync("videos/video.mp4"); 5 6 7 // the function will stop on a symlink detection 8 var size = fsUtils.fsizeSync("newfolder/folder/subfolder", function (err, size) { 9 // callback code 10 }); 11 12 13 // treat the symbolic links as folders if these links to directories 14 var size = fsUtils.fsizeSync("newfolder/folder/symbolic-link/subfolder", { 15 symbolicLinks : false 16 }); 17 18 19 // don't stop scanning on errors 20 var config = { skipErrors : true }; 21 var size = fsUtils.fsizeSync("newfolder/folder/symbolic-link/subfolder", config); 22 if (config.errors.length) { 23 console.log("Error detected: ", config.errors[0]) 24 } 25 26 27 // don't stop scanning on errors 28 // return an array of all errors 29 var config = { skipErrors : true }; 30 var size = fsUtils.fsizeSync("newfolder/folder/symbolic-link/subfolder", config); 31 if (config.errors.length) { 32 console.log("Error detected: ", config.errors[0]) 33 } 34 35 36 // don't count folders size 37 var size = fsUtils.fsizeSync("newfolder/folder/symbolic-link/subfolder", { 38 countFolders : false 39 }); 40 41 42 // don't scan links and don't count links size 43 var size = fsUtils.fsizeSync("newfolder/folder/symbolic-link/subfolder", { 44 countSymbolicLinks : false 45 });
move file of folders or links
symlinksNormalize
- specify how to treat symlinks
specify if is needed link normalizing
accepted values: "auto"
, "none"
, "relative"
, "absolute"
"auto"
, "none"
or "absolute"
- uses absolute path
"relative"
- uses relative paths for links
P.S "auto"
will be dynamic in future, will try to use relative if it is posiblesymlinksKeep
- specify if is needed to keep simplinks or to move files or folders
accepted values: "file", "directory", "all"linkFiles
- for files linking instead of moving
accepted values: "auto", "none", "relative", "absolute"symbolicLinks
- treat symbolic links as files ( default true
)countFolders
- counts and folder inode size ( default true
)countSymbolicLinks
- counts symbolic links inode size ( default true
)logErrors
- log all error in an array ( default false
)skipErrors
- skip errors just log them ( default false
)
P.S. if is true
the errors will be an array1 var fsUtils = require("nodejs-fs-utils"); 2 3 // move file or folders 4 fsUtils.move(__dirname + "/source", "./destination-path", function (err, cache) { 5 if (!err) { 6 console.log("Moved !"); 7 } else { 8 console.error("Error", err) 9 } 10 }); 11 12 // move files and skip errors 13 fsUtils.move(__dirname + "/source", "./destination-path", function (errors, cache) { 14 if (!errors.length) { 15 console.log("Moved !"); 16 } else { 17 errors.forEach(function (err) { 18 console.error("Error", err) 19 }); 20 } 21 }, { 22 skipErrors : true 23 }); 24
synchronous version for move function
1 var fsUtils = require("nodejs-fs-utils"); 2 var moveSync = fsUtils.moveSync; 3 4 // move file or folders 5 moveSync(__dirname + "/source", "./destination-path", function (err, cache) { 6 if (!err) { 7 console.log("Moved !"); 8 } else { 9 console.error("Error", err) 10 } 11 }); 12 13 // move files and skip errors 14 moveSync(__dirname + "/source", "./destination-path", function (errors, cache) { 15 if (!errors.length) { 16 console.log("Moved !"); 17 } else { 18 errors.forEach(function (err) { 19 console.error("Error", err) 20 }); 21 } 22 }, { 23 skipErrors : true 24 }); 25
copy file of folders or links
symlinksNormalize
- specify how to treat symlinks
specify if is needed link normalizing
accepted values: "auto"
, "none"
, "relative"
, "absolute"
"auto"
, "none"
or "absolute"
- uses absolute path
"relative"
- uses relative paths for links
P.S "auto"
will be dynamic in future, will try to use relative if it is posiblesymlinksKeep
- specify if is needed to keep simplinks or to copy files or folders
accepted values: "file", "directory", "all"linkFiles
- for files linking instead of coping
accepted values: "auto", "none", "relative", "absolute"symbolicLinks
- treat symbolic links as files ( default true
)countFolders
- counts and folder inode size ( default true
)countSymbolicLinks
- counts symbolic links inode size ( default true
)logErrors
- log all error in an array ( default false
)skipErrors
- skip errors just log them ( default false
)
P.S. if is true
the errors will be an array1 var fsUtils = require("nodejs-fs-utils"); 2 3 // copy file or folders 4 fsUtils.copy(__dirname + "/source", "./destination-path", function (err, cache) { 5 if (!err) { 6 console.log("Copied !"); 7 } else { 8 console.error("Error", err) 9 } 10 }); 11 12 // copy files and skip errors 13 fsUtils.copy(__dirname + "/source", "./destination-path", function (errors, cache) { 14 if (!errors.length) { 15 console.log("Copied !"); 16 } else { 17 errors.forEach(function (err) { 18 console.error("Error", err) 19 }); 20 } 21 }, { 22 skipErrors : true 23 }); 24 25 // link files instead of copying 26 fsUtils.copy(__dirname + "/source", "./destination-path", function (err, cache) { 27 if (!err) { 28 console.log("Files were linked !"); 29 } else { 30 console.error("Error", err) 31 } 32 }, { 33 linkFiles : "relative" 34 }); 35
synchronous version for copy function
1 var fsUtils = require("nodejs-fs-utils"); 2 var copySync = fsUtils.copySync; 3 4 // copy file or folders 5 copySync(__dirname + "/source", "./destination-path", function (err, cache) { 6 if (!err) { 7 console.log("Copied !"); 8 } else { 9 console.error("Error", err) 10 } 11 }); 12 13 // copy files and skip errors 14 copySync(__dirname + "/source", "./destination-path", function (errors, cache) { 15 if (!errors.length) { 16 console.log("Copied !"); 17 } else { 18 errors.forEach(function (err) { 19 console.error("Error", err) 20 }); 21 } 22 }, { 23 skipErrors : true 24 }); 25 26 // link files instead of copying 27 copySync(__dirname + "/source", "./destination-path", function (err, cache) { 28 if (!err) { 29 console.log("Files were linked !"); 30 } else { 31 console.error("Error", err) 32 } 33 }, { 34 linkFiles : "relative" 35 }); 36
optional can be send fs module in
"fs"
option cache reference can be used for storing data while walking
1 var fsUtils = require("nodejs-fs-utils"); 2 3 // walk througth a list of files and folders in a folder 4 fsUtils.walk("./videos", function (err, path, stats, next, cache) { 5 // callback code 6 // ... 7 // stats.isDirectory() 8 // 9 // cache.errors is array of errors 10 // continue walk 11 next(); 12 }); 13 14 // walk througth a list of files and folders in a folder 15 fsUtils.walk("./videos", function (err, path, stats, next, cache) { 16 // callback code 17 // ... 18 // stats.isDirectory() 19 // 20 // cache.errors is array of errors 21 // continue walk 22 next(); 23 }, function (cache) { 24 console.log("Walk is finished"); 25 }); 26 27 28 // treat the symbolic links as folders if these links to directories 29 fsUtils.walk("newfolder/folder/symbolic-link/subfolder", { 30 symbolicLinks : false 31 }, function (err, path, stats, next, cache) { 32 // callback code 33 next(); 34 }); 35 36 37 // don't stop scanning on errors 38 fsUtils.walk("newfolder/folder/symbolic-link/subfolder", { 39 skipErrors : true 40 }, function (err, path, stats, next, cache) { 41 // callback code 42 next(); 43 }); 44 45 46 // don't stop scanning on errors 47 // return an array of all errors in cache reference 48 fsUtils.walk("newfolder/folder/symbolic-link/subfolder", { 49 skipErrors : true, 50 logErrors : true 51 }, function (err, path, stats, next, cache) { 52 // callback code 53 next(); 54 }, function (cache) { 55 if (cache.errors.length) { 56 console.log("Errors: ", cache.errors); 57 } else { 58 console.log("No errors found"); 59 } 60 }); 61
walkSync
has same api aswalk
, but it is synchronous
1 var fsUtils = require("nodejs-fs-utils"); 2 3 // walk througth a list of files and folders in a folder 4 fsUtils.walkSync("./videos", function (err, path, stats, next, cache) { 5 // callback code 6 // ... 7 // stats.isDirectory() 8 // 9 // cache.errors is array of errors 10 // continue walk 11 next(); 12 }); 13 14 // walk througth a list of files and folders in a folder 15 fsUtils.walkSync("./videos", function (err, path, stats, next, cache) { 16 // callback code 17 // ... 18 // stats.isDirectory() 19 // 20 // cache.errors is array of errors 21 // continue walk 22 next(); 23 }, function (cache) { 24 console.log("Walk is finished"); 25 }); 26 27 28 // treat the symbolic links as folders if these links to directories 29 fsUtils.walkSync("newfolder/folder/symbolic-link/subfolder", { 30 symbolicLinks : false 31 }, function (err, path, stats, next, cache) { 32 // callback code 33 next(); 34 }); 35 36 37 // don't stop scanning on errors 38 fsUtils.walkSync("newfolder/folder/symbolic-link/subfolder", { 39 skipErrors : true 40 }, function (err, path, stats, next, cache) { 41 // callback code 42 next(); 43 }); 44 45 46 // don't stop scanning on errors 47 // return an array of all errors in cache reference 48 fsUtils.walkSync("newfolder/folder/symbolic-link/subfolder", { 49 skipErrors : true, 50 logErrors : true 51 }, function (err, path, stats, next, cache) { 52 // callback code 53 next(); 54 }, function (cache) { 55 if (cache.errors.length) { 56 console.log("Errors: ", cache.errors); 57 } else { 58 console.log("No errors found"); 59 } 60 });
getArray of folders in a array
1 var fsUtils = require("nodejs-fs-utils"); 2 // getArray of folders in a array 3 var folders = []; 4 fsUtils.walkSync("newfolder/folder/symbolic-link/subfolder", { 5 skipErrors : true, 6 logErrors : true 7 }, function (err, path, stats, next, cache) { 8 if (!err && stats.isDirectory()) { 9 folders.push(path); 10 } 11 next(); 12 });
remove folders with name "tmp"
1 var fsUtils = require("nodejs-fs-utils"); 2 var fs = require("fs"); 3 4 // synchronous 5 fsUtils.walkSync("newfolder/folder/symbolic-link/subfolder", { 6 skipErrors : true, 7 logErrors : true 8 }, function (err, path, stats, next, cache) { 9 if (!err && stats.isDirectory() && path.match(/\/tmp$/)) { 10 fs.unlinkSync(path); 11 } else { 12 next(); 13 } 14 }); 15 16 // asynchronous 17 fsUtils.walk("newfolder/folder/symbolic-link/subfolder", { 18 skipErrors : true, 19 logErrors : true, 20 stackPushEnd: true // push new observed files to end of the stack insteat of beginig 21 }, function (err, path, stats, next, cache) { 22 if (!err && stats.isDirectory() && path.match(/\/tmp$/)) { 23 fs.unlinkSync(path); 24 25 // for async to tell that step is done 26 // without this row onend callback will not be trigered 27 cache.count++; 28 } else { 29 next(); 30 } 31 }, function (cache) { // optional 32 console.log("Finished") 33 });
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
Found 1/29 approved changesets -- score normalized to 0
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
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-05-05
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