array-includes-with-glob 4.0.6 → 4.0.12

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2010-2021 Roy Revelt and other contributors
3
+ Copyright (c) 2010-2022 Roy Revelt and other contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
package/README.md CHANGED
@@ -26,18 +26,17 @@
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:
29
+ The latest version is **ESM only**: Node 12+ is needed to use it and it must be `import`ed instead of `require`d. If your project is not on ESM yet and you want to use `require`, use an older version of this program, `3.1.0`.
30
30
 
31
31
  ```bash
32
32
  npm i array-includes-with-glob
33
33
  ```
34
34
 
35
- If you need a legacy version which works with `require`, use version 3.1.0
36
-
37
35
  ## Quick Take
38
36
 
39
37
  ```js
40
38
  import { strict as assert } from "assert";
39
+
41
40
  import { includesWithGlob } from "array-includes-with-glob";
42
41
 
43
42
  assert.equal(includesWithGlob(["xc", "yc", "zc"], "*c"), true);
@@ -52,7 +51,7 @@ assert.equal(includesWithGlob(["something", "anything", "zzz"], "some*"), true);
52
51
 
53
52
  ## Documentation
54
53
 
55
- Please [visit codsen.com](https://codsen.com/os/array-includes-with-glob/) for a full description of the API and examples.
54
+ Please [visit codsen.com](https://codsen.com/os/array-includes-with-glob/) for a full description of the API.
56
55
 
57
56
  ## Contributing
58
57
 
@@ -62,6 +61,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
62
61
 
63
62
  MIT License
64
63
 
65
- Copyright (c) 2010-2021 Roy Revelt and other contributors
64
+ Copyright (c) 2010-2022 Roy Revelt and other contributors
66
65
 
67
66
  <img src="https://codsen.com/images/png-codsen-ok.png" width="98" alt="ok" align="center"> <img src="https://codsen.com/images/png-codsen-1.png" width="148" alt="codsen" align="center"> <img src="https://codsen.com/images/png-codsen-star-small.png" width="32" alt="star" align="center">
@@ -1,40 +1,10 @@
1
1
  /**
2
2
  * @name array-includes-with-glob
3
3
  * @fileoverview Like _.includes but with wildcards
4
- * @version 4.0.6
4
+ * @version 4.0.12
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
- import { isMatch } from 'matcher';
11
-
12
- var version$1 = "4.0.6";
13
-
14
- const version = version$1;
15
- const defaults = {
16
- arrayVsArrayAllMustBeFound: "any",
17
- caseSensitive: true,
18
- };
19
- function includesWithGlob(originalInput, stringToFind, originalOpts) {
20
- if (!originalInput.length || !stringToFind.length) {
21
- return false;
22
- }
23
- const opts = { ...defaults, ...originalOpts };
24
- const input = typeof originalInput === "string"
25
- ? [originalInput]
26
- : Array.from(originalInput);
27
- if (typeof stringToFind === "string") {
28
- return input.some((val) => isMatch(val, stringToFind, { caseSensitive: opts.caseSensitive }));
29
- }
30
- if (opts.arrayVsArrayAllMustBeFound === "any") {
31
- return stringToFind.some((stringToFindVal) => input.some((val) => isMatch(val, stringToFindVal, {
32
- caseSensitive: opts.caseSensitive,
33
- })));
34
- }
35
- return stringToFind.every((stringToFindVal) => input.some((val) => isMatch(val, stringToFindVal, {
36
- caseSensitive: opts.caseSensitive,
37
- })));
38
- }
39
-
40
- export { defaults, includesWithGlob, version };
10
+ function d(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var y=new Map,p=(e,r)=>{if(!Array.isArray(e))switch(typeof e){case"string":e=[e];break;case"undefined":e=[];break;default:throw new TypeError(`Expected '${r}' to be a string or an array, but got a type of '${typeof e}'`)}return e.filter(t=>{if(typeof t!="string"){if(typeof t=="undefined")return!1;throw new TypeError(`Expected '${r}' to be an array of strings, but found a type of '${typeof t}' in the array`)}return!0})},h=(e,r)=>{r={caseSensitive:!1,...r};let t=e+JSON.stringify(r);if(y.has(t))return y.get(t);let s=e[0]==="!";s&&(e=e.slice(1)),e=d(e).replace(/\\\*/g,"[\\s\\S]*");let n=new RegExp(`^${e}$`,r.caseSensitive?"":"i");return n.negated=s,y.set(t,n),n},m=(e,r,t,s)=>{if(e=p(e,"inputs"),r=p(r,"patterns"),r.length===0)return[];r=r.map(a=>h(a,t));let{allPatterns:n}=t||{},i=[];for(let a of e){let c,f=[...r].fill(!1);for(let[o,l]of r.entries())if(l.test(a)&&(f[o]=!0,c=!l.negated,!c))break;if(!(c===!1||c===void 0&&r.some(o=>!o.negated)||n&&f.some((o,l)=>!o&&!r[l].negated))&&(i.push(a),s))break}return i};function u(e,r,t){return m(e,r,t,!0).length>0}var g="4.0.12";var M=g,x={arrayVsArrayAllMustBeFound:"any",caseSensitive:!0};function j(e,r,t){if(!e.length||!r.length)return!1;let s={...x,...t},n=typeof e=="string"?[e]:Array.from(e);return typeof r=="string"?n.some(i=>u(i,r,{caseSensitive:s.caseSensitive})):s.arrayVsArrayAllMustBeFound==="any"?r.some(i=>n.some(a=>u(a,i,{caseSensitive:s.caseSensitive}))):r.every(i=>n.some(a=>u(a,i,{caseSensitive:s.caseSensitive})))}export{x as defaults,j as includesWithGlob,M as version};
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @name array-includes-with-glob
3
3
  * @fileoverview Like _.includes but with wildcards
4
- * @version 4.0.6
4
+ * @version 4.0.12
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";const t=new Map,n=(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}))},r=(e,n)=>{n={caseSensitive:!1,...n};const r=e+JSON.stringify(n);if(t.has(r))return t.get(r);const s="!"===e[0];s&&(e=e.slice(1)),e=function(e){if("string"!=typeof e)throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}(e).replace(/\\\*/g,"[\\s\\S]*");const i=new RegExp(`^${e}$`,n.caseSensitive?"":"i");return i.negated=s,t.set(r,i),i};function s(e,t,s){return((e,t,s,i)=>{if(e=n(e,"inputs"),0===(t=n(t,"patterns")).length)return[];t=t.map((e=>r(e,s)));const{allPatterns:o}=s||{},a=[];for(const n of e){let e;const r=[...t].fill(!1);for(const[s,i]of t.entries())if(i.test(n)&&(r[s]=!0,e=!i.negated,!e))break;if(!(!1===e||void 0===e&&t.some((e=>!e.negated))||o&&r.some(((e,n)=>!e&&!t[n].negated)))&&(a.push(n),i))break}return a})(e,t,s,!0).length>0}const i={arrayVsArrayAllMustBeFound:"any",caseSensitive:!0};e.defaults=i,e.includesWithGlob=function(e,t,n){if(!e.length||!t.length)return!1;const r={...i,...n},o="string"==typeof e?[e]:Array.from(e);return"string"==typeof t?o.some((e=>s(e,t,{caseSensitive:r.caseSensitive}))):"any"===r.arrayVsArrayAllMustBeFound?t.some((e=>o.some((t=>s(t,e,{caseSensitive:r.caseSensitive}))))):t.every((e=>o.some((t=>s(t,e,{caseSensitive:r.caseSensitive})))))},e.version="4.0.6",Object.defineProperty(e,"__esModule",{value:!0})}));
10
+ var arrayIncludesWithGlob=(()=>{var d=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames,h=Object.getOwnPropertySymbols;var m=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var b=(e,r,t)=>r in e?d(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,c=(e,r)=>{for(var t in r||(r={}))m.call(r,t)&&b(e,t,r[t]);if(h)for(var t of h(r))A.call(r,t)&&b(e,t,r[t]);return e};var E=e=>d(e,"__esModule",{value:!0});var M=(e,r)=>{for(var t in r)d(e,t,{get:r[t],enumerable:!0})},j=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of k(r))!m.call(e,s)&&(t||s!=="default")&&d(e,s,{get:()=>r[s],enumerable:!(n=S(r,s))||n.enumerable});return e};var $=(e=>(r,t)=>e&&e.get(r)||(t=j(E({}),r,1),e&&e.set(r,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var z={};M(z,{defaults:()=>w,includesWithGlob:()=>D,version:()=>B});function f(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var p=new Map,x=(e,r)=>{if(!Array.isArray(e))switch(typeof e){case"string":e=[e];break;case"undefined":e=[];break;default:throw new TypeError(`Expected '${r}' to be a string or an array, but got a type of '${typeof e}'`)}return e.filter(t=>{if(typeof t!="string"){if(typeof t=="undefined")return!1;throw new TypeError(`Expected '${r}' to be an array of strings, but found a type of '${typeof t}' in the array`)}return!0})},R=(e,r)=>{r=c({caseSensitive:!1},r);let t=e+JSON.stringify(r);if(p.has(t))return p.get(t);let n=e[0]==="!";n&&(e=e.slice(1)),e=f(e).replace(/\\\*/g,"[\\s\\S]*");let s=new RegExp(`^${e}$`,r.caseSensitive?"":"i");return s.negated=n,p.set(t,s),s},O=(e,r,t,n)=>{if(e=x(e,"inputs"),r=x(r,"patterns"),r.length===0)return[];r=r.map(a=>R(a,t));let{allPatterns:s}=t||{},i=[];for(let a of e){let l,g=[...r].fill(!1);for(let[o,u]of r.entries())if(u.test(a)&&(g[o]=!0,l=!u.negated,!l))break;if(!(l===!1||l===void 0&&r.some(o=>!o.negated)||s&&g.some((o,u)=>!o&&!r[u].negated))&&(i.push(a),n))break}return i};function y(e,r,t){return O(e,r,t,!0).length>0}var v="4.0.12";var B=v,w={arrayVsArrayAllMustBeFound:"any",caseSensitive:!0};function D(e,r,t){if(!e.length||!r.length)return!1;let n=c(c({},w),t),s=typeof e=="string"?[e]:Array.from(e);return typeof r=="string"?s.some(i=>y(i,r,{caseSensitive:n.caseSensitive})):n.arrayVsArrayAllMustBeFound==="any"?r.some(i=>s.some(a=>y(a,i,{caseSensitive:n.caseSensitive}))):r.every(i=>s.some(a=>y(a,i,{caseSensitive:n.caseSensitive})))}return $(z);})();
@@ -1,6 +1,7 @@
1
1
  // Quick Take
2
2
 
3
3
  import { strict as assert } from "assert";
4
+
4
5
  import { includesWithGlob } from "../dist/array-includes-with-glob.esm.js";
5
6
 
6
7
  assert.equal(includesWithGlob(["xc", "yc", "zc"], "*c"), true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "array-includes-with-glob",
3
- "version": "4.0.6",
3
+ "version": "4.0.12",
4
4
  "description": "Like _.includes but with wildcards",
5
5
  "keywords": [
6
6
  "array",
@@ -37,90 +37,37 @@
37
37
  },
38
38
  "types": "types/index.d.ts",
39
39
  "scripts": {
40
- "build": "rollup -c",
41
- "build:esbuild": "node '../../scripts/esbuild.js'",
42
- "build:esbuild:dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
43
- "ci_test": "npm run build && npm run format && tap --no-only --reporter=silent",
44
- "clean_types": "../../scripts/cleanTypes.js",
45
- "dev": "rollup -c --dev",
46
- "devunittest": "npm run dev && tap --only -R 'base'",
47
- "format": "npm run lect && npm run prettier && npm run lint",
48
- "lect": "lect",
49
- "lint": "../../node_modules/eslint/bin/eslint.js . --ext .js --ext .ts --fix --config \"../../.eslintrc.json\" --quiet",
50
- "perf": "node perf/check",
51
- "prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
52
- "republish": "npm publish || :",
53
- "tap": "tap",
54
- "pretest": "npm run build",
55
- "test": "npm run test:ci && npm run perf",
56
- "test:ci": "npm run unittest && npm run test:examples && npm run format",
57
- "test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
58
- "tsc": "tsc",
59
- "unittest": "tap --no-only --reporter=terse && tsc -p tsconfig.json --noEmit"
40
+ "build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
41
+ "dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
42
+ "devtest": "c8 yarn run unit && yarn run examples && yarn run lint",
43
+ "dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
44
+ "examples": "node '../../ops/scripts/run-examples.js'",
45
+ "lect": "node '../../ops/lect/lect.js' && yarn run prettier 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
46
+ "letspublish": "yarn publish || :",
47
+ "lint": "eslint . --fix",
48
+ "perf": "node perf/check.js",
49
+ "prepare": "echo 'ready'",
50
+ "prettier": "prettier",
51
+ "prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
52
+ "pretest": "yarn run lect && yarn run build",
53
+ "test": "yarn run devtest",
54
+ "unit": "uvu test"
60
55
  },
61
- "tap": {
62
- "check-coverage": false,
63
- "node-arg": [
64
- "--no-warnings",
65
- "--experimental-loader",
66
- "@istanbuljs/esm-loader-hook"
56
+ "engines": {
57
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
58
+ },
59
+ "c8": {
60
+ "check-coverage": true,
61
+ "exclude": [
62
+ "**/test/**/*.*"
67
63
  ],
68
- "timeout": 0
64
+ "lines": 100
69
65
  },
70
66
  "lect": {
71
67
  "licence": {
72
68
  "extras": [
73
69
  ""
74
70
  ]
75
- },
76
- "req": "{ includesWithGlob }",
77
- "various": {
78
- "devDependencies": []
79
71
  }
80
- },
81
- "dependencies": {
82
- "@babel/runtime": "^7.16.3",
83
- "matcher": "^5.0.0"
84
- },
85
- "devDependencies": {
86
- "@babel/cli": "^7.16.0",
87
- "@babel/core": "^7.16.0",
88
- "@babel/node": "^7.16.0",
89
- "@babel/plugin-external-helpers": "^7.16.0",
90
- "@babel/plugin-proposal-class-properties": "^7.16.0",
91
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
92
- "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
93
- "@babel/plugin-proposal-optional-chaining": "^7.16.0",
94
- "@babel/plugin-transform-runtime": "^7.16.4",
95
- "@babel/preset-env": "^7.16.4",
96
- "@babel/preset-typescript": "^7.16.0",
97
- "@babel/register": "^7.16.0",
98
- "@istanbuljs/esm-loader-hook": "^0.1.2",
99
- "@rollup/plugin-babel": "^5.3.0",
100
- "@rollup/plugin-commonjs": "^21.0.1",
101
- "@rollup/plugin-json": "^4.1.0",
102
- "@rollup/plugin-node-resolve": "^13.0.6",
103
- "@rollup/plugin-strip": "^2.1.0",
104
- "@rollup/plugin-typescript": "^8.3.0",
105
- "@types/node": "^16.11.9",
106
- "@types/tap": "^15.0.5",
107
- "@typescript-eslint/eslint-plugin": "^5.4.0",
108
- "@typescript-eslint/parser": "^5.4.0",
109
- "core-js": "^3.19.1",
110
- "cross-env": "^7.0.3",
111
- "eslint": "^8.3.0",
112
- "lect": "^0.18.6",
113
- "rollup": "^2.60.0",
114
- "rollup-plugin-ascii": "^0.0.3",
115
- "rollup-plugin-banner": "^0.2.1",
116
- "rollup-plugin-cleanup": "^3.2.1",
117
- "rollup-plugin-dts": "^4.0.1",
118
- "rollup-plugin-terser": "^7.0.2",
119
- "tap": "^15.1.2",
120
- "tslib": "^2.3.1",
121
- "typescript": "^4.5.2"
122
- },
123
- "engines": {
124
- "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
125
72
  }
126
73
  }
package/types/index.d.ts CHANGED
@@ -1,12 +1,16 @@
1
1
  declare const version: string;
2
2
  interface Opts {
3
- arrayVsArrayAllMustBeFound?: "any" | "all";
4
- caseSensitive?: boolean;
3
+ arrayVsArrayAllMustBeFound?: "any" | "all";
4
+ caseSensitive?: boolean;
5
5
  }
6
6
  declare const defaults: Opts;
7
7
  /**
8
8
  * Like _.includes but with wildcards
9
9
  */
10
- declare function includesWithGlob(originalInput: string | string[], stringToFind: string | string[], originalOpts?: Opts): boolean;
10
+ declare function includesWithGlob(
11
+ originalInput: string | string[],
12
+ stringToFind: string | string[],
13
+ originalOpts?: Opts
14
+ ): boolean;
11
15
 
12
16
  export { defaults, includesWithGlob, version };
package/examples/api.json DELETED
@@ -1 +0,0 @@
1
- {"_quickTake.js":{"title":"Quick Take","content":"import &#x7B; strict as assert &#x7D; from \"assert\";\nimport &#x7B; includesWithGlob &#x7D; from \"array-includes-with-glob\";\n\nassert.equal(includesWithGlob([\"xc\", \"yc\", \"zc\"], \"*c\"), true);\n// (all 3)\n\nassert.equal(includesWithGlob([\"xc\", \"yc\", \"zc\"], \"*a\"), false);\n// (none found)\n\nassert.equal(includesWithGlob([\"something\", \"anything\", \"zzz\"], \"some*\"), true);\n// (1 hit)"}}