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 10.1.2 to 10.1.3

27

index.js

@@ -16,4 +16,2 @@ import {readdir, stat, lstat} from "node:fs/promises";

const escRe = str => str.replace(/[|\\{}()[\]^$+*?.-]/g, "\\$&");
function makePath(entry, dir, encoding) {

@@ -36,12 +34,21 @@ if (encoding === "buffer") {

export function pathGlobToRegex(glob, {flags = undefined, sep = "/"} = {flags: undefined, sep: "/"}) {
if (sep === "\\") sep = "\\\\";
return new RegExp(`${glob
.replace(/[|\\{}()[\]^$+.-]/g, "\\$&")
.replace(new RegExp(`\\*\\*${sep}\\*`, "g"), ".*")
.replace(/^\*\*/g, ".*")
.replace(new RegExp(`${sep}?\\*\\*$`, "g"), ".*")
.replace(new RegExp(`(${sep})\\*\\*(${sep})`, "g"), (_, p1, p2) => `${p1}.*${p2}`)
.replace(/([^.])\*/g, (_, p1) => `${p1}[^${sep}]*`)
.replaceAll("**", "*")
.replaceAll("?", ".")
}$`, flags);
}
function makeMatcher(filters, flags) {
const res = filters.map(f => {
return new RegExp(`${escRe(f)
.replace(/\\\*+/g, ".*")
.replace(/\/\.\*/, ".*")
.replace(/(\.\*){2,}/, ".*")}$`, flags);
});
const regexes = filters.map(filter => pathGlobToRegex(filter, {flags, sep}));
return str => {
for (const re of res) {
if (re.test(str)) return true;
for (const regex of regexes) {
if (regex.test(str)) return true;
}

@@ -48,0 +55,0 @@ return false;

{
"name": "rrdir",
"version": "10.1.2",
"version": "10.1.3",
"description": "Recursive directory reader 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