multimatch
Advanced tools
Comparing version 4.0.0 to 5.0.0
@@ -12,3 +12,3 @@ import {IOptions} from 'minimatch'; | ||
@param patterns - Globbing patterns to use. For example: `['*', '!cake']`. See supported [`minimatch` patterns](https://github.com/isaacs/minimatch#usage). | ||
@returns The matching paths. | ||
@returns The matching paths in the order of input paths. | ||
@@ -24,4 +24,4 @@ @example | ||
declare function multimatch( | ||
paths: string | string[], | ||
patterns: string | string[], | ||
paths: string | readonly string[], | ||
patterns: string | readonly string[], | ||
options?: multimatch.Options | ||
@@ -28,0 +28,0 @@ ): string[]; |
19
index.js
@@ -15,12 +15,17 @@ 'use strict'; | ||
return patterns.reduce((result, pattern) => { | ||
let process = arrayUnion; | ||
let result = []; | ||
for (const item of list) { | ||
for (let pattern of patterns) { | ||
let process = arrayUnion; | ||
if (pattern[0] === '!') { | ||
pattern = pattern.slice(1); | ||
process = arrayDiffer; | ||
if (pattern[0] === '!') { | ||
pattern = pattern.slice(1); | ||
process = arrayDiffer; | ||
} | ||
result = process(result, minimatch.match([item], pattern, options)); | ||
} | ||
} | ||
return process(result, minimatch.match(list, pattern, options)); | ||
}, []); | ||
return result; | ||
}; |
{ | ||
"name": "multimatch", | ||
"version": "4.0.0", | ||
"version": "5.0.0", | ||
"description": "Extends `minimatch.match()` with support for multiple patterns", | ||
"license": "MIT", | ||
"repository": "sindresorhus/multimatch", | ||
"funding": "https://github.com/sponsors/sindresorhus", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
"url": "https://sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=8" | ||
"node": ">=10" | ||
}, | ||
@@ -43,6 +44,6 @@ "scripts": { | ||
"devDependencies": { | ||
"ava": "^1.4.1", | ||
"tsd": "^0.7.2", | ||
"xo": "^0.24.0" | ||
"ava": "^2.4.0", | ||
"tsd": "^0.13.1", | ||
"xo": "^0.33.1" | ||
} | ||
} |
@@ -1,6 +0,5 @@ | ||
# multimatch [![Build Status](https://travis-ci.org/sindresorhus/multimatch.svg?branch=master)](https://travis-ci.org/sindresorhus/multimatch) | ||
# multimatch [![Build Status](https://travis-ci.com/sindresorhus/multimatch.svg?branch=master)](https://travis-ci.com/github/sindresorhus/multimatch) | ||
> Extends [`minimatch.match()`](https://github.com/isaacs/minimatch#minimatchmatchlist-pattern-options) with support for multiple patterns | ||
## Install | ||
@@ -12,3 +11,2 @@ | ||
## Usage | ||
@@ -25,8 +23,7 @@ | ||
## API | ||
### multimatch(paths, patterns, [options] | ||
### multimatch(paths, patterns, options?) | ||
Returns an array of matching paths. | ||
Returns an array of matching paths in the order of input paths. | ||
@@ -54,3 +51,2 @@ #### paths | ||
## How multiple patterns work | ||
@@ -62,3 +58,2 @@ | ||
## Globbing patterns | ||
@@ -74,3 +69,2 @@ | ||
## Related | ||
@@ -81,5 +75,12 @@ | ||
--- | ||
## License | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) | ||
<div align="center"> | ||
<b> | ||
<a href="https://tidelift.com/subscription/pkg/npm-multimatch?utm_source=npm-multimatch&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> |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6030
46
81