Socket
Socket
Sign inDemoInstall

matcher

Package Overview
Dependencies
1
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.1.0

17

index.d.ts

@@ -36,5 +36,5 @@ declare namespace matcher {

/**
@param input - String to match.
@param pattern - Use `*` to match zero or more characters. A pattern starting with `!` will be negated.
@returns Whether the `input` matches the `pattern`.
@param input - String or array of strings to match.
@param pattern - String or array of string patterns. Use `*` to match zero or more characters. A pattern starting with `!` will be negated.
@returns Whether any given `input` matches every given `pattern`.

@@ -68,7 +68,16 @@ @example

//=> false
matcher.isMatch(['foo', 'bar'], 'f*');
//=> true
matcher.isMatch(['foo', 'bar'], ['a*', 'b*']);
//=> true
matcher.isMatch('unicorn', ['tri*', 'UNI*'], {caseSensitive: true});
//=> false
```
*/
isMatch(input: string, pattern: string, options?: matcher.Options): boolean;
isMatch(input: string | readonly string[], pattern: string | readonly string[], options?: matcher.Options): boolean;
};
export = matcher;

@@ -67,5 +67,12 @@ 'use strict';

module.exports.isMatch = (input, pattern, options) => {
const regexp = makeRegexp(pattern, options);
const matches = regexp.test(input);
return regexp.negated ? !matches : matches;
const inputArray = Array.isArray(input) ? input : [input];
const patternArray = Array.isArray(pattern) ? pattern : [pattern];
return inputArray.some(input => {
return patternArray.every(pattern => {
const regexp = makeRegexp(pattern, options);
const matches = regexp.test(input);
return regexp.negated ? !matches : matches;
});
});
};
{
"name": "matcher",
"version": "2.0.0",
"version": "2.1.0",
"description": "Simple wildcard matching",

@@ -44,7 +44,7 @@ "license": "MIT",

"devDependencies": {
"ava": "^1.4.1",
"ava": "^2.4.0",
"matcha": "^0.7.0",
"tsd": "^0.7.2",
"xo": "^0.24.0"
"tsd": "^0.11.0",
"xo": "^0.25.3"
}
}

@@ -7,3 +7,2 @@ # matcher [![Build Status](https://travis-ci.org/sindresorhus/matcher.svg?branch=master)](https://travis-ci.org/sindresorhus/matcher)

## Install

@@ -15,3 +14,2 @@

## Usage

@@ -51,8 +49,16 @@

//=> false
matcher.isMatch(['foo', 'bar'], 'f*');
//=> true
matcher.isMatch(['foo', 'bar'], ['a*', 'b*']);
//=> true
matcher.isMatch('unicorn', ['tri*', 'UNI*'], {caseSensitive: true});
//=> false
```
## API
### matcher(inputs, patterns, [options])
### matcher(inputs, patterns, options?)

@@ -63,11 +69,13 @@ Accepts an array of `input`'s and `pattern`'s.

### matcher.isMatch(input, pattern, [options])
### matcher.isMatch(input, pattern, options?)
Returns a `boolean` of whether the `input` matches the `pattern`.
Accepts either a string or array of strings for both `input` and `pattern`.
Returns a `boolean` of whether any given `input` matches every given `pattern`.
#### input
Type: `string`
Type: `string | string[]`
String to match.
String or array of strings to match.

@@ -80,3 +88,3 @@ #### options

Type: `boolean`<br>
Type: `boolean`\
Default: `false`

@@ -90,7 +98,6 @@

Type: `string`
Type: `string | string[]`
Use `*` to match zero or more characters. A pattern starting with `!` will be negated.
## Benchmark

@@ -102,3 +109,2 @@

## Related

@@ -109,5 +115,12 @@

---
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)
<div align="center">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-matcher?utm_source=npm-matcher&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>
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