Socket
Socket
Sign inDemoInstall

recursive-fs

Package Overview
Dependencies
0
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.2 to 2.0.0

64

lib/readdirr.js
var fs = require('fs')
var path = require('path')

@@ -15,39 +14,38 @@

exports.readdirr = function (dpath, cb) {
exports.readdirr = function (dpath, done) {
var dirs = [], files = []
dirs.push(dpath)
;(function loop (index) {
if (index == dirs.length) return cb(null, dirs, files)
fs.readdir(dirs[index], function (err, _files) {
if (err) return cb(err)
getstat(dirs[index], _files, function (err) {
if (err) return cb(err)
loop(++index)
})
})
}(0))
;(function walk (_dirs) {
if (!_dirs.length) {
done(null, dirs, files)
return
}
/**
* Get stat
*
* @param {String} directory path
* @param {Array} files
* @param {Function} callback
* @api private
*/
function getstat (dpath, _files, cb) {
;(function loop (index) {
if (index == _files.length) return cb()
var fpath = path.join(dpath, _files[index])
fs.stat(fpath, function (err, stats) {
if (err) return cb(err)
if (stats.isDirectory()) {
dirs.push(fpath)
} else {
files.push(fpath)
var complete = 0
var __dirs = []
for (let dir of _dirs) {
fs.readdir(dir, {withFileTypes: true}, function (err, _files) {
if (err) {
done(err)
return
}
loop(++index)
for (var entry of _files) {
var fpath = `${dir}/${entry.name}`
if (entry.isDirectory()) {
__dirs.push(fpath)
dirs.push(fpath)
}
else {
files.push(fpath)
}
}
if (++complete === _dirs.length) {
walk(__dirs)
}
})
}(0))
}
}
}([dpath]))
}
{
"name": "recursive-fs",
"version": "1.1.2",
"version": "2.0.0",
"description": "Asynchronous recursive file system operations",

@@ -25,5 +25,5 @@ "keywords": [

"devDependencies": {
"coveralls": "^3.0.2",
"coveralls": "^3.0.9",
"istanbul": "^0.4.5",
"mocha": "^5.2.0"
"mocha": "^7.1.0"
},

@@ -48,4 +48,4 @@ "main": "index.js",

"engines": {
"node": ">=4.0.0"
"node": ">=10.0.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc