@humanwhocodes/config-array
Advanced tools
Comparing version 0.10.5 to 0.10.6
32
api.js
@@ -106,2 +106,4 @@ 'use strict'; | ||
const Minimatch = minimatch.Minimatch; | ||
const minimatchCache = new Map(); | ||
const debug = createDebug('@hwc/config-array'); | ||
@@ -126,2 +128,22 @@ | ||
/** | ||
* Wrapper around minimatch that caches minimatch patterns for | ||
* faster matching speed over multiple file path evaluations. | ||
* @param {string} filepath The file path to match. | ||
* @param {string} pattern The glob pattern to match against. | ||
* @param {object} options The minimatch options to use. | ||
* @returns | ||
*/ | ||
function doMatch(filepath, pattern, options) { | ||
let matcher = minimatchCache.get(pattern); | ||
if (!matcher) { | ||
matcher = new Minimatch(pattern, options); | ||
minimatchCache.set(pattern, matcher); | ||
} | ||
return matcher.match(filepath); | ||
} | ||
/** | ||
* Normalizes a `ConfigArray` by flattening it and executing any functions | ||
@@ -268,3 +290,3 @@ * that are found inside. | ||
if (shouldIgnore && | ||
minimatch(relativeFilePath, matcher, { | ||
doMatch(relativeFilePath, matcher, { | ||
...MINIMATCH_OPTIONS, | ||
@@ -276,3 +298,3 @@ flipNegate: true | ||
} else { | ||
shouldIgnore = shouldIgnore || minimatch(relativeFilePath, matcher, MINIMATCH_OPTIONS); | ||
shouldIgnore = shouldIgnore || doMatch(relativeFilePath, matcher, MINIMATCH_OPTIONS); | ||
} | ||
@@ -313,3 +335,3 @@ | ||
if (isString(pattern)) { | ||
return minimatch(relativeFilePath, pattern, MINIMATCH_OPTIONS); | ||
return doMatch(relativeFilePath, pattern, MINIMATCH_OPTIONS); | ||
} | ||
@@ -460,3 +482,5 @@ | ||
// init cache | ||
dataCache.set(this, { explicitMatches: new Map() }); | ||
dataCache.set(this, { | ||
explicitMatches: new Map() | ||
}); | ||
@@ -463,0 +487,0 @@ // load the configs into this array |
# Changelog | ||
## [0.10.6](https://github.com/humanwhocodes/config-array/compare/v0.10.5...v0.10.6) (2022-09-28) | ||
### Performance Improvements | ||
* Cache Minimatch instances ([5cf9af7](https://github.com/humanwhocodes/config-array/commit/5cf9af7ecaf227d2106be0cebd92d7f5148867e6)) | ||
## [0.10.5](https://github.com/humanwhocodes/config-array/compare/v0.10.4...v0.10.5) (2022-09-21) | ||
@@ -4,0 +11,0 @@ |
{ | ||
"name": "@humanwhocodes/config-array", | ||
"version": "0.10.5", | ||
"version": "0.10.6", | ||
"description": "Glob-based configuration matching.", | ||
@@ -52,3 +52,3 @@ "author": "Nicholas C. Zakas", | ||
"chai": "4.2.0", | ||
"eslint": "8.23.1", | ||
"eslint": "8.24.0", | ||
"esm": "3.2.25", | ||
@@ -55,0 +55,0 @@ "lint-staged": "13.0.3", |
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
51722
651