Socket
Socket
Sign inDemoInstall

minimatch

Package Overview
Dependencies
Maintainers
1
Versions
110
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

minimatch - npm Package Compare versions

Comparing version 6.1.6 to 6.1.7

15

dist/cjs/index-cjs.d.ts

@@ -8,6 +8,3 @@ declare const _default: {

braceExpand: (pattern: string, options?: import("./index.js").MinimatchOptions) => string[];
makeRe: (pattern: string, options?: import("./index.js").MinimatchOptions) => false | (RegExp & {
_src?: string | undefined;
_glob?: string | undefined;
});
makeRe: (pattern: string, options?: import("./index.js").MinimatchOptions) => false | import("./index.js").MMRegExp;
match: (list: string[], pattern: string, options?: import("./index.js").MinimatchOptions) => string[];

@@ -23,6 +20,3 @@ Minimatch: typeof import("./index.js").Minimatch;

braceExpand: (pattern: string, options?: import("./index.js").MinimatchOptions) => string[];
makeRe: (pattern: string, options?: import("./index.js").MinimatchOptions) => false | (RegExp & {
_src?: string | undefined;
_glob?: string | undefined;
});
makeRe: (pattern: string, options?: import("./index.js").MinimatchOptions) => false | import("./index.js").MMRegExp;
match: (list: string[], pattern: string, options?: import("./index.js").MinimatchOptions) => string[];

@@ -38,6 +32,3 @@ Minimatch: typeof import("./index.js").Minimatch;

braceExpand: (pattern: string, options?: import("./index.js").MinimatchOptions) => string[];
makeRe: (pattern: string, options?: import("./index.js").MinimatchOptions) => false | (RegExp & {
_src?: string | undefined;
_glob?: string | undefined;
});
makeRe: (pattern: string, options?: import("./index.js").MinimatchOptions) => false | import("./index.js").MMRegExp;
match: (list: string[], pattern: string, options?: import("./index.js").MinimatchOptions) => string[];

@@ -44,0 +35,0 @@ Minimatch: typeof import("./index.js").Minimatch;

2

dist/cjs/index.d.ts

@@ -38,3 +38,3 @@ export interface MinimatchOptions {

export declare const match: (list: string[], pattern: string, options?: MinimatchOptions) => string[];
type MMRegExp = RegExp & {
export type MMRegExp = RegExp & {
_src?: string;

@@ -41,0 +41,0 @@ _glob?: string;

@@ -17,2 +17,22 @@ "use strict";

exports.default = exports.minimatch;
// Optimized checking for the most common glob patterns.
const starDotExtRE = /^\*+(\.[^!?\*\[\(]*)$/;
const starDotExtTest = (ext) => (f) => !f.startsWith('.') && f.endsWith(ext);
const starDotExtTestDot = (ext) => (f) => f.endsWith(ext);
const starDotExtTestNocase = (ext) => {
ext = ext.toLowerCase();
return (f) => !f.startsWith('.') && f.toLowerCase().endsWith(ext);
};
const starDotExtTestNocaseDot = (ext) => {
ext = ext.toLowerCase();
return (f) => f.toLowerCase().endsWith(ext);
};
const starDotStarRE = /^\*+\.\*+$/;
const starDotStarTest = (f) => !f.startsWith('.') && f.includes('.');
const starDotStarTestDot = (f) => f !== '.' && f !== '..' && f.includes('.');
const dotStarRE = /^\.\*+$/;
const dotStarTest = (f) => f !== '.' && f !== '..' && f.startsWith('.');
const starRE = /^\*+$/;
const starTest = (f) => f.length !== 0 && !f.startsWith('.');
const starTestDot = (f) => f.length !== 0 && f !== '.' && f !== '..';
/* c8 ignore start */

@@ -217,5 +237,30 @@ const platform = typeof process === 'object' && process

// consecutive globstars are an unncessary perf killer
this.globParts = this.options.noglobstar
? rawGlobParts
: rawGlobParts.map(parts => parts.reduce((set, part) => {
// also, **/*/... is equivalent to */**/..., so swap all of those
// this turns a pattern like **/*/**/*/x into */*/**/x
// and a pattern like **/x/**/*/y becomes **/x/*/**/y
// the *later* we can push the **, the more efficient it is,
// because we can avoid having to do a recursive walk until
// the walked tree is as shallow as possible.
// Note that this is only true up to the last pattern, though, because
// a/*/** will only match a/b if b is a dir, but a/**/* will match a/b
// regardless, since it's "0 or more path segments" if it's not final.
if (this.options.noglobstar) {
// ** is * anyway
this.globParts = rawGlobParts;
}
else {
for (const parts of rawGlobParts) {
let swapped;
do {
swapped = false;
for (let i = 0; i < parts.length - 1; i++) {
if (parts[i] === '*' && parts[i - 1] === '**') {
parts[i] = '**';
parts[i - 1] = '*';
swapped = true;
}
}
} while (swapped);
}
this.globParts = rawGlobParts.map(parts => parts.reduce((set, part) => {
if (part !== '**' || set[set.length - 1] !== '**') {

@@ -226,2 +271,3 @@ set.push(part);

}, []));
}
this.debug(this.pattern, this.globParts);

@@ -464,2 +510,26 @@ // glob --> regexps

return '';
// far and away, the most common glob pattern parts are
// *, *.*, and *.<ext> Add a fast check method for those.
let m;
let fastTest = null;
if (isSub !== SUBPARSE) {
if ((m = pattern.match(starRE))) {
fastTest = options.dot ? starTestDot : starTest;
}
else if ((m = pattern.match(starDotExtRE))) {
fastTest = (options.nocase
? options.dot
? starDotExtTestNocaseDot
: starDotExtTestNocase
: options.dot
? starDotExtTestDot
: starDotExtTest)(m[1]);
}
else if ((m = pattern.match(starDotStarRE))) {
fastTest = options.dot ? starDotStarTestDot : starDotStarTest;
}
else if ((m = pattern.match(dotStarRE))) {
fastTest = dotStarTest;
}
}
let re = '';

@@ -794,6 +864,13 @@ let hasMagic = false;

try {
return Object.assign(new RegExp('^' + re + '$', flags), {
_glob: pattern,
_src: re,
});
const ext = fastTest
? {
_glob: pattern,
_src: re,
test: fastTest,
}
: {
_glob: pattern,
_src: re,
};
return Object.assign(new RegExp('^' + re + '$', flags), ext);
/* c8 ignore start */

@@ -800,0 +877,0 @@ }

@@ -38,3 +38,3 @@ export interface MinimatchOptions {

export declare const match: (list: string[], pattern: string, options?: MinimatchOptions) => string[];
type MMRegExp = RegExp & {
export type MMRegExp = RegExp & {
_src?: string;

@@ -41,0 +41,0 @@ _glob?: string;

@@ -10,2 +10,22 @@ export const minimatch = (p, pattern, options = {}) => {

export default minimatch;
// Optimized checking for the most common glob patterns.
const starDotExtRE = /^\*+(\.[^!?\*\[\(]*)$/;
const starDotExtTest = (ext) => (f) => !f.startsWith('.') && f.endsWith(ext);
const starDotExtTestDot = (ext) => (f) => f.endsWith(ext);
const starDotExtTestNocase = (ext) => {
ext = ext.toLowerCase();
return (f) => !f.startsWith('.') && f.toLowerCase().endsWith(ext);
};
const starDotExtTestNocaseDot = (ext) => {
ext = ext.toLowerCase();
return (f) => f.toLowerCase().endsWith(ext);
};
const starDotStarRE = /^\*+\.\*+$/;
const starDotStarTest = (f) => !f.startsWith('.') && f.includes('.');
const starDotStarTestDot = (f) => f !== '.' && f !== '..' && f.includes('.');
const dotStarRE = /^\.\*+$/;
const dotStarTest = (f) => f !== '.' && f !== '..' && f.startsWith('.');
const starRE = /^\*+$/;
const starTest = (f) => f.length !== 0 && !f.startsWith('.');
const starTestDot = (f) => f.length !== 0 && f !== '.' && f !== '..';
/* c8 ignore start */

@@ -205,5 +225,30 @@ const platform = typeof process === 'object' && process

// consecutive globstars are an unncessary perf killer
this.globParts = this.options.noglobstar
? rawGlobParts
: rawGlobParts.map(parts => parts.reduce((set, part) => {
// also, **/*/... is equivalent to */**/..., so swap all of those
// this turns a pattern like **/*/**/*/x into */*/**/x
// and a pattern like **/x/**/*/y becomes **/x/*/**/y
// the *later* we can push the **, the more efficient it is,
// because we can avoid having to do a recursive walk until
// the walked tree is as shallow as possible.
// Note that this is only true up to the last pattern, though, because
// a/*/** will only match a/b if b is a dir, but a/**/* will match a/b
// regardless, since it's "0 or more path segments" if it's not final.
if (this.options.noglobstar) {
// ** is * anyway
this.globParts = rawGlobParts;
}
else {
for (const parts of rawGlobParts) {
let swapped;
do {
swapped = false;
for (let i = 0; i < parts.length - 1; i++) {
if (parts[i] === '*' && parts[i - 1] === '**') {
parts[i] = '**';
parts[i - 1] = '*';
swapped = true;
}
}
} while (swapped);
}
this.globParts = rawGlobParts.map(parts => parts.reduce((set, part) => {
if (part !== '**' || set[set.length - 1] !== '**') {

@@ -214,2 +259,3 @@ set.push(part);

}, []));
}
this.debug(this.pattern, this.globParts);

@@ -452,2 +498,26 @@ // glob --> regexps

return '';
// far and away, the most common glob pattern parts are
// *, *.*, and *.<ext> Add a fast check method for those.
let m;
let fastTest = null;
if (isSub !== SUBPARSE) {
if ((m = pattern.match(starRE))) {
fastTest = options.dot ? starTestDot : starTest;
}
else if ((m = pattern.match(starDotExtRE))) {
fastTest = (options.nocase
? options.dot
? starDotExtTestNocaseDot
: starDotExtTestNocase
: options.dot
? starDotExtTestDot
: starDotExtTest)(m[1]);
}
else if ((m = pattern.match(starDotStarRE))) {
fastTest = options.dot ? starDotStarTestDot : starDotStarTest;
}
else if ((m = pattern.match(dotStarRE))) {
fastTest = dotStarTest;
}
}
let re = '';

@@ -782,6 +852,13 @@ let hasMagic = false;

try {
return Object.assign(new RegExp('^' + re + '$', flags), {
_glob: pattern,
_src: re,
});
const ext = fastTest
? {
_glob: pattern,
_src: re,
test: fastTest,
}
: {
_glob: pattern,
_src: re,
};
return Object.assign(new RegExp('^' + re + '$', flags), ext);
/* c8 ignore start */

@@ -788,0 +865,0 @@ }

@@ -5,3 +5,3 @@ {

"description": "a glob matcher in javascript",
"version": "6.1.6",
"version": "6.1.7",
"repository": {

@@ -8,0 +8,0 @@ "type": "git",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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