ranges-process-outside 5.0.6 → 5.0.7
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name ranges-process-outside
|
|
3
3
|
* @fileoverview Iterate string considering ranges, as if they were already applied
|
|
4
|
-
* @version 5.0.
|
|
4
|
+
* @version 5.0.7
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/ranges-process-outside/}
|
|
@@ -11,7 +11,7 @@ import runes from 'runes';
|
|
|
11
11
|
import { rInvert } from 'ranges-invert';
|
|
12
12
|
import { rCrop } from 'ranges-crop';
|
|
13
13
|
|
|
14
|
-
var version$1 = "5.0.
|
|
14
|
+
var version$1 = "5.0.7";
|
|
15
15
|
|
|
16
16
|
const version = version$1;
|
|
17
17
|
function rProcessOutside(originalStr, originalRanges, cb, skipChecks = false) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name ranges-process-outside
|
|
3
3
|
* @fileoverview Iterate string considering ranges, as if they were already applied
|
|
4
|
-
* @version 5.0.
|
|
4
|
+
* @version 5.0.7
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/ranges-process-outside/}
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
/**
|
|
12
12
|
* @name ranges-sort
|
|
13
13
|
* @fileoverview Sort string index ranges
|
|
14
|
-
* @version 5.0.
|
|
14
|
+
* @version 5.0.7
|
|
15
15
|
* @author Roy Revelt, Codsen Ltd
|
|
16
16
|
* @license MIT
|
|
17
17
|
* {@link https://codsen.com/os/ranges-sort/}
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
/**
|
|
20
20
|
* @name ranges-merge
|
|
21
21
|
* @fileoverview Merge and sort string index ranges
|
|
22
|
-
* @version 8.0.
|
|
22
|
+
* @version 8.0.7
|
|
23
23
|
* @author Roy Revelt, Codsen Ltd
|
|
24
24
|
* @license MIT
|
|
25
25
|
* {@link https://codsen.com/os/ranges-merge/}
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
/**
|
|
28
28
|
* @name ranges-crop
|
|
29
29
|
* @fileoverview Crop array of ranges when they go beyond the reference string's length
|
|
30
|
-
* @version 5.0.
|
|
30
|
+
* @version 5.0.7
|
|
31
31
|
* @author Roy Revelt, Codsen Ltd
|
|
32
32
|
* @license MIT
|
|
33
33
|
* {@link https://codsen.com/os/ranges-crop/}
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
/**
|
|
36
36
|
* @name ranges-invert
|
|
37
37
|
* @fileoverview Invert string index ranges
|
|
38
|
-
* @version 5.0.
|
|
38
|
+
* @version 5.0.7
|
|
39
39
|
* @author Roy Revelt, Codsen Ltd
|
|
40
40
|
* @license MIT
|
|
41
41
|
* {@link https://codsen.com/os/ranges-invert/}
|
|
42
|
-
*/e.rProcessOutside=function(e,r,n,t=!1){if("string"!=typeof e)throw void 0===e?new Error("ranges-process-outside: [THROW_ID_01] the first input argument must be string! It's missing currently (undefined)!"):new Error(`ranges-process-outside: [THROW_ID_02] the first input argument must be string! It was given as:\n${JSON.stringify(e,null,4)} (type ${typeof e})`);if(r&&(!Array.isArray(r)||r.length&&!Array.isArray(r[0])))throw new Error(`ranges-process-outside: [THROW_ID_03] the second input argument must be array of ranges or null! It was given as:\n${JSON.stringify(r,null,4)} (type ${typeof r})`);if("function"!=typeof n)throw new Error(`ranges-process-outside: [THROW_ID_04] the third input argument must be a function! It was given as:\n${JSON.stringify(n,null,4)} (type ${typeof n})`);function s(e,r){(r||[]).forEach((([r,t])=>{for(let s=r;s<t;s++){const r=c(e.slice(s))[0].length;n(s,s+r,(e=>{null!=e&&(s+=e)})),r&&r>1&&(s+=r-1)}}))}if(r&&r.length){s(e,b(function(e,r,n){if(!Array.isArray(e)&&null!==e)throw new TypeError(`ranges-invert: [THROW_ID_01] Input's first argument must be an array, consisting of range arrays! Currently its type is: ${typeof e}, equal to: ${JSON.stringify(e,null,4)}`);if(!Number.isInteger(r)||r<0)throw new TypeError(`ranges-invert: [THROW_ID_02] Input's second argument must be a natural number or zero (coming from String.length)! Currently its type is: ${typeof r}, equal to: ${JSON.stringify(r,null,4)}`);if(Array.isArray(e)&&"number"==typeof e[0]&&"number"==typeof e[1])throw new TypeError(`ranges-invert: [THROW_ID_07] The first argument should be AN ARRAY OF RANGES, not a single range! Currently arrOfRanges = ${JSON.stringify(e,null,0)}!`);if(!Array.isArray(e)||!e.filter((e=>Array.isArray(e)&&e[0]!==e[1])).length||!r)return r?[[0,r]]:null;const t={strictlyTwoElementsInRangeArrays:!1,skipChecks:!1,...n};let s,o,i=0;if(!t.skipChecks&&t.strictlyTwoElementsInRangeArrays&&!e.filter((e=>e)).every(((e,r)=>2===e.length||(i=r,s=e.length,!1))))throw new TypeError(`ranges-invert: [THROW_ID_04] Because opts.strictlyTwoElementsInRangeArrays was enabled, all ranges must be strictly two-element-long. However, the ${i}th range (${JSON.stringify(e[i],null,0)}) has not two but ${s} elements!`);if(!t.skipChecks&&!e.every(((e,r)=>!(!Number.isInteger(e[0])||e[0]<0||!Number.isInteger(e[1])||e[1]<0)||(i=r,!1))))throw new TypeError(`ranges-invert: [THROW_ID_05] The first argument should be AN ARRAY OF ARRAYS! Each sub-array means string slice indexes. In our case, here ${i+1}th range (${JSON.stringify(e[i],null,0)}) does not consist of only natural numbers!`);return o=t.skipChecks?e.filter((e=>e[0]!==e[1])):w(e.filter((e=>e[0]!==e[1]))),b(o.reduce(((e,n,s,o)=>{const i=[];0===s&&0!==o[0][0]&&i.push([0,o[0][0]]);const a=s<o.length-1?o[s+1][0]:r;if(n[1]!==a){if(t.skipChecks&&n[1]>a)throw new TypeError(`ranges-invert: [THROW_ID_08] The checking (opts.skipChecks) is off and input ranges were not sorted! We nearly wrote range [${n[1]}, ${a}] which is backwards. For investigation, whole ranges array is:\n${JSON.stringify(o,null,0)}`);i.push([n[1],a])}return e.concat(i)}),[]),r)}(r,e.length,{skipChecks:!!t}),e.length))}else s(e,[[0,e.length]])},e.version="5.0.
|
|
42
|
+
*/e.rProcessOutside=function(e,r,n,t=!1){if("string"!=typeof e)throw void 0===e?new Error("ranges-process-outside: [THROW_ID_01] the first input argument must be string! It's missing currently (undefined)!"):new Error(`ranges-process-outside: [THROW_ID_02] the first input argument must be string! It was given as:\n${JSON.stringify(e,null,4)} (type ${typeof e})`);if(r&&(!Array.isArray(r)||r.length&&!Array.isArray(r[0])))throw new Error(`ranges-process-outside: [THROW_ID_03] the second input argument must be array of ranges or null! It was given as:\n${JSON.stringify(r,null,4)} (type ${typeof r})`);if("function"!=typeof n)throw new Error(`ranges-process-outside: [THROW_ID_04] the third input argument must be a function! It was given as:\n${JSON.stringify(n,null,4)} (type ${typeof n})`);function s(e,r){(r||[]).forEach((([r,t])=>{for(let s=r;s<t;s++){const r=c(e.slice(s))[0].length;n(s,s+r,(e=>{null!=e&&(s+=e)})),r&&r>1&&(s+=r-1)}}))}if(r&&r.length){s(e,b(function(e,r,n){if(!Array.isArray(e)&&null!==e)throw new TypeError(`ranges-invert: [THROW_ID_01] Input's first argument must be an array, consisting of range arrays! Currently its type is: ${typeof e}, equal to: ${JSON.stringify(e,null,4)}`);if(!Number.isInteger(r)||r<0)throw new TypeError(`ranges-invert: [THROW_ID_02] Input's second argument must be a natural number or zero (coming from String.length)! Currently its type is: ${typeof r}, equal to: ${JSON.stringify(r,null,4)}`);if(Array.isArray(e)&&"number"==typeof e[0]&&"number"==typeof e[1])throw new TypeError(`ranges-invert: [THROW_ID_07] The first argument should be AN ARRAY OF RANGES, not a single range! Currently arrOfRanges = ${JSON.stringify(e,null,0)}!`);if(!Array.isArray(e)||!e.filter((e=>Array.isArray(e)&&e[0]!==e[1])).length||!r)return r?[[0,r]]:null;const t={strictlyTwoElementsInRangeArrays:!1,skipChecks:!1,...n};let s,o,i=0;if(!t.skipChecks&&t.strictlyTwoElementsInRangeArrays&&!e.filter((e=>e)).every(((e,r)=>2===e.length||(i=r,s=e.length,!1))))throw new TypeError(`ranges-invert: [THROW_ID_04] Because opts.strictlyTwoElementsInRangeArrays was enabled, all ranges must be strictly two-element-long. However, the ${i}th range (${JSON.stringify(e[i],null,0)}) has not two but ${s} elements!`);if(!t.skipChecks&&!e.every(((e,r)=>!(!Number.isInteger(e[0])||e[0]<0||!Number.isInteger(e[1])||e[1]<0)||(i=r,!1))))throw new TypeError(`ranges-invert: [THROW_ID_05] The first argument should be AN ARRAY OF ARRAYS! Each sub-array means string slice indexes. In our case, here ${i+1}th range (${JSON.stringify(e[i],null,0)}) does not consist of only natural numbers!`);return o=t.skipChecks?e.filter((e=>e[0]!==e[1])):w(e.filter((e=>e[0]!==e[1]))),b(o.reduce(((e,n,s,o)=>{const i=[];0===s&&0!==o[0][0]&&i.push([0,o[0][0]]);const a=s<o.length-1?o[s+1][0]:r;if(n[1]!==a){if(t.skipChecks&&n[1]>a)throw new TypeError(`ranges-invert: [THROW_ID_08] The checking (opts.skipChecks) is off and input ranges were not sorted! We nearly wrote range [${n[1]}, ${a}] which is backwards. For investigation, whole ranges array is:\n${JSON.stringify(o,null,0)}`);i.push([n[1],a])}return e.concat(i)}),[]),r)}(r,e.length,{skipChecks:!!t}),e.length))}else s(e,[[0,e.length]])},e.version="5.0.7",Object.defineProperty(e,"__esModule",{value:!0})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ranges-process-outside",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.7",
|
|
4
4
|
"description": "Iterate string considering ranges, as if they were already applied",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"array",
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
},
|
|
74
74
|
"dependencies": {
|
|
75
75
|
"@babel/runtime": "^7.16.3",
|
|
76
|
-
"ranges-crop": "^5.0.
|
|
77
|
-
"ranges-invert": "^5.0.
|
|
76
|
+
"ranges-crop": "^5.0.7",
|
|
77
|
+
"ranges-invert": "^5.0.7",
|
|
78
78
|
"runes": "^0.4.3"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
@@ -97,22 +97,22 @@
|
|
|
97
97
|
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
98
98
|
"@rollup/plugin-strip": "^2.1.0",
|
|
99
99
|
"@rollup/plugin-typescript": "^8.3.0",
|
|
100
|
-
"@types/node": "^16.11.
|
|
100
|
+
"@types/node": "^16.11.10",
|
|
101
101
|
"@types/runes": "^0.4.1",
|
|
102
102
|
"@types/tap": "^15.0.5",
|
|
103
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
104
|
-
"@typescript-eslint/parser": "^5.
|
|
105
|
-
"core-js": "^3.19.
|
|
103
|
+
"@typescript-eslint/eslint-plugin": "^5.5.0",
|
|
104
|
+
"@typescript-eslint/parser": "^5.5.0",
|
|
105
|
+
"core-js": "^3.19.2",
|
|
106
106
|
"cross-env": "^7.0.3",
|
|
107
107
|
"eslint": "^8.3.0",
|
|
108
|
-
"lect": "^0.18.
|
|
109
|
-
"rollup": "^2.60.
|
|
108
|
+
"lect": "^0.18.7",
|
|
109
|
+
"rollup": "^2.60.1",
|
|
110
110
|
"rollup-plugin-ascii": "^0.0.3",
|
|
111
111
|
"rollup-plugin-banner": "^0.2.1",
|
|
112
112
|
"rollup-plugin-cleanup": "^3.2.1",
|
|
113
113
|
"rollup-plugin-dts": "^4.0.1",
|
|
114
114
|
"rollup-plugin-terser": "^7.0.2",
|
|
115
|
-
"tap": "^15.1.
|
|
115
|
+
"tap": "^15.1.5",
|
|
116
116
|
"tslib": "^2.3.1",
|
|
117
117
|
"typescript": "^4.5.2"
|
|
118
118
|
},
|