Socket
Socket
Sign inDemoInstall

anymatch

Package Overview
Dependencies
2
Maintainers
5
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.0 to 3.0.1

18

index.d.ts

@@ -5,7 +5,15 @@ // type

type AnymatchFn = (string) => boolean;
type AnymatchFn = (testString: string) => boolean;
type AnymatchPattern = string|RegExp|AnymatchFn;
type AnymatchMatcher = AnymatchPattern|Array<AnymatchPattern>
declare function anymatch(matchers: AnymatchMatcher, testString: string|Array, returnIndex?: boolean): boolean;
declare function anymatch(matchers: AnymatchMatcher): (testString: string|Array, returnIndex?: boolean) => number;
export = anymatch;
type AnymatchMatcher = AnymatchPattern|AnymatchPattern[]
type AnymatchTester = {
(testString: string|any[], returnIndex: true): number;
(testString: string|any[]): boolean;
}
declare const anymatch: {
(matchers: AnymatchMatcher): AnymatchTester;
(matchers: AnymatchMatcher, testString: string|any[], returnIndex: true): number;
(matchers: AnymatchMatcher, testString: string|any[]): boolean;
}
export = anymatch

@@ -7,9 +7,6 @@ 'use strict';

/**
* @typedef {(...args) => boolean} BooleanFn
* @typedef {(string) => boolean} StrBoolFn
* @typedef {BooleanFn|StrBoolFn} AnymatchFn
* @typedef {(testString: string) => boolean} AnymatchFn
* @typedef {string|RegExp|AnymatchFn} AnymatchPattern
* @typedef {AnymatchPattern|Array<AnymatchPattern>} AnymatchMatcher
* @typedef {AnymatchPattern|AnymatchPattern[]} AnymatchMatcher
*/
const BANG = '!';

@@ -41,2 +38,3 @@ const arrify = (item) => Array.isArray(item) ? item : [item];

* @param {Boolean} returnIndex
* @returns {boolean|number}
*/

@@ -46,20 +44,13 @@ const matchPatterns = (patterns, negatedGlobs, path, returnIndex) => {

const upath = normalizePath(additionalArgs ? path[0] : path);
if (negatedGlobs.length > 0) {
for (let index = 0; index < negatedGlobs.length; index++) {
const nglob = negatedGlobs[index];
if (nglob(upath)) {
return returnIndex ? -1 : false;
}
for (let index = 0; index < negatedGlobs.length; index++) {
const nglob = negatedGlobs[index];
if (nglob(upath)) {
return returnIndex ? -1 : false;
}
}
const args = additionalArgs && [upath].concat(path.slice(1));
for (let index = 0; index < patterns.length; index++) {
const pattern = patterns[index];
if (additionalArgs) {
if (pattern(...path)) {
return returnIndex ? index : true;
}
} else {
if (pattern(upath)) {
return returnIndex ? index : true;
}
if (additionalArgs ? pattern(...args) : pattern(upath)) {
return returnIndex ? index : true;
}

@@ -74,3 +65,3 @@ }

* @param {Array|string} testString
* @param {Boolean=} returnIndex
* @param {boolean=} returnIndex
* @returns {boolean|number|Function}

@@ -77,0 +68,0 @@ */

{
"name": "anymatch",
"version": "3.0.0",
"version": "3.0.1",
"description": "Matches strings against configurable strings, globs, regular expressions, and/or functions",

@@ -42,8 +42,8 @@ "files": [

"normalize-path": "^3.0.0",
"picomatch": "^2.0.3"
"picomatch": "^2.0.4"
},
"devDependencies": {
"mocha": "^6.1.2",
"nyc": "^13.3.0"
"mocha": "^6.1.3",
"nyc": "^14.0.0"
}
}
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc