array-includes-with-glob 4.0.10 → 4.0.13

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
@@ -1,6 +1,6 @@
1
1
  # array-includes-with-glob
2
2
 
3
- > Like _.includes but with wildcards
3
+ > Like \_.includes but with wildcards
4
4
 
5
5
  <div class="package-badges">
6
6
  <a href="https://www.npmjs.com/package/array-includes-with-glob" rel="nofollow noreferrer noopener">
@@ -26,14 +26,12 @@
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
+ This package is [pure ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). If you're not ready yet, install an older version of this program, 3.1.0 (`npm i array-includes-with-glob@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
@@ -63,8 +61,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
63
61
 
64
62
  MIT License
65
63
 
66
- Copyright (c) 2010-2021 Roy Revelt and other contributors
67
-
64
+ Copyright (c) 2010-2022 Roy Revelt and other contributors
68
65
 
69
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">
70
-
@@ -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.10
4
+ * @version 4.0.13
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 d(e){if(typeof e!="string")throw new TypeError("Expected a string");return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var f=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(s=>{if(typeof s!="string"){if(typeof s=="undefined")return!1;throw new TypeError(`Expected '${r}' to be an array of strings, but found a type of '${typeof s}' in the array`)}return!0})},h=(e,r)=>{r={caseSensitive:!1,...r};let s=e+JSON.stringify(r);if(f.has(s))return f.get(s);let t=e[0]==="!";t&&(e=e.slice(1)),e=d(e).replace(/\\\*/g,"[\\s\\S]*");let n=new RegExp(`^${e}$`,r.caseSensitive?"":"i");return n.negated=t,f.set(s,n),n},m=(e,r,s,t)=>{if(e=p(e,"inputs"),r=p(r,"patterns"),r.length===0)return[];r=r.map(i=>h(i,s));let{allPatterns:n}=s||{},a=[];for(let i of e){let c,y=[...r].fill(!1);for(let[o,l]of r.entries())if(l.test(i)&&(y[o]=!0,c=!l.negated,!c))break;if(!(c===!1||c===void 0&&r.some(o=>!o.negated)||n&&y.some((o,l)=>!o&&!r[l].negated))&&(a.push(i),t))break}return a};function u(e,r,s){return m(e,r,s,!0).length>0}var g="4.0.10";var M=g,x={arrayVsArrayAllMustBeFound:"any",caseSensitive:!0};function $(e,r,s){if(!e.length||!r.length)return!1;let t={...x,...s},n=typeof e=="string"?[e]:Array.from(e);return typeof r=="string"?n.some(a=>u(a,r,{caseSensitive:t.caseSensitive})):t.arrayVsArrayAllMustBeFound==="any"?r.some(a=>n.some(i=>u(i,a,{caseSensitive:t.caseSensitive}))):r.every(a=>n.some(i=>u(i,a,{caseSensitive:t.caseSensitive})))}export{x as defaults,$ as includesWithGlob,M as 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>"u")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.13";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.10
4
+ * @version 4.0.13
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
- 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,s)=>r in e?d(e,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[r]=s,c=(e,r)=>{for(var s in r||(r={}))m.call(r,s)&&b(e,s,r[s]);if(h)for(var s of h(r))A.call(r,s)&&b(e,s,r[s]);return e};var E=e=>d(e,"__esModule",{value:!0});var M=(e,r)=>{for(var s in r)d(e,s,{get:r[s],enumerable:!0})},$=(e,r,s,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of k(r))!m.call(e,t)&&(s||t!=="default")&&d(e,t,{get:()=>r[t],enumerable:!(n=S(r,t))||n.enumerable});return e};var j=(e=>(r,s)=>e&&e.get(r)||(s=$(E({}),r,1),e&&e.set(r,s),s))(typeof WeakMap!="undefined"?new WeakMap:0);var C={};M(C,{defaults:()=>w,includesWithGlob:()=>z,version:()=>B});function y(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(s=>{if(typeof s!="string"){if(typeof s=="undefined")return!1;throw new TypeError(`Expected '${r}' to be an array of strings, but found a type of '${typeof s}' in the array`)}return!0})},R=(e,r)=>{r=c({caseSensitive:!1},r);let s=e+JSON.stringify(r);if(p.has(s))return p.get(s);let n=e[0]==="!";n&&(e=e.slice(1)),e=y(e).replace(/\\\*/g,"[\\s\\S]*");let t=new RegExp(`^${e}$`,r.caseSensitive?"":"i");return t.negated=n,p.set(s,t),t},O=(e,r,s,n)=>{if(e=x(e,"inputs"),r=x(r,"patterns"),r.length===0)return[];r=r.map(i=>R(i,s));let{allPatterns:t}=s||{},a=[];for(let i of e){let l,g=[...r].fill(!1);for(let[o,u]of r.entries())if(u.test(i)&&(g[o]=!0,l=!u.negated,!l))break;if(!(l===!1||l===void 0&&r.some(o=>!o.negated)||t&&g.some((o,u)=>!o&&!r[u].negated))&&(a.push(i),n))break}return a};function f(e,r,s){return O(e,r,s,!0).length>0}var v="4.0.10";var B=v,w={arrayVsArrayAllMustBeFound:"any",caseSensitive:!0};function z(e,r,s){if(!e.length||!r.length)return!1;let n=c(c({},w),s),t=typeof e=="string"?[e]:Array.from(e);return typeof r=="string"?t.some(a=>f(a,r,{caseSensitive:n.caseSensitive})):n.arrayVsArrayAllMustBeFound==="any"?r.some(a=>t.some(i=>f(i,a,{caseSensitive:n.caseSensitive}))):r.every(a=>t.some(i=>f(i,a,{caseSensitive:n.caseSensitive})))}return j(C);})();
10
+ var arrayIncludesWithGlob=(()=>{var d=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames,h=Object.getOwnPropertySymbols;var b=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var m=(r,e,t)=>e in r?d(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,c=(r,e)=>{for(var t in e||(e={}))b.call(e,t)&&m(r,t,e[t]);if(h)for(var t of h(e))A.call(e,t)&&m(r,t,e[t]);return r};var E=(r,e)=>{for(var t in e)d(r,t,{get:e[t],enumerable:!0})},M=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of k(e))!b.call(r,s)&&s!==t&&d(r,s,{get:()=>e[s],enumerable:!(n=S(e,s))||n.enumerable});return r};var j=r=>M(d({},"__esModule",{value:!0}),r);var D={};E(D,{defaults:()=>w,includesWithGlob:()=>B,version:()=>V});function f(r){if(typeof r!="string")throw new TypeError("Expected a string");return r.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}var p=new Map,x=(r,e)=>{if(!Array.isArray(r))switch(typeof r){case"string":r=[r];break;case"undefined":r=[];break;default:throw new TypeError(`Expected '${e}' to be a string or an array, but got a type of '${typeof r}'`)}return r.filter(t=>{if(typeof t!="string"){if(typeof t>"u")return!1;throw new TypeError(`Expected '${e}' to be an array of strings, but found a type of '${typeof t}' in the array`)}return!0})},$=(r,e)=>{e=c({caseSensitive:!1},e);let t=r+JSON.stringify(e);if(p.has(t))return p.get(t);let n=r[0]==="!";n&&(r=r.slice(1)),r=f(r).replace(/\\\*/g,"[\\s\\S]*");let s=new RegExp(`^${r}$`,e.caseSensitive?"":"i");return s.negated=n,p.set(t,s),s},R=(r,e,t,n)=>{if(r=x(r,"inputs"),e=x(e,"patterns"),e.length===0)return[];e=e.map(a=>$(a,t));let{allPatterns:s}=t||{},i=[];for(let a of r){let l,g=[...e].fill(!1);for(let[o,u]of e.entries())if(u.test(a)&&(g[o]=!0,l=!u.negated,!l))break;if(!(l===!1||l===void 0&&e.some(o=>!o.negated)||s&&g.some((o,u)=>!o&&!e[u].negated))&&(i.push(a),n))break}return i};function y(r,e,t){return R(r,e,t,!0).length>0}var v="4.0.13";var V=v,w={arrayVsArrayAllMustBeFound:"any",caseSensitive:!0};function B(r,e,t){if(!r.length||!e.length)return!1;let n=c(c({},w),t),s=typeof r=="string"?[r]:Array.from(r);return typeof e=="string"?s.some(i=>y(i,e,{caseSensitive:n.caseSensitive})):n.arrayVsArrayAllMustBeFound==="any"?e.some(i=>s.some(a=>y(a,i,{caseSensitive:n.caseSensitive}))):e.every(i=>s.some(a=>y(a,i,{caseSensitive:n.caseSensitive})))}return j(D);})();
@@ -0,0 +1,26 @@
1
+ // `opts.arrayVsArrayAllMustBeFound`
2
+
3
+ import { strict as assert } from "assert";
4
+
5
+ import { includesWithGlob } from "../dist/array-includes-with-glob.esm.js";
6
+
7
+ let source = ["aaa", "bbb", "ccc"];
8
+ let whatToLookFor = ["a*", "d*"];
9
+
10
+ // the default setting for opts.arrayVsArrayAllMustBeFound is "any"
11
+ assert.equal(includesWithGlob(source, whatToLookFor), true);
12
+ assert.equal(
13
+ includesWithGlob(source, whatToLookFor, {
14
+ arrayVsArrayAllMustBeFound: "any",
15
+ }),
16
+ true
17
+ );
18
+ // true, because one element, 'a*' was found in source (it was its first element)
19
+
20
+ assert.equal(
21
+ includesWithGlob(source, whatToLookFor, {
22
+ arrayVsArrayAllMustBeFound: "all",
23
+ }),
24
+ false
25
+ );
26
+ // false, because not all elements were found, the 'd*' is missing
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "array-includes-with-glob",
3
- "version": "4.0.10",
3
+ "version": "4.0.13",
4
4
  "description": "Like _.includes but with wildcards",
5
5
  "keywords": [
6
6
  "array",
@@ -39,15 +39,18 @@
39
39
  "scripts": {
40
40
  "build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
41
41
  "dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
42
- "dts": "rollup -c",
42
+ "devtest": "c8 yarn run unit && yarn run examples && yarn run lint",
43
+ "dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
43
44
  "examples": "node '../../ops/scripts/run-examples.js'",
44
- "lect": "node '../../ops/lect/lect.js'",
45
+ "lect": "node '../../ops/lect/lect.js' && yarn run prettier 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
45
46
  "letspublish": "yarn publish || :",
46
47
  "lint": "eslint . --fix",
47
48
  "perf": "node perf/check.js",
48
49
  "prepare": "echo 'ready'",
50
+ "prettier": "prettier",
51
+ "prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
49
52
  "pretest": "yarn run lect && yarn run build",
50
- "test": "c8 yarn run unit && yarn run examples && yarn run lint",
53
+ "test": "yarn run devtest",
51
54
  "unit": "uvu test"
52
55
  },
53
56
  "engines": {
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 };