New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

recursive-readdir-async

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

recursive-readdir-async - npm Package Compare versions

Comparing version

to
1.1.1

.coveralls.yml

12

module.min.js

@@ -15,3 +15,3 @@ "use strict";const LIST=1,TREE=2

* @preserve
*/async function stat(file){return new Promise(function(e,t){FS.stat(file,function(n,l){n?t(n):e(l)})})}function checkItem(path,e){for(let t=0;t<e.exclude.length;t++)if(path.indexOf(e.exclude[t])>-1)return!1;return!0}async function myReaddir(path,e,t){const n=[];return new Promise(function(t,r){try{FS.realpath(path,function(i,a){(i||!1===e.realPath)&&(a=path),e.normalizePath&&(a=normalizePath(a)),FS.readdir(a,function(i,o){if(i)r(i);else{for(let t=0,r=o.length;t<r;t++){const r={name:o[t],path:a,fullname:a+(a.endsWith(pathSimbol)?"":pathSimbol)+o[t]};checkItem(r.fullname,e)&&(l(r,o[t]),n.push(r))}t(n)}})})}catch(e){r(e)}});function l(n,file){e.extensions&&(n.extension=PATH.extname(file).toLowerCase()),e.deep&&(n.deep=t)}}function normalizePath(path){return path.replace(/\\/g,"/")}async function listDir(path,e,progress,t){let n;t=null==t?0:t;try{n=await myReaddir(path,e,t)}catch(e){return{error:e,path:path}}return(e.stats||e.recursive||e.ignoreFolders||e.mode==TREE)&&(n=await statDir(n,e,progress,t)),function(){for(let t=0;t<e.include.length;t++)for(let l=n.length-1;l>-1;l--){let r=n[l];e.mode===TREE&&r.isDirectory&&r.content||-1===r.fullname.indexOf(e.include[t])&&n.splice(l,1)}}(),n}async function statDir(e,t,progress,n){let l=!0;for(let r=e.length-1;r>-1;r--){try{e=await statDirItem(e,r,t,progress,n),null!=progress&&(l=!progress(e[r],e.length-r,e.length))}catch(t){e[r].error=t}(e[r].isDirectory&&t.ignoreFolders&&null==e[r].content&&null==e[r].error||!l)&&e.splice(r,1)}return e}async function statDirItem(e,t,n,progress,l){const r=await stat(e[t].fullname);return e[t].isDirectory=r.isDirectory(),n.stats&&(e[t].stats=r),e[t].isDirectory&&n.recursive&&(n.mode==LIST?e=e.concat(await listDir(e[t].fullname,n,progress,l+1)):(e[t].content=await listDir(e[t].fullname,n,progress,l+1),0==e[t].content.length&&(e[t].content=null))),e}
*/async function stat(file){return new Promise(function(e,t){FS.stat(file,function(n,l){n?t(n):e(l)})})}function checkItem(path,e){for(let t=0;t<e.exclude.length;t++)if(path.indexOf(e.exclude[t])>-1)return!1;return!0}async function myReaddir(path,e,t){const n=[];return new Promise(function(t,r){try{FS.realpath(path,function(i,a){(i||!1===e.realPath)&&(a=path),e.normalizePath&&(a=normalizePath(a)),FS.readdir(a,function(i,o){if(i)r(i);else{for(let t=0,r=o.length;t<r;t++){const r={name:o[t],path:a,fullname:a+(a.endsWith(pathSimbol)?"":pathSimbol)+o[t]};checkItem(r.fullname,e)&&(l(r,o[t]),n.push(r))}t(n)}})})}catch(e){r(e)}});function l(n,file){e.extensions&&(n.extension=PATH.extname(file).toLowerCase()),e.deep&&(n.deep=t)}}function normalizePath(path){return path.toString().replace(/\\/g,"/")}async function listDir(path,e,progress,t){let n;t=null==t?0:t;try{n=await myReaddir(path,e,t)}catch(e){return{error:e,path:path}}return(e.stats||e.recursive||e.ignoreFolders||e.mode==TREE)&&(n=await statDir(n,e,progress,t)),function(){for(let t=0;t<e.include.length;t++)for(let l=n.length-1;l>-1;l--){let r=n[l];e.mode===TREE&&r.isDirectory&&r.content||-1===r.fullname.indexOf(e.include[t])&&n.splice(l,1)}}(),n}async function statDir(e,t,progress,n){let l=!0;for(let r=e.length-1;r>-1;r--){try{e=await statDirItem(e,r,t,progress,n),null!=progress&&(l=!progress(e[r],e.length-r,e.length))}catch(t){e[r].error=t}(e[r].isDirectory&&t.ignoreFolders&&null==e[r].content&&null==e[r].error||!l)&&e.splice(r,1)}return e}async function statDirItem(e,t,n,progress,l){const r=await stat(e[t].fullname);return e[t].isDirectory=r.isDirectory(),n.stats&&(e[t].stats=r),e[t].isDirectory&&n.recursive&&(n.mode==LIST?e=e.concat(await listDir(e[t].fullname,n,progress,l+1)):(e[t].content=await listDir(e[t].fullname,n,progress,l+1),0==e[t].content.length&&(e[t].content=null))),e}
/**

@@ -23,2 +23,10 @@ * Returns a javascript object with directory items information (non blocking async with Promises)

* @preserve
*/async function list(path,options,progress){"function"==typeof options&&(progress=options);const e={mode:LIST,recursive:!0,stats:!1,ignoreFolders:!0,extensions:!1,deep:!1,realPath:!0,normalizePath:!0,include:[],exclude:[]};return null!=options&&(null!=options.recursive&&(e.recursive=options.recursive),null!=options.mode&&(e.mode=options.mode),null!=options.stats&&(e.stats=options.stats),null!=options.ignoreFolders&&(e.ignoreFolders=options.ignoreFolders),null!=options.deep&&(e.deep=options.deep),null!=options.extensions&&(e.extensions=options.extensions),null!=options.realPath&&(e.realPath=options.realPath),null!=options.normalizePath&&(e.normalizePath=options.normalizePath),null!=options.include&&(e.include=options.include),null!=options.exclude&&(e.exclude=options.exclude)),pathSimbol=!1===e.normalizePath?PATH.sep:"/",await listDir(path,e,progress)}module.exports={LIST:LIST,TREE:TREE,list:list,stat:stat,fs:FS,path:PATH};
*/async function list(path,options,progress){"function"==typeof options&&(progress=options);const e={mode:LIST,recursive:!0,stats:!1,ignoreFolders:!0,extensions:!1,deep:!1,realPath:!0,normalizePath:!0,include:[],exclude:[]};return null!=options&&(null!=options.recursive&&(e.recursive=options.recursive),null!=options.mode&&(e.mode=options.mode),null!=options.stats&&(e.stats=options.stats),null!=options.ignoreFolders&&(e.ignoreFolders=options.ignoreFolders),null!=options.deep&&(e.deep=options.deep),null!=options.extensions&&(e.extensions=options.extensions),null!=options.realPath&&(e.realPath=options.realPath),null!=options.normalizePath&&(e.normalizePath=options.normalizePath),null!=options.include&&(e.include=options.include),null!=options.exclude&&(e.exclude=options.exclude)),pathSimbol=!1===e.normalizePath?PATH.sep:"/",await listDir(path,e,progress)}module.exports={LIST:LIST,TREE:TREE,
/**
* Returns a javascript object with directory items information (non blocking async with Promises)
* @param {string} path the path to start reading contents
* @param {object} options options (mode, recursive, stats, ignoreFolders)
* @param {function} progress callback with item data and progress info for each item
* @preserve
*/
list:list,stat:stat,fs:FS,path:PATH};

4

package.json
{
"name": "recursive-readdir-async",
"version": "1.1.0",
"version": "1.1.1",
"description": "Module to recursive read directory async (non blocking). Must be used with Promises. Configurable, extended filtering. etc.",

@@ -9,2 +9,3 @@ "main": "module.min.js",

"coverage": "nyc --reporter=lcov --reporter=text-lcov npm test",
"coveralls": "nyc npm test && nyc report --reporter=text-lcov | coveralls",
"build": "uglifyjs --compress --mangle reserved=[file,path,options,progress] --comments -- module.js > module.min.js"

@@ -41,2 +42,3 @@ },

"devDependencies": {
"coveralls": "^3.0.3",
"fs-extra": "^7.0.0",

@@ -43,0 +45,0 @@ "mocha": "^5.2.0",

@@ -0,1 +1,4 @@

[![Build Status](https://travis-ci.org/m0rtadelo/recursive-readdir-async.svg?branch=master)](https://travis-ci.org/m0rtadelo/recursive-readdir-async)
[![Coverage Status](https://coveralls.io/repos/github/m0rtadelo/recursive-readdir-async/badge.svg?branch=master)](https://coveralls.io/github/m0rtadelo/recursive-readdir-async?branch=master)
# recursive-readdir-async

@@ -2,0 +5,0 @@ NPM Module to recursive read directory async (non blocking). Returns Promise. Configurable, with callback for extended filtering and progress status. Quiet, NO dependencies.

Sorry, the diff of this file is not supported yet