Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rrdir

Package Overview
Dependencies
Maintainers
1
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rrdir - npm Package Compare versions

Comparing version 3.0.2 to 3.0.3

88

index.js

@@ -30,7 +30,6 @@ "use strict";

function handleOpts(dir, opts) {
if (!dir || !typeof dir === "string") {
throw new Error(`Expected a string, got '${dir}'`);
}
return Object.assign({}, defaults, opts);
function build(dirent, path, stats) {
const entry = {path, directory: dirent.isDirectory(), symlink: dirent.isSymbolicLink()};
if (stats) entry.stats = stats;
return entry;
}

@@ -40,5 +39,4 @@

if (isExcluded(dir, opts)) return [];
opts = handleOpts(dir, opts);
let results = [];
opts = Object.assign({}, defaults, opts);
const results = [];
let entries = [];

@@ -55,7 +53,4 @@

}
if (!entries.length) return results;
if (!entries.length) {
return entries;
}
for (const entry of entries) {

@@ -66,5 +61,3 @@ const path = join(dir, entry.name);

let stats;
if (!opts.stats) {
stats = entry;
} else {
if (opts.stats) {
try {

@@ -81,13 +74,4 @@ stats = await (opts.followSymlinks ? stat(path) : lstat(path));

if (stats) {
const directory = stats.isDirectory();
const symlink = stats.isSymbolicLink();
const entry = {path, directory, symlink};
if (opts.stats) entry.stats = stats;
results.push(entry);
if (directory) {
results = results.concat(await rrdir(path, opts));
}
}
results.push(build(entry, path, stats));
if (entry.isDirectory()) results.push(...await rrdir(path, opts));
}

@@ -100,5 +84,4 @@

if (isExcluded(dir, opts)) return [];
opts = handleOpts(dir, opts);
let results = [];
opts = Object.assign({}, defaults, opts);
const results = [];
let entries = [];

@@ -115,7 +98,4 @@

}
if (!entries.length) return results;
if (!entries.length) {
return entries;
}
for (const entry of entries) {

@@ -126,5 +106,3 @@ const path = join(dir, entry.name);

let stats;
if (!opts.stats) {
stats = entry;
} else {
if (opts.stats) {
try {

@@ -141,13 +119,4 @@ stats = opts.followSymlinks ? fs.statSync(path) : fs.lstatSync(path);

if (stats) {
const directory = stats.isDirectory();
const symlink = stats.isSymbolicLink();
const entry = {path, directory, symlink};
if (opts.stats) entry.stats = stats;
results.push(entry);
if (directory) {
results = results.concat(rrdir.sync(path, opts));
}
}
results.push(build(entry, path, stats));
if (entry.isDirectory()) results.push(...rrdir.sync(path, opts));
}

@@ -160,4 +129,3 @@

if (isExcluded(dir, opts)) return;
opts = handleOpts(dir, opts);
opts = Object.assign({}, defaults, opts);
let entries = [];

@@ -174,7 +142,4 @@

}
if (!entries.length) return;
if (!entries.length) {
return;
}
for (const entry of entries) {

@@ -185,5 +150,3 @@ const path = join(dir, entry.name);

let stats;
if (!opts.stats) {
stats = entry;
} else {
if (opts.stats) {
try {

@@ -200,14 +163,5 @@ stats = await (opts.followSymlinks ? stat(path) : lstat(path));

if (stats) {
const directory = stats.isDirectory();
const symlink = stats.isSymbolicLink();
const entry = {path, directory, symlink};
if (opts.stats) entry.stats = stats;
yield entry;
if (directory) {
yield * await rrdir.stream(path, opts);
}
}
yield build(entry, path, stats);
if (entry.isDirectory()) yield* await rrdir.stream(path, opts);
}
};
{
"name": "rrdir",
"version": "3.0.2",
"version": "3.0.3",
"description": "Recursive directory crawler with a delightful API",

@@ -17,2 +17,11 @@ "author": "silverwind <me@silverwind.io>",

],
"dependencies": {
"multimatch": "^4.0.0"
},
"devDependencies": {
"eslint": "^5.16.0",
"eslint-config-silverwind": "^2.1.3",
"updates": "^8.0.2",
"ver": "^4.2.0"
},
"keywords": [

@@ -24,15 +33,7 @@ "recursive readdir",

"walkdir",
"directory",
"crawl",
"directory",
"crawler",
"scandir"
],
"devDependencies": {
"eslint": "^5.16.0",
"eslint-config-silverwind": "^2.1.1",
"updates": "^8.0.2",
"ver": "^4.2.0"
},
"dependencies": {
"multimatch": "^4.0.0"
}
]
}

@@ -33,7 +33,7 @@ # rrdir

Recursively searches a directory for entries contained within. Will reject or throw on unexpected errors, but can optionally ignore errors encountered on individual files. `rrdir` and `rrdir.sync` return an array of `entry`, `rrdir.stream` is a async iterator which yields `entry`.
Recursively crawls a directory for entries contained within. By default, errors while reading files will be ignored and put in `entry.err`. The functions can throw on other unexpected conditions. `rrdir` and `rrdir.sync` return an array of `entry`, `rrdir.stream` is a async iterator which yields `entry`.
#### `options`
- `options.stats` *boolean*: Include `entry.stats`. Will reduce performance. Default: `false`.
- `options.stats` *boolean*: Whether to include `entry.stats`. Will reduce performance. Default: `false`.
- `options.followSymlinks` *boolean*: Whether to follow symlinks when `options.stats` is enabled. Default: `true`.

@@ -47,3 +47,3 @@ - `options.exclude` *Array*: Path globs to exclude from the result. Default: `[]`.

- `entry.path` *string*: The path to the entry, will be relative if `dir` is given relative.
- `entry.path` *string*: The path to the entry, will be relative if `dir` is given relative. Always present.
- `entry.directory` *boolean*: Boolean indicating whether the entry is a directory. `undefined` on error.

@@ -50,0 +50,0 @@ - `entry.symlink` *boolean*: Boolean indicating whether the entry is a symbolic link. `undefined` on error.

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc