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

@pnpm/matcher

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pnpm/matcher - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

4

lib/index.d.ts

@@ -1,1 +0,3 @@

export default function matcher(patterns: string[] | string): (input: string) => boolean;
declare type Matcher = (input: string) => boolean;
export default function matcher(patterns: string[] | string): Matcher;
export {};

@@ -9,9 +9,33 @@ "use strict";

if (typeof patterns === 'string')
return matcherFromPattern(patterns);
return matcherWhenOnlyOnePattern(patterns);
switch (patterns.length) {
case 0: return () => false;
case 1: return matcherFromPattern(patterns[0]);
case 1: return matcherWhenOnlyOnePattern(patterns[0]);
}
const matchArr = patterns.map(matcherFromPattern);
return (input) => matchArr.some((match) => match(input));
const matchArr = [];
let hasIgnore = false;
for (const pattern of patterns) {
if (isIgnorePattern(pattern)) {
hasIgnore = true;
matchArr.push({ ignore: true, match: matcherFromPattern(pattern.substring(1)) });
}
else {
matchArr.push({ ignore: false, match: matcherFromPattern(pattern) });
}
}
if (!hasIgnore) {
return (input) => matchArr.some(({ match }) => match(input));
}
return (input) => {
let isMatched = false;
for (const { ignore, match } of matchArr) {
if (ignore) {
isMatched = !match(input);
}
else if (!isMatched && match(input)) {
isMatched = true;
}
}
return isMatched;
};
}

@@ -30,2 +54,10 @@ exports.default = matcher;

}
function isIgnorePattern(pattern) {
return pattern.startsWith('!');
}
function matcherWhenOnlyOnePattern(pattern) {
return isIgnorePattern(pattern)
? () => false
: matcherFromPattern(pattern);
}
//# sourceMappingURL=index.js.map
{
"name": "@pnpm/matcher",
"version": "3.0.0",
"version": "3.1.0",
"description": "A simple pattern matcher for pnpm",

@@ -8,3 +8,3 @@ "main": "lib/index.js",

"engines": {
"node": ">=14.19"
"node": ">=14.6"
},

@@ -33,3 +33,3 @@ "files": [

"devDependencies": {
"@pnpm/matcher": "3.0.0"
"@pnpm/matcher": "3.1.0"
},

@@ -36,0 +36,0 @@ "exports": {

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