array-includes-with-glob 4.0.5 → 4.0.11

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,42 +1,10 @@
1
1
  /**
2
2
  * @name array-includes-with-glob
3
3
  * @fileoverview Like _.includes but with wildcards
4
- * @version 4.0.5
4
+ * @version 4.0.11
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.5";
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,
24
- ...originalOpts
25
- };
26
- const input = typeof originalInput === "string" ? [originalInput] : Array.from(originalInput);
27
- if (typeof stringToFind === "string") {
28
- return input.some(val => isMatch(val, stringToFind, {
29
- caseSensitive: opts.caseSensitive
30
- }));
31
- }
32
- if (opts.arrayVsArrayAllMustBeFound === "any") {
33
- return stringToFind.some(stringToFindVal => input.some(val => isMatch(val, stringToFindVal, {
34
- caseSensitive: opts.caseSensitive
35
- })));
36
- }
37
- return stringToFind.every(stringToFindVal => input.some(val => isMatch(val, stringToFindVal, {
38
- caseSensitive: opts.caseSensitive
39
- })));
40
- }
41
-
42
- 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.11";var M=g,x={arrayVsArrayAllMustBeFound:"any",caseSensitive:!0};function $(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,$ 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.5
4
+ * @version 4.0.11
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.5",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})},$=(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 j=(e=>(r,t)=>e&&e.get(r)||(t=$(E({}),r,1),e&&e.set(r,t),t))(typeof WeakMap!="undefined"?new WeakMap:0);var C={};M(C,{defaults:()=>v,includesWithGlob:()=>z,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 w="4.0.11";var B=w,v={arrayVsArrayAllMustBeFound:"any",caseSensitive:!0};function z(e,r,t){if(!e.length||!r.length)return!1;let n=c(c({},v),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 j(C);})();
@@ -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.5",
3
+ "version": "4.0.11",
4
4
  "description": "Like _.includes but with wildcards",
5
5
  "keywords": [
6
6
  "array",
@@ -37,94 +37,36 @@
37
37
  },
38
38
  "types": "types/index.d.ts",
39
39
  "scripts": {
40
- "build": "rollup -c",
41
- "ci_test": "npm run build && npm run format && tap --no-only --reporter=silent --output-file=testStats.md && npm run clean_cov",
42
- "clean_cov": "../../scripts/leaveCoverageTotalOnly.js",
43
- "clean_types": "../../scripts/cleanTypes.js",
44
- "dev": "rollup -c --dev",
45
- "devunittest": "npm run dev && tap --only -R 'base'",
46
- "esbuild": "node '../../scripts/esbuild.js'",
47
- "esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
48
- "format": "npm run lect && npm run prettier && npm run lint",
49
- "lect": "lect",
50
- "lint": "../../node_modules/eslint/bin/eslint.js . --ext .js --ext .ts --fix --config \"../../.eslintrc.json\" --quiet",
51
- "perf": "node perf/check",
52
- "prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
53
- "republish": "npm publish || :",
54
- "tap": "tap",
55
- "pretest": "npm run build",
56
- "test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
57
- "test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
58
- "tsc": "tsc",
59
- "unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf"
40
+ "build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
41
+ "dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
42
+ "dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
43
+ "examples": "node '../../ops/scripts/run-examples.js'",
44
+ "lect": "node '../../ops/lect/lect.js'",
45
+ "letspublish": "yarn publish || :",
46
+ "lint": "eslint . --fix",
47
+ "perf": "node perf/check.js",
48
+ "prepare": "echo 'ready'",
49
+ "prettier": "prettier",
50
+ "prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
51
+ "pretest": "yarn run lect && yarn run build",
52
+ "test": "c8 yarn run unit && yarn run examples && yarn run lint",
53
+ "unit": "uvu test"
60
54
  },
61
- "tap": {
62
- "check-coverage": false,
63
- "coverage-report": [
64
- "json-summary",
65
- "text"
66
- ],
67
- "node-arg": [
68
- "--no-warnings",
69
- "--experimental-loader",
70
- "@istanbuljs/esm-loader-hook"
55
+ "engines": {
56
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
57
+ },
58
+ "c8": {
59
+ "check-coverage": true,
60
+ "exclude": [
61
+ "**/test/**/*.*"
71
62
  ],
72
- "timeout": 0
63
+ "lines": 100
73
64
  },
74
65
  "lect": {
75
66
  "licence": {
76
67
  "extras": [
77
68
  ""
78
69
  ]
79
- },
80
- "req": "{ includesWithGlob }",
81
- "various": {
82
- "devDependencies": []
83
70
  }
84
- },
85
- "dependencies": {
86
- "@babel/runtime": "^7.16.0",
87
- "matcher": "^5.0.0"
88
- },
89
- "devDependencies": {
90
- "@babel/cli": "^7.16.0",
91
- "@babel/core": "^7.16.0",
92
- "@babel/node": "^7.16.0",
93
- "@babel/plugin-external-helpers": "^7.16.0",
94
- "@babel/plugin-proposal-class-properties": "^7.16.0",
95
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
96
- "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
97
- "@babel/plugin-proposal-optional-chaining": "^7.16.0",
98
- "@babel/plugin-transform-runtime": "^7.16.0",
99
- "@babel/preset-env": "^7.16.0",
100
- "@babel/preset-typescript": "^7.16.0",
101
- "@babel/register": "^7.16.0",
102
- "@istanbuljs/esm-loader-hook": "^0.1.2",
103
- "@rollup/plugin-babel": "^5.3.0",
104
- "@rollup/plugin-commonjs": "^21.0.1",
105
- "@rollup/plugin-json": "^4.1.0",
106
- "@rollup/plugin-node-resolve": "^13.0.6",
107
- "@rollup/plugin-strip": "^2.1.0",
108
- "@rollup/plugin-typescript": "^8.3.0",
109
- "@types/node": "^16.11.6",
110
- "@types/tap": "^15.0.5",
111
- "@typescript-eslint/eslint-plugin": "^5.3.0",
112
- "@typescript-eslint/parser": "^5.3.0",
113
- "core-js": "^3.19.1",
114
- "cross-env": "^7.0.3",
115
- "eslint": "^8.2.0",
116
- "lect": "^0.18.5",
117
- "rollup": "^2.59.0",
118
- "rollup-plugin-ascii": "^0.0.3",
119
- "rollup-plugin-banner": "^0.2.1",
120
- "rollup-plugin-cleanup": "^3.2.1",
121
- "rollup-plugin-dts": "^4.0.1",
122
- "rollup-plugin-terser": "^7.0.2",
123
- "tap": "^15.0.10",
124
- "tslib": "^2.3.1",
125
- "typescript": "^4.4.4"
126
- },
127
- "engines": {
128
- "node": ">=12"
129
71
  }
130
72
  }
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)"}}