array-pull-all-with-glob 5.1.0 → 6.0.3

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,36 @@
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
+ ## 6.0.3 (2021-11-02)
7
+
8
+ ### Bug Fixes
9
+
10
+ - bump TS and separate ESLint plugins away from this monorepo ([b1ebce1](https://github.com/codsen/codsen/commit/b1ebce1637d8c41c2d848fc24b0ba4058865bd5d))
11
+
12
+ ### Features
13
+
14
+ - migrate to ES Modules ([c579dff](https://github.com/codsen/codsen/commit/c579dff3b23205e383035ca10ddcec671e35d0fe))
15
+
16
+ ### BREAKING CHANGES
17
+
18
+ - programs now are in ES Modules and won't work with Common JS require()
19
+
20
+ ## 6.0.1 (2021-09-13)
21
+
22
+ ### Bug Fixes
23
+
24
+ - bump TS and separate ESLint plugins away from this monorepo ([2e07d42](https://github.com/codsen/codsen/commit/2e07d424222b6ffedf5fb45c83ad453627ec2904))
25
+
26
+ ## 6.0.0 (2021-09-09)
27
+
28
+ ### Features
29
+
30
+ - migrate to ES Modules ([8c9d95d](https://github.com/codsen/codsen/commit/8c9d95d5dea0b769c2f070397141918a4893d575))
31
+
32
+ ### BREAKING CHANGES
33
+
34
+ - programs now are in ES Modules and won't work with Common JS require()
35
+
6
36
  ## 5.1.0 (2021-05-24)
7
37
 
8
38
  ### Features
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-pull-all-with-glob
31
33
  ```
32
34
 
35
+ If you need a legacy version which works with `require`, use version 5.1.0
36
+
33
37
  ## Quick Take
34
38
 
35
39
  ```js
@@ -1,15 +1,15 @@
1
1
  /**
2
2
  * @name array-pull-all-with-glob
3
3
  * @fileoverview Like _.pullAll but with globs (wildcards)
4
- * @version 5.1.0
4
+ * @version 6.0.3
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/array-pull-all-with-glob/}
8
8
  */
9
9
 
10
- import matcher from 'matcher';
10
+ import { isMatch } from 'matcher';
11
11
 
12
- var version$1 = "5.1.0";
12
+ var version$1 = "6.0.3";
13
13
 
14
14
  const version = version$1;
15
15
  function pull(originalInput, originalToBeRemoved, originalOpts) {
@@ -26,7 +26,7 @@ function pull(originalInput, originalToBeRemoved, originalOpts) {
26
26
  const opts = { ...defaults,
27
27
  ...originalOpts
28
28
  };
29
- const res = Array.from(originalInput).filter(originalVal => !toBeRemoved.some(remVal => matcher.isMatch(originalVal, remVal, {
29
+ const res = Array.from(originalInput).filter(originalVal => !toBeRemoved.some(remVal => isMatch(originalVal, remVal, {
30
30
  caseSensitive: opts.caseSensitive
31
31
  })));
32
32
  return res;
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @name array-pull-all-with-glob
3
3
  * @fileoverview Like _.pullAll but with globs (wildcards)
4
- * @version 5.1.0
4
+ * @version 6.0.3
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/array-pull-all-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).arrayPullAllWithGlob={})}(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 o(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 s(e,t){t={caseSensitive:!1,...t};const o=e+JSON.stringify(t);if(n.has(o))return n.get(o);const s="!"===e[0];s&&(e=e.slice(1)),e=r(e).replace(/\\\*/g,"[\\s\\S]*");const i=new RegExp(`^${e}$`,t.caseSensitive?"":"i");return i.negated=s,n.set(o,i),i}t.exports=(e,t,r)=>{if(e=o(e,"inputs"),0===(t=o(t,"patterns")).length)return[];const n="!"===t[0][0];t=t.map((e=>s(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=o(e,"inputs"),0!==(t=o(t,"patterns")).length&&e.some((e=>t.every((t=>{const n=s(t,r),o=n.test(e);return n.negated?!o:o})))));var i=t.exports;e.pull=function(e,t,r){if(!e.length)return[];if(!e.length||!t.length)return Array.from(e);const n="string"==typeof t?[t]:Array.from(t),o={caseSensitive:!0,...r};return Array.from(e).filter((e=>!n.some((t=>i.isMatch(e,t,{caseSensitive:o.caseSensitive})))))},e.version="5.1.0",Object.defineProperty(e,"__esModule",{value:!0})}));
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).arrayPullAllWithGlob={})}(this,(function(e){"use strict";const t=new Map,r=(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}))},n=(e,r)=>{r={caseSensitive:!1,...r};const n=e+JSON.stringify(r);if(t.has(n))return t.get(n);const o="!"===e[0];o&&(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}$`,r.caseSensitive?"":"i");return i.negated=o,t.set(n,i),i};function o(e,t,o){return((e,t,o,i)=>{if(e=r(e,"inputs"),0===(t=r(t,"patterns")).length)return[];t=t.map((e=>n(e,o)));const{allPatterns:s}=o||{},f=[];for(const r of e){let e;const n=[...t].fill(!1);for(const[o,i]of t.entries())if(i.test(r)&&(n[o]=!0,e=!i.negated,!e))break;if(!(!1===e||void 0===e&&t.some((e=>!e.negated))||s&&n.some(((e,r)=>!e&&!t[r].negated)))&&(f.push(r),i))break}return f})(e,t,o,!0).length>0}e.pull=function(e,t,r){if(!e.length)return[];if(!e.length||!t.length)return Array.from(e);const n="string"==typeof t?[t]:Array.from(t),i={caseSensitive:!0,...r};return Array.from(e).filter((e=>!n.some((t=>o(e,t,{caseSensitive:i.caseSensitive})))))},e.version="6.0.3",Object.defineProperty(e,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "array-pull-all-with-glob",
3
- "version": "5.1.0",
3
+ "version": "6.0.3",
4
4
  "description": "Like _.pullAll but with globs (wildcards)",
5
5
  "keywords": [
6
6
  "array",
@@ -31,17 +31,21 @@
31
31
  "email": "roy@codsen.com",
32
32
  "url": "https://codsen.com"
33
33
  },
34
- "main": "dist/array-pull-all-with-glob.cjs.js",
35
- "module": "dist/array-pull-all-with-glob.esm.js",
36
- "browser": "dist/array-pull-all-with-glob.umd.js",
34
+ "type": "module",
35
+ "exports": {
36
+ "script": "./dist/array-pull-all-with-glob.umd.js",
37
+ "default": "./dist/array-pull-all-with-glob.esm.js"
38
+ },
37
39
  "types": "types/index.d.ts",
38
40
  "scripts": {
39
41
  "build": "rollup -c",
40
- "esbuild": "node '../../scripts/esbuild.js'",
41
- "esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
42
42
  "ci_test": "npm run build && npm run format && tap --no-only --reporter=silent --output-file=testStats.md && npm run clean_cov",
43
+ "clean_cov": "../../scripts/leaveCoverageTotalOnly.js",
44
+ "clean_types": "../../scripts/cleanTypes.js",
43
45
  "dev": "rollup -c --dev",
44
46
  "devunittest": "npm run dev && tap --only -R 'base'",
47
+ "esbuild": "node '../../scripts/esbuild.js'",
48
+ "esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
45
49
  "format": "npm run lect && npm run prettier && npm run lint",
46
50
  "lect": "lect",
47
51
  "lint": "../../node_modules/eslint/bin/eslint.js . --ext .js --ext .ts --fix --config \"../../.eslintrc.json\" --quiet",
@@ -49,22 +53,22 @@
49
53
  "prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
50
54
  "republish": "npm publish || :",
51
55
  "tap": "tap",
52
- "tsc": "tsc",
53
56
  "pretest": "npm run build",
54
57
  "test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
55
58
  "test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
56
- "unittest": "./node_modules/.bin/tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf",
57
- "clean_cov": "../../scripts/leaveCoverageTotalOnly.js",
58
- "clean_types": "../../scripts/cleanTypes.js"
59
+ "tsc": "tsc",
60
+ "unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf"
59
61
  },
60
62
  "tap": {
63
+ "check-coverage": false,
61
64
  "coverage-report": [
62
65
  "json-summary",
63
66
  "text"
64
67
  ],
65
- "nyc-arg": [
66
- "--exclude=**/*.cjs.js",
67
- "--exclude=**/*.umd.js"
68
+ "node-arg": [
69
+ "--no-warnings",
70
+ "--experimental-loader",
71
+ "@istanbuljs/esm-loader-hook"
68
72
  ],
69
73
  "timeout": 0
70
74
  },
@@ -80,44 +84,48 @@
80
84
  }
81
85
  },
82
86
  "dependencies": {
83
- "@babel/runtime": "^7.14.0",
84
- "matcher": "^4.0.0"
87
+ "@babel/runtime": "^7.16.0",
88
+ "matcher": "^5.0.0"
85
89
  },
86
90
  "devDependencies": {
87
- "@babel/cli": "^7.14.3",
88
- "@babel/core": "^7.14.3",
89
- "@babel/node": "^7.14.2",
90
- "@babel/plugin-external-helpers": "^7.12.13",
91
- "@babel/plugin-proposal-class-properties": "^7.13.0",
92
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.2",
93
- "@babel/plugin-proposal-object-rest-spread": "^7.14.2",
94
- "@babel/plugin-proposal-optional-chaining": "^7.14.2",
95
- "@babel/plugin-transform-runtime": "^7.14.3",
96
- "@babel/preset-env": "^7.14.2",
97
- "@babel/preset-typescript": "^7.13.0",
98
- "@babel/register": "^7.13.16",
91
+ "@babel/cli": "^7.16.0",
92
+ "@babel/core": "^7.16.0",
93
+ "@babel/node": "^7.16.0",
94
+ "@babel/plugin-external-helpers": "^7.16.0",
95
+ "@babel/plugin-proposal-class-properties": "^7.16.0",
96
+ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
97
+ "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
98
+ "@babel/plugin-proposal-optional-chaining": "^7.16.0",
99
+ "@babel/plugin-transform-runtime": "^7.16.0",
100
+ "@babel/preset-env": "^7.16.0",
101
+ "@babel/preset-typescript": "^7.16.0",
102
+ "@babel/register": "^7.16.0",
103
+ "@istanbuljs/esm-loader-hook": "^0.1.2",
99
104
  "@rollup/plugin-babel": "^5.3.0",
100
- "@rollup/plugin-commonjs": "^19.0.0",
105
+ "@rollup/plugin-commonjs": "^21.0.1",
101
106
  "@rollup/plugin-json": "^4.1.0",
102
- "@rollup/plugin-node-resolve": "^13.0.0",
103
- "@rollup/plugin-strip": "^2.0.1",
104
- "@rollup/plugin-typescript": "^8.2.1",
105
- "@types/node": "^15.6.0",
106
- "@types/tap": "^15.0.1",
107
- "@typescript-eslint/eslint-plugin": "^4.24.0",
108
- "@typescript-eslint/parser": "^4.24.0",
109
- "core-js": "^3.12.1",
107
+ "@rollup/plugin-node-resolve": "^13.0.6",
108
+ "@rollup/plugin-strip": "^2.1.0",
109
+ "@rollup/plugin-typescript": "^8.3.0",
110
+ "@types/node": "^16.11.6",
111
+ "@types/tap": "^15.0.5",
112
+ "@typescript-eslint/eslint-plugin": "^5.2.0",
113
+ "@typescript-eslint/parser": "^5.2.0",
114
+ "core-js": "^3.19.0",
110
115
  "cross-env": "^7.0.3",
111
- "eslint": "^7.27.0",
112
- "lect": "^0.17.0",
113
- "rollup": "^2.49.0",
116
+ "eslint": "^8.1.0",
117
+ "lect": "^0.18.3",
118
+ "rollup": "^2.59.0",
114
119
  "rollup-plugin-ascii": "^0.0.3",
115
120
  "rollup-plugin-banner": "^0.2.1",
116
121
  "rollup-plugin-cleanup": "^3.2.1",
117
- "rollup-plugin-dts": "^3.0.1",
122
+ "rollup-plugin-dts": "^4.0.0",
118
123
  "rollup-plugin-terser": "^7.0.2",
119
- "tap": "^14.11.0",
120
- "tslib": "^2.2.0",
121
- "typescript": "^4.2.4"
124
+ "tap": "^15.0.10",
125
+ "tslib": "^2.3.1",
126
+ "typescript": "^4.4.4"
127
+ },
128
+ "engines": {
129
+ "node": ">=12"
122
130
  }
123
131
  }
@@ -1,48 +0,0 @@
1
- /**
2
- * @name array-pull-all-with-glob
3
- * @fileoverview Like _.pullAll but with globs (wildcards)
4
- * @version 5.1.0
5
- * @author Roy Revelt, Codsen Ltd
6
- * @license MIT
7
- * {@link https://codsen.com/os/array-pull-all-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 = "5.1.0";
23
-
24
- var version = version$1;
25
- function pull(originalInput, originalToBeRemoved, originalOpts) {
26
- if (!originalInput.length) {
27
- return [];
28
- }
29
- if (!originalInput.length || !originalToBeRemoved.length) {
30
- return Array.from(originalInput);
31
- }
32
- var toBeRemoved = typeof originalToBeRemoved === "string" ? [originalToBeRemoved] : Array.from(originalToBeRemoved);
33
- var defaults = {
34
- caseSensitive: true
35
- };
36
- var opts = _objectSpread__default['default'](_objectSpread__default['default']({}, defaults), originalOpts);
37
- var res = Array.from(originalInput).filter(function (originalVal) {
38
- return !toBeRemoved.some(function (remVal) {
39
- return matcher__default['default'].isMatch(originalVal, remVal, {
40
- caseSensitive: opts.caseSensitive
41
- });
42
- });
43
- });
44
- return res;
45
- }
46
-
47
- exports.pull = pull;
48
- exports.version = version;
@@ -1,172 +0,0 @@
1
- /**
2
- * @name array-pull-all-with-glob
3
- * @fileoverview Like _.pullAll but with globs (wildcards)
4
- * @version 5.1.0
5
- * @author Roy Revelt, Codsen Ltd
6
- * @license MIT
7
- * {@link https://codsen.com/os/array-pull-all-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.arrayPullAllWithGlob = {}));
14
- }(this, (function (exports) { 'use strict';
15
-
16
- var matcher$1 = {exports: {}};
17
-
18
- var escapeStringRegexp$1 = string => {
19
- if (typeof string !== 'string') {
20
- throw new TypeError('Expected a string');
21
- }
22
-
23
- // Escape characters with special meaning either inside or outside character sets.
24
- // 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.
25
- return string
26
- .replace(/[|\\{}()[\]^$+*?.]/g, '\\$&')
27
- .replace(/-/g, '\\x2d');
28
- };
29
-
30
- const escapeStringRegexp = escapeStringRegexp$1;
31
-
32
- const regexpCache = new Map();
33
-
34
- function sanitizeArray(input, inputName) {
35
- if (!Array.isArray(input)) {
36
- switch (typeof input) {
37
- case 'string':
38
- input = [input];
39
- break;
40
- case 'undefined':
41
- input = [];
42
- break;
43
- default:
44
- throw new TypeError(`Expected '${inputName}' to be a string or an array, but got a type of '${typeof input}'`);
45
- }
46
- }
47
-
48
- return input.filter(string => {
49
- if (typeof string !== 'string') {
50
- if (typeof string === 'undefined') {
51
- return false;
52
- }
53
-
54
- throw new TypeError(`Expected '${inputName}' to be an array of strings, but found a type of '${typeof string}' in the array`);
55
- }
56
-
57
- return true;
58
- });
59
- }
60
-
61
- function makeRegexp(pattern, options) {
62
- options = {
63
- caseSensitive: false,
64
- ...options
65
- };
66
-
67
- const cacheKey = pattern + JSON.stringify(options);
68
-
69
- if (regexpCache.has(cacheKey)) {
70
- return regexpCache.get(cacheKey);
71
- }
72
-
73
- const negated = pattern[0] === '!';
74
-
75
- if (negated) {
76
- pattern = pattern.slice(1);
77
- }
78
-
79
- pattern = escapeStringRegexp(pattern).replace(/\\\*/g, '[\\s\\S]*');
80
-
81
- const regexp = new RegExp(`^${pattern}$`, options.caseSensitive ? '' : 'i');
82
- regexp.negated = negated;
83
- regexpCache.set(cacheKey, regexp);
84
-
85
- return regexp;
86
- }
87
-
88
- matcher$1.exports = (inputs, patterns, options) => {
89
- inputs = sanitizeArray(inputs, 'inputs');
90
- patterns = sanitizeArray(patterns, 'patterns');
91
-
92
- if (patterns.length === 0) {
93
- return [];
94
- }
95
-
96
- const isFirstPatternNegated = patterns[0][0] === '!';
97
-
98
- patterns = patterns.map(pattern => makeRegexp(pattern, options));
99
-
100
- const result = [];
101
-
102
- for (const input of inputs) {
103
- // If first pattern is negated we include everything to match user expectation.
104
- let matches = isFirstPatternNegated;
105
-
106
- for (const pattern of patterns) {
107
- if (pattern.test(input)) {
108
- matches = !pattern.negated;
109
- }
110
- }
111
-
112
- if (matches) {
113
- result.push(input);
114
- }
115
- }
116
-
117
- return result;
118
- };
119
-
120
- matcher$1.exports.isMatch = (inputs, patterns, options) => {
121
- inputs = sanitizeArray(inputs, 'inputs');
122
- patterns = sanitizeArray(patterns, 'patterns');
123
-
124
- if (patterns.length === 0) {
125
- return false;
126
- }
127
-
128
- return inputs.some(input => {
129
- return patterns.every(pattern => {
130
- const regexp = makeRegexp(pattern, options);
131
- const matches = regexp.test(input);
132
- return regexp.negated ? !matches : matches;
133
- });
134
- });
135
- };
136
-
137
- var matcher = matcher$1.exports;
138
-
139
- var version$1 = "5.1.0";
140
-
141
- const version = version$1;
142
- /**
143
- * Like _.pullAll but with globs (wildcards)
144
- */
145
- function pull(originalInput, originalToBeRemoved, originalOpts) {
146
- // insurance
147
- if (!originalInput.length) {
148
- return [];
149
- }
150
- if (!originalInput.length || !originalToBeRemoved.length) {
151
- return Array.from(originalInput);
152
- }
153
- const toBeRemoved = typeof originalToBeRemoved === "string"
154
- ? [originalToBeRemoved]
155
- : Array.from(originalToBeRemoved);
156
- // opts are mirroring matcher's at the moment, can't promise that for the future
157
- const defaults = {
158
- caseSensitive: true,
159
- };
160
- const opts = { ...defaults, ...originalOpts };
161
- const res = Array.from(originalInput).filter((originalVal) => !toBeRemoved.some((remVal) => matcher.isMatch(originalVal, remVal, {
162
- caseSensitive: opts.caseSensitive,
163
- })));
164
- return res;
165
- }
166
-
167
- exports.pull = pull;
168
- exports.version = version;
169
-
170
- Object.defineProperty(exports, '__esModule', { value: true });
171
-
172
- })));