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.1 to 3.0.2

55

index.js

@@ -25,9 +25,18 @@ "use strict";

const rrdir = module.exports = async (dir, opts) => {
opts = Object.assign({}, defaults, opts);
function isExcluded(dir, opts) {
if (!dir || !opts || !opts.exclude || !opts.exclude.length) return false;
return opts.exclude.length && !!multimatch(dir, opts.exclude, opts.minimatch).length;
}
function handleOpts(dir, opts) {
if (!dir || !typeof dir === "string") {
throw new Error(`Expected a string, got '${dir}'`);
}
return Object.assign({}, defaults, opts);
}
const rrdir = module.exports = async (dir, opts) => {
if (isExcluded(dir, opts)) return [];
opts = handleOpts(dir, opts);
let results = [];

@@ -37,6 +46,3 @@ let entries = [];

try {
const exclude = (opts.exclude.length) && !!(multimatch(dir, opts.exclude, opts.minimatch).length);
if (!exclude) {
entries = await readdir(dir, {encoding: opts.encoding, withFileTypes: true});
}
entries = await readdir(dir, {encoding: opts.encoding, withFileTypes: true});
} catch (err) {

@@ -56,7 +62,4 @@ if (opts.strict) {

const path = join(dir, entry.name);
if (isExcluded(path, opts)) continue;
if (opts.exclude.length && !!(multimatch(path, opts.exclude, opts.minimatch).length)) {
continue;
}
let stats;

@@ -94,3 +97,4 @@ if (!opts.stats) {

module.exports.sync = (dir, opts) => {
opts = Object.assign({}, defaults, opts);
if (isExcluded(dir, opts)) return [];
opts = handleOpts(dir, opts);

@@ -101,6 +105,3 @@ let results = [];

try {
const exclude = (opts.exclude.length) && !!(multimatch(dir, opts.exclude, opts.minimatch).length);
if (!exclude) {
entries = fs.readdirSync(dir, {encoding: opts.encoding, withFileTypes: true});
}
entries = fs.readdirSync(dir, {encoding: opts.encoding, withFileTypes: true});
} catch (err) {

@@ -120,7 +121,4 @@ if (opts.strict) {

const path = join(dir, entry.name);
if (isExcluded(path, opts)) continue;
if (opts.exclude.length && !!(multimatch(path, opts.exclude, opts.minimatch).length)) {
continue;
}
let stats;

@@ -158,15 +156,9 @@ if (!opts.stats) {

module.exports.stream = async function* (dir, opts) {
opts = Object.assign({}, defaults, opts);
if (isExcluded(dir, opts)) return;
opts = handleOpts(dir, opts);
if (!dir || !typeof dir === "string") {
throw new Error(`Expected a string, got '${dir}'`);
}
let entries = [];
try {
const exclude = (opts.exclude.length) && !!(multimatch(dir, opts.exclude, opts.minimatch).length);
if (!exclude) {
entries = await readdir(dir, {encoding: opts.encoding, withFileTypes: true});
}
entries = await readdir(dir, {encoding: opts.encoding, withFileTypes: true});
} catch (err) {

@@ -186,7 +178,4 @@ if (opts.strict) {

const path = join(dir, entry.name);
if (isExcluded(path, opts)) continue;
if (opts.exclude.length && !!(multimatch(path, opts.exclude, opts.minimatch).length)) {
continue;
}
let stats;

@@ -215,3 +204,3 @@ if (!opts.stats) {

if (directory) {
yield * await rrdir(path, opts);
yield * await rrdir.stream(path, opts);
}

@@ -218,0 +207,0 @@ }

2

package.json
{
"name": "rrdir",
"version": "3.0.1",
"version": "3.0.2",
"description": "Recursive directory crawler with a delightful API",

@@ -5,0 +5,0 @@ "author": "silverwind <me@silverwind.io>",

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