array-includes-with-glob 3.0.16 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,28 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 4.0.1 (2021-09-13)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- bump TS and separate ESLint plugins away from this monorepo ([2e07d42](https://github.com/codsen/codsen/commit/2e07d424222b6ffedf5fb45c83ad453627ec2904))
|
|
11
|
+
|
|
12
|
+
## 4.0.0 (2021-09-09)
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
- migrate to ES Modules ([8c9d95d](https://github.com/codsen/codsen/commit/8c9d95d5dea0b769c2f070397141918a4893d575))
|
|
17
|
+
|
|
18
|
+
### BREAKING CHANGES
|
|
19
|
+
|
|
20
|
+
- programs now are in ES Modules and won't work with Common JS require()
|
|
21
|
+
|
|
22
|
+
## 3.1.0 (2021-05-24)
|
|
23
|
+
|
|
24
|
+
### Features
|
|
25
|
+
|
|
26
|
+
- config file based major bump blacklisting ([e15f9bb](https://github.com/codsen/codsen/commit/e15f9bba1c4fd5f847ac28b3f38fa6ee633f5dca))
|
|
27
|
+
|
|
6
28
|
## 3.0.15 (2021-04-11)
|
|
7
29
|
|
|
8
30
|
### Reverts
|
package/README.md
CHANGED
|
@@ -26,10 +26,14 @@
|
|
|
26
26
|
|
|
27
27
|
## Install
|
|
28
28
|
|
|
29
|
+
This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required:
|
|
30
|
+
|
|
29
31
|
```bash
|
|
30
32
|
npm i array-includes-with-glob
|
|
31
33
|
```
|
|
32
34
|
|
|
35
|
+
If you need a legacy version which works with `require`, use version 3.1.0
|
|
36
|
+
|
|
33
37
|
## Quick Take
|
|
34
38
|
|
|
35
39
|
```js
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name array-includes-with-glob
|
|
3
3
|
* @fileoverview Like _.includes but with wildcards
|
|
4
|
-
* @version
|
|
4
|
+
* @version 4.0.2
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/array-includes-with-glob/}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import matcher from 'matcher';
|
|
11
11
|
|
|
12
|
-
var version$1 = "
|
|
12
|
+
var version$1 = "4.0.2";
|
|
13
13
|
|
|
14
14
|
const version = version$1;
|
|
15
15
|
const defaults = {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name array-includes-with-glob
|
|
3
3
|
* @fileoverview Like _.includes but with wildcards
|
|
4
|
-
* @version
|
|
4
|
+
* @version 4.0.2
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/array-includes-with-glob/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).arrayIncludesWithGlob={})}(this,(function(e){"use strict";
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).arrayIncludesWithGlob={})}(this,(function(e){"use strict";var t={exports:{}};const r=e=>{if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")},n=new Map;function s(e,t){if(!Array.isArray(e))switch(typeof e){case"string":e=[e];break;case"undefined":e=[];break;default:throw new TypeError(`Expected '${t}' to be a string or an array, but got a type of '${typeof e}'`)}return e.filter((e=>{if("string"!=typeof e){if(void 0===e)return!1;throw new TypeError(`Expected '${t}' to be an array of strings, but found a type of '${typeof e}' in the array`)}return!0}))}function o(e,t){t={caseSensitive:!1,...t};const s=e+JSON.stringify(t);if(n.has(s))return n.get(s);const o="!"===e[0];o&&(e=e.slice(1)),e=r(e).replace(/\\\*/g,"[\\s\\S]*");const i=new RegExp(`^${e}$`,t.caseSensitive?"":"i");return i.negated=o,n.set(s,i),i}t.exports=(e,t,r)=>{if(e=s(e,"inputs"),0===(t=s(t,"patterns")).length)return[];const n="!"===t[0][0];t=t.map((e=>o(e,r)));const i=[];for(const r of e){let e=n;for(const n of t)n.test(r)&&(e=!n.negated);e&&i.push(r)}return i},t.exports.isMatch=(e,t,r)=>(e=s(e,"inputs"),0!==(t=s(t,"patterns")).length&&e.some((e=>t.every((t=>{const n=o(t,r),s=n.test(e);return n.negated?!s:s})))));var i=t.exports;const a={arrayVsArrayAllMustBeFound:"any",caseSensitive:!0};e.defaults=a,e.includesWithGlob=function(e,t,r){if(!e.length||!t.length)return!1;const n={...a,...r},s="string"==typeof e?[e]:Array.from(e);return"string"==typeof t?s.some((e=>i.isMatch(e,t,{caseSensitive:n.caseSensitive}))):"any"===n.arrayVsArrayAllMustBeFound?t.some((e=>s.some((t=>i.isMatch(t,e,{caseSensitive:n.caseSensitive}))))):t.every((e=>s.some((t=>i.isMatch(t,e,{caseSensitive:n.caseSensitive})))))},e.version="4.0.2",Object.defineProperty(e,"__esModule",{value:!0})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "array-includes-with-glob",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "Like _.includes but with wildcards",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"array",
|
|
@@ -30,9 +30,11 @@
|
|
|
30
30
|
"email": "roy@codsen.com",
|
|
31
31
|
"url": "https://codsen.com"
|
|
32
32
|
},
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
|
|
33
|
+
"type": "module",
|
|
34
|
+
"exports": {
|
|
35
|
+
"script": "./dist/array-includes-with-glob.umd.js",
|
|
36
|
+
"default": "./dist/array-includes-with-glob.esm.js"
|
|
37
|
+
},
|
|
36
38
|
"types": "types/index.d.ts",
|
|
37
39
|
"scripts": {
|
|
38
40
|
"build": "rollup -c",
|
|
@@ -52,18 +54,20 @@
|
|
|
52
54
|
"pretest": "npm run build",
|
|
53
55
|
"test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
|
|
54
56
|
"test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
|
|
55
|
-
"unittest": "
|
|
57
|
+
"unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf",
|
|
56
58
|
"clean_cov": "../../scripts/leaveCoverageTotalOnly.js",
|
|
57
59
|
"clean_types": "../../scripts/cleanTypes.js"
|
|
58
60
|
},
|
|
59
61
|
"tap": {
|
|
62
|
+
"check-coverage": false,
|
|
60
63
|
"coverage-report": [
|
|
61
64
|
"json-summary",
|
|
62
65
|
"text"
|
|
63
66
|
],
|
|
64
|
-
"
|
|
65
|
-
"--
|
|
66
|
-
"--
|
|
67
|
+
"node-arg": [
|
|
68
|
+
"--no-warnings",
|
|
69
|
+
"--experimental-loader",
|
|
70
|
+
"@istanbuljs/esm-loader-hook"
|
|
67
71
|
],
|
|
68
72
|
"timeout": 0
|
|
69
73
|
},
|
|
@@ -79,45 +83,48 @@
|
|
|
79
83
|
}
|
|
80
84
|
},
|
|
81
85
|
"dependencies": {
|
|
82
|
-
"@babel/runtime": "^7.
|
|
86
|
+
"@babel/runtime": "^7.15.4",
|
|
83
87
|
"matcher": "^4.0.0"
|
|
84
88
|
},
|
|
85
89
|
"devDependencies": {
|
|
86
|
-
"@babel/cli": "^7.
|
|
87
|
-
"@babel/core": "^7.
|
|
88
|
-
"@babel/node": "^7.
|
|
89
|
-
"@babel/plugin-external-helpers": "^7.
|
|
90
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
91
|
-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.
|
|
92
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.
|
|
93
|
-
"@babel/plugin-proposal-optional-chaining": "^7.
|
|
94
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
95
|
-
"@babel/preset-env": "^7.
|
|
96
|
-
"@babel/preset-typescript": "^7.
|
|
97
|
-
"@babel/register": "^7.
|
|
90
|
+
"@babel/cli": "^7.15.4",
|
|
91
|
+
"@babel/core": "^7.15.5",
|
|
92
|
+
"@babel/node": "^7.15.4",
|
|
93
|
+
"@babel/plugin-external-helpers": "^7.14.5",
|
|
94
|
+
"@babel/plugin-proposal-class-properties": "^7.14.5",
|
|
95
|
+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.5",
|
|
96
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.15.6",
|
|
97
|
+
"@babel/plugin-proposal-optional-chaining": "^7.14.5",
|
|
98
|
+
"@babel/plugin-transform-runtime": "^7.15.0",
|
|
99
|
+
"@babel/preset-env": "^7.15.6",
|
|
100
|
+
"@babel/preset-typescript": "^7.15.0",
|
|
101
|
+
"@babel/register": "^7.15.3",
|
|
102
|
+
"@istanbuljs/esm-loader-hook": "^0.1.2",
|
|
98
103
|
"@rollup/plugin-babel": "^5.3.0",
|
|
99
|
-
"@rollup/plugin-commonjs": "^
|
|
104
|
+
"@rollup/plugin-commonjs": "^20.0.0",
|
|
100
105
|
"@rollup/plugin-json": "^4.1.0",
|
|
101
|
-
"@rollup/plugin-node-resolve": "^
|
|
102
|
-
"@rollup/plugin-
|
|
103
|
-
"@rollup/plugin-
|
|
104
|
-
"@
|
|
105
|
-
"@types/
|
|
106
|
-
"@
|
|
107
|
-
"@typescript-eslint/
|
|
108
|
-
"
|
|
109
|
-
"core-js": "^3.10.0",
|
|
106
|
+
"@rollup/plugin-node-resolve": "^13.0.4",
|
|
107
|
+
"@rollup/plugin-strip": "^2.1.0",
|
|
108
|
+
"@rollup/plugin-typescript": "^8.2.5",
|
|
109
|
+
"@types/node": "^16.9.1",
|
|
110
|
+
"@types/tap": "^15.0.5",
|
|
111
|
+
"@typescript-eslint/eslint-plugin": "^4.31.0",
|
|
112
|
+
"@typescript-eslint/parser": "^4.31.0",
|
|
113
|
+
"core-js": "^3.17.3",
|
|
110
114
|
"cross-env": "^7.0.3",
|
|
111
|
-
"eslint": "^7.
|
|
112
|
-
"lect": "^0.
|
|
113
|
-
"rollup": "^2.
|
|
115
|
+
"eslint": "^7.32.0",
|
|
116
|
+
"lect": "^0.18.2",
|
|
117
|
+
"rollup": "^2.56.3",
|
|
114
118
|
"rollup-plugin-ascii": "^0.0.3",
|
|
115
119
|
"rollup-plugin-banner": "^0.2.1",
|
|
116
120
|
"rollup-plugin-cleanup": "^3.2.1",
|
|
117
|
-
"rollup-plugin-dts": "^
|
|
121
|
+
"rollup-plugin-dts": "^4.0.0",
|
|
118
122
|
"rollup-plugin-terser": "^7.0.2",
|
|
119
|
-
"tap": "^
|
|
120
|
-
"tslib": "^2.1
|
|
121
|
-
"typescript": "^4.
|
|
123
|
+
"tap": "^15.0.9",
|
|
124
|
+
"tslib": "^2.3.1",
|
|
125
|
+
"typescript": "^4.4.3"
|
|
126
|
+
},
|
|
127
|
+
"engines": {
|
|
128
|
+
"node": ">=12"
|
|
122
129
|
}
|
|
123
130
|
}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @name array-includes-with-glob
|
|
3
|
-
* @fileoverview Like _.includes but with wildcards
|
|
4
|
-
* @version 3.0.16
|
|
5
|
-
* @author Roy Revelt, Codsen Ltd
|
|
6
|
-
* @license MIT
|
|
7
|
-
* {@link https://codsen.com/os/array-includes-with-glob/}
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
13
|
-
|
|
14
|
-
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
15
|
-
var matcher = require('matcher');
|
|
16
|
-
|
|
17
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
18
|
-
|
|
19
|
-
var _objectSpread__default = /*#__PURE__*/_interopDefaultLegacy(_objectSpread);
|
|
20
|
-
var matcher__default = /*#__PURE__*/_interopDefaultLegacy(matcher);
|
|
21
|
-
|
|
22
|
-
var version$1 = "3.0.16";
|
|
23
|
-
|
|
24
|
-
var version = version$1;
|
|
25
|
-
var defaults = {
|
|
26
|
-
arrayVsArrayAllMustBeFound: "any",
|
|
27
|
-
caseSensitive: true
|
|
28
|
-
};
|
|
29
|
-
function includesWithGlob(originalInput, stringToFind, originalOpts) {
|
|
30
|
-
if (!originalInput.length || !stringToFind.length) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
var opts = _objectSpread__default['default'](_objectSpread__default['default']({}, defaults), originalOpts);
|
|
34
|
-
var input = typeof originalInput === "string" ? [originalInput] : Array.from(originalInput);
|
|
35
|
-
if (typeof stringToFind === "string") {
|
|
36
|
-
return input.some(function (val) {
|
|
37
|
-
return matcher__default['default'].isMatch(val, stringToFind, {
|
|
38
|
-
caseSensitive: opts.caseSensitive
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
if (opts.arrayVsArrayAllMustBeFound === "any") {
|
|
43
|
-
return stringToFind.some(function (stringToFindVal) {
|
|
44
|
-
return input.some(function (val) {
|
|
45
|
-
return matcher__default['default'].isMatch(val, stringToFindVal, {
|
|
46
|
-
caseSensitive: opts.caseSensitive
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
return stringToFind.every(function (stringToFindVal) {
|
|
52
|
-
return input.some(function (val) {
|
|
53
|
-
return matcher__default['default'].isMatch(val, stringToFindVal, {
|
|
54
|
-
caseSensitive: opts.caseSensitive
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
exports.defaults = defaults;
|
|
61
|
-
exports.includesWithGlob = includesWithGlob;
|
|
62
|
-
exports.version = version;
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @name array-includes-with-glob
|
|
3
|
-
* @fileoverview Like _.includes but with wildcards
|
|
4
|
-
* @version 3.0.16
|
|
5
|
-
* @author Roy Revelt, Codsen Ltd
|
|
6
|
-
* @license MIT
|
|
7
|
-
* {@link https://codsen.com/os/array-includes-with-glob/}
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
(function (global, factory) {
|
|
11
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
12
|
-
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
13
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.arrayIncludesWithGlob = {}));
|
|
14
|
-
}(this, (function (exports) { 'use strict';
|
|
15
|
-
|
|
16
|
-
var escapeStringRegexp = string => {
|
|
17
|
-
if (typeof string !== 'string') {
|
|
18
|
-
throw new TypeError('Expected a string');
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Escape characters with special meaning either inside or outside character sets.
|
|
22
|
-
// Use a simple backslash escape when it’s always valid, and a \unnnn escape when the simpler form would be disallowed by Unicode patterns’ stricter grammar.
|
|
23
|
-
return string
|
|
24
|
-
.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
|
|
25
|
-
.replace(/-/g, '\\x2d');
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
const regexpCache = new Map();
|
|
29
|
-
|
|
30
|
-
function sanitizeArray(input, inputName) {
|
|
31
|
-
if (!Array.isArray(input)) {
|
|
32
|
-
switch (typeof input) {
|
|
33
|
-
case 'string':
|
|
34
|
-
input = [input];
|
|
35
|
-
break;
|
|
36
|
-
case 'undefined':
|
|
37
|
-
input = [];
|
|
38
|
-
break;
|
|
39
|
-
default:
|
|
40
|
-
throw new TypeError(`Expected '${inputName}' to be a string or an array, but got a type of '${typeof input}'`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return input.filter(string => {
|
|
45
|
-
if (typeof string !== 'string') {
|
|
46
|
-
if (typeof string === 'undefined') {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
throw new TypeError(`Expected '${inputName}' to be an array of strings, but found a type of '${typeof string}' in the array`);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return true;
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function makeRegexp(pattern, options) {
|
|
58
|
-
options = {
|
|
59
|
-
caseSensitive: false,
|
|
60
|
-
...options
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
const cacheKey = pattern + JSON.stringify(options);
|
|
64
|
-
|
|
65
|
-
if (regexpCache.has(cacheKey)) {
|
|
66
|
-
return regexpCache.get(cacheKey);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const negated = pattern[0] === '!';
|
|
70
|
-
|
|
71
|
-
if (negated) {
|
|
72
|
-
pattern = pattern.slice(1);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
pattern = escapeStringRegexp(pattern).replace(/\\\*/g, '[\\s\\S]*');
|
|
76
|
-
|
|
77
|
-
const regexp = new RegExp(`^${pattern}$`, options.caseSensitive ? '' : 'i');
|
|
78
|
-
regexp.negated = negated;
|
|
79
|
-
regexpCache.set(cacheKey, regexp);
|
|
80
|
-
|
|
81
|
-
return regexp;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
var matcher = (inputs, patterns, options) => {
|
|
85
|
-
inputs = sanitizeArray(inputs, 'inputs');
|
|
86
|
-
patterns = sanitizeArray(patterns, 'patterns');
|
|
87
|
-
|
|
88
|
-
if (patterns.length === 0) {
|
|
89
|
-
return [];
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const isFirstPatternNegated = patterns[0][0] === '!';
|
|
93
|
-
|
|
94
|
-
patterns = patterns.map(pattern => makeRegexp(pattern, options));
|
|
95
|
-
|
|
96
|
-
const result = [];
|
|
97
|
-
|
|
98
|
-
for (const input of inputs) {
|
|
99
|
-
// If first pattern is negated we include everything to match user expectation.
|
|
100
|
-
let matches = isFirstPatternNegated;
|
|
101
|
-
|
|
102
|
-
for (const pattern of patterns) {
|
|
103
|
-
if (pattern.test(input)) {
|
|
104
|
-
matches = !pattern.negated;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (matches) {
|
|
109
|
-
result.push(input);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return result;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
var isMatch = (inputs, patterns, options) => {
|
|
117
|
-
inputs = sanitizeArray(inputs, 'inputs');
|
|
118
|
-
patterns = sanitizeArray(patterns, 'patterns');
|
|
119
|
-
|
|
120
|
-
if (patterns.length === 0) {
|
|
121
|
-
return false;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return inputs.some(input => {
|
|
125
|
-
return patterns.every(pattern => {
|
|
126
|
-
const regexp = makeRegexp(pattern, options);
|
|
127
|
-
const matches = regexp.test(input);
|
|
128
|
-
return regexp.negated ? !matches : matches;
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
};
|
|
132
|
-
matcher.isMatch = isMatch;
|
|
133
|
-
|
|
134
|
-
var version$1 = "3.0.16";
|
|
135
|
-
|
|
136
|
-
const version = version$1;
|
|
137
|
-
const defaults = {
|
|
138
|
-
arrayVsArrayAllMustBeFound: "any",
|
|
139
|
-
caseSensitive: true,
|
|
140
|
-
};
|
|
141
|
-
/**
|
|
142
|
-
* Like _.includes but with wildcards
|
|
143
|
-
*/
|
|
144
|
-
function includesWithGlob(originalInput, stringToFind, originalOpts) {
|
|
145
|
-
// maybe we can end prematurely:
|
|
146
|
-
if (!originalInput.length || !stringToFind.length) {
|
|
147
|
-
return false; // because nothing can be found in it
|
|
148
|
-
}
|
|
149
|
-
const opts = { ...defaults, ...originalOpts };
|
|
150
|
-
const input = typeof originalInput === "string"
|
|
151
|
-
? [originalInput]
|
|
152
|
-
: Array.from(originalInput);
|
|
153
|
-
if (typeof stringToFind === "string") {
|
|
154
|
-
return input.some((val) => matcher.isMatch(val, stringToFind, { caseSensitive: opts.caseSensitive }));
|
|
155
|
-
}
|
|
156
|
-
// array then.
|
|
157
|
-
if (opts.arrayVsArrayAllMustBeFound === "any") {
|
|
158
|
-
return stringToFind.some((stringToFindVal) => input.some((val) => matcher.isMatch(val, stringToFindVal, {
|
|
159
|
-
caseSensitive: opts.caseSensitive,
|
|
160
|
-
})));
|
|
161
|
-
}
|
|
162
|
-
return stringToFind.every((stringToFindVal) => input.some((val) => matcher.isMatch(val, stringToFindVal, {
|
|
163
|
-
caseSensitive: opts.caseSensitive,
|
|
164
|
-
})));
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
exports.defaults = defaults;
|
|
168
|
-
exports.includesWithGlob = includesWithGlob;
|
|
169
|
-
exports.version = version;
|
|
170
|
-
|
|
171
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
172
|
-
|
|
173
|
-
})));
|