ranges-process-outside 5.0.2 → 5.0.6

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,12 +3,6 @@
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
- ## 5.0.1 (2021-09-13)
7
-
8
- ### Bug Fixes
9
-
10
- - bump TS and separate ESLint plugins away from this monorepo ([2e07d42](https://github.com/codsen/codsen/commit/2e07d424222b6ffedf5fb45c83ad453627ec2904))
11
-
12
6
  ## 5.0.0 (2021-09-09)
13
7
 
14
8
  ### Features
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2010-%YEAR% Roy Revelt and other contributors
3
+ Copyright (c) 2010-2021 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
@@ -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.2
4
+ * @version 5.0.6
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/ranges-process-outside/}
@@ -11,47 +11,51 @@ 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.2";
14
+ var version$1 = "5.0.6";
15
15
 
16
16
  const version = version$1;
17
17
  function rProcessOutside(originalStr, originalRanges, cb, skipChecks = false) {
18
- if (typeof originalStr !== "string") {
19
- if (originalStr === undefined) {
20
- throw new Error(`ranges-process-outside: [THROW_ID_01] the first input argument must be string! It's missing currently (undefined)!`);
21
- } else {
22
- throw new Error(`ranges-process-outside: [THROW_ID_02] the first input argument must be string! It was given as:\n${JSON.stringify(originalStr, null, 4)} (type ${typeof originalStr})`);
18
+ if (typeof originalStr !== "string") {
19
+ if (originalStr === undefined) {
20
+ throw new Error(`ranges-process-outside: [THROW_ID_01] the first input argument must be string! It's missing currently (undefined)!`);
21
+ }
22
+ else {
23
+ throw new Error(`ranges-process-outside: [THROW_ID_02] the first input argument must be string! It was given as:\n${JSON.stringify(originalStr, null, 4)} (type ${typeof originalStr})`);
24
+ }
25
+ }
26
+ if (originalRanges &&
27
+ (!Array.isArray(originalRanges) ||
28
+ (originalRanges.length && !Array.isArray(originalRanges[0])))) {
29
+ 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(originalRanges, null, 4)} (type ${typeof originalRanges})`);
30
+ }
31
+ if (typeof cb !== "function") {
32
+ throw new Error(`ranges-process-outside: [THROW_ID_04] the third input argument must be a function! It was given as:\n${JSON.stringify(cb, null, 4)} (type ${typeof cb})`);
23
33
  }
24
- }
25
- if (originalRanges && (!Array.isArray(originalRanges) || originalRanges.length && !Array.isArray(originalRanges[0]))) {
26
- 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(originalRanges, null, 4)} (type ${typeof originalRanges})`);
27
- }
28
- if (typeof cb !== "function") {
29
- throw new Error(`ranges-process-outside: [THROW_ID_04] the third input argument must be a function! It was given as:\n${JSON.stringify(cb, null, 4)} (type ${typeof cb})`);
30
- }
31
- function iterator(str, arrOfArrays) {
32
- (arrOfArrays || []).forEach(([fromIdx, toIdx]) => {
33
- for (let i = fromIdx; i < toIdx; i++) {
34
- const charLength = runes(str.slice(i))[0].length;
35
- cb(i, i + charLength, offsetValue => {
36
- /* istanbul ignore else */
37
- if (offsetValue != null) {
38
- i += offsetValue;
39
- }
34
+ function iterator(str, arrOfArrays) {
35
+ (arrOfArrays || []).forEach(([fromIdx, toIdx]) => {
36
+ for (let i = fromIdx; i < toIdx; i++) {
37
+ const charLength = runes(str.slice(i))[0].length;
38
+ cb(i, i + charLength, (offsetValue) => {
39
+ /* istanbul ignore else */
40
+ if (offsetValue != null) {
41
+ i += offsetValue;
42
+ }
43
+ });
44
+ if (charLength && charLength > 1) {
45
+ i += charLength - 1;
46
+ }
47
+ }
40
48
  });
41
- if (charLength && charLength > 1) {
42
- i += charLength - 1;
43
- }
44
- }
45
- });
46
- }
47
- if (originalRanges && originalRanges.length) {
48
- const temp = rCrop(rInvert(skipChecks ? originalRanges : originalRanges, originalStr.length, {
49
- skipChecks: !!skipChecks
50
- }), originalStr.length);
51
- iterator(originalStr, temp);
52
- } else {
53
- iterator(originalStr, [[0, originalStr.length]]);
54
- }
49
+ }
50
+ if (originalRanges && originalRanges.length) {
51
+ const temp = rCrop(rInvert(skipChecks ? originalRanges : originalRanges, originalStr.length, {
52
+ skipChecks: !!skipChecks,
53
+ }), originalStr.length);
54
+ iterator(originalStr, temp);
55
+ }
56
+ else {
57
+ iterator(originalStr, [[0, originalStr.length]]);
58
+ }
55
59
  }
56
60
 
57
61
  export { rProcessOutside, version };
@@ -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.2
4
+ * @version 5.0.6
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.2
14
+ * @version 5.0.6
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.2
22
+ * @version 8.0.6
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.2
30
+ * @version 5.0.6
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.2
38
+ * @version 5.0.6
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.2",Object.defineProperty(e,"__esModule",{value:!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.6",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.2",
3
+ "version": "5.0.6",
4
4
  "description": "Iterate string considering ranges, as if they were already applied",
5
5
  "keywords": [
6
6
  "array",
@@ -29,9 +29,10 @@
29
29
  "types": "types/index.d.ts",
30
30
  "scripts": {
31
31
  "build": "rollup -c",
32
- "esbuild": "node '../../scripts/esbuild.js'",
33
- "esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
34
- "ci_test": "npm run build && npm run format && tap --no-only --reporter=silent --output-file=testStats.md && npm run clean_cov",
32
+ "build:esbuild": "node '../../scripts/esbuild.js'",
33
+ "build:esbuild:dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
34
+ "ci_test": "npm run build && npm run format && tap --no-only --reporter=silent",
35
+ "clean_types": "../../scripts/cleanTypes.js",
35
36
  "dev": "rollup -c --dev",
36
37
  "devunittest": "npm run dev && tap --only -R 'base'",
37
38
  "format": "npm run lect && npm run prettier && npm run lint",
@@ -41,20 +42,15 @@
41
42
  "prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
42
43
  "republish": "npm publish || :",
43
44
  "tap": "tap",
44
- "tsc": "tsc",
45
45
  "pretest": "npm run build",
46
- "test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
46
+ "test": "npm run test:ci && npm run perf",
47
+ "test:ci": "npm run unittest && npm run test:examples && npm run format",
47
48
  "test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
48
- "unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf",
49
- "clean_cov": "../../scripts/leaveCoverageTotalOnly.js",
50
- "clean_types": "../../scripts/cleanTypes.js"
49
+ "tsc": "tsc",
50
+ "unittest": "tap --no-only --reporter=terse && tsc -p tsconfig.json --noEmit"
51
51
  },
52
52
  "tap": {
53
53
  "check-coverage": false,
54
- "coverage-report": [
55
- "json-summary",
56
- "text"
57
- ],
58
54
  "node-arg": [
59
55
  "--no-warnings",
60
56
  "--experimental-loader",
@@ -76,51 +72,51 @@
76
72
  }
77
73
  },
78
74
  "dependencies": {
79
- "@babel/runtime": "^7.15.4",
80
- "ranges-crop": "^5.0.2",
81
- "ranges-invert": "^5.0.2",
75
+ "@babel/runtime": "^7.16.3",
76
+ "ranges-crop": "^5.0.6",
77
+ "ranges-invert": "^5.0.6",
82
78
  "runes": "^0.4.3"
83
79
  },
84
80
  "devDependencies": {
85
- "@babel/cli": "^7.15.4",
86
- "@babel/core": "^7.15.5",
87
- "@babel/node": "^7.15.4",
88
- "@babel/plugin-external-helpers": "^7.14.5",
89
- "@babel/plugin-proposal-class-properties": "^7.14.5",
90
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.5",
91
- "@babel/plugin-proposal-object-rest-spread": "^7.15.6",
92
- "@babel/plugin-proposal-optional-chaining": "^7.14.5",
93
- "@babel/plugin-transform-runtime": "^7.15.0",
94
- "@babel/preset-env": "^7.15.6",
95
- "@babel/preset-typescript": "^7.15.0",
96
- "@babel/register": "^7.15.3",
81
+ "@babel/cli": "^7.16.0",
82
+ "@babel/core": "^7.16.0",
83
+ "@babel/node": "^7.16.0",
84
+ "@babel/plugin-external-helpers": "^7.16.0",
85
+ "@babel/plugin-proposal-class-properties": "^7.16.0",
86
+ "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
87
+ "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
88
+ "@babel/plugin-proposal-optional-chaining": "^7.16.0",
89
+ "@babel/plugin-transform-runtime": "^7.16.4",
90
+ "@babel/preset-env": "^7.16.4",
91
+ "@babel/preset-typescript": "^7.16.0",
92
+ "@babel/register": "^7.16.0",
97
93
  "@istanbuljs/esm-loader-hook": "^0.1.2",
98
94
  "@rollup/plugin-babel": "^5.3.0",
99
- "@rollup/plugin-commonjs": "^20.0.0",
95
+ "@rollup/plugin-commonjs": "^21.0.1",
100
96
  "@rollup/plugin-json": "^4.1.0",
101
- "@rollup/plugin-node-resolve": "^13.0.4",
97
+ "@rollup/plugin-node-resolve": "^13.0.6",
102
98
  "@rollup/plugin-strip": "^2.1.0",
103
- "@rollup/plugin-typescript": "^8.2.5",
104
- "@types/node": "^16.9.1",
99
+ "@rollup/plugin-typescript": "^8.3.0",
100
+ "@types/node": "^16.11.9",
105
101
  "@types/runes": "^0.4.1",
106
102
  "@types/tap": "^15.0.5",
107
- "@typescript-eslint/eslint-plugin": "^4.31.0",
108
- "@typescript-eslint/parser": "^4.31.0",
109
- "core-js": "^3.17.3",
103
+ "@typescript-eslint/eslint-plugin": "^5.4.0",
104
+ "@typescript-eslint/parser": "^5.4.0",
105
+ "core-js": "^3.19.1",
110
106
  "cross-env": "^7.0.3",
111
- "eslint": "^7.32.0",
112
- "lect": "^0.18.2",
113
- "rollup": "^2.56.3",
107
+ "eslint": "^8.3.0",
108
+ "lect": "^0.18.6",
109
+ "rollup": "^2.60.0",
114
110
  "rollup-plugin-ascii": "^0.0.3",
115
111
  "rollup-plugin-banner": "^0.2.1",
116
112
  "rollup-plugin-cleanup": "^3.2.1",
117
- "rollup-plugin-dts": "^4.0.0",
113
+ "rollup-plugin-dts": "^4.0.1",
118
114
  "rollup-plugin-terser": "^7.0.2",
119
- "tap": "^15.0.9",
115
+ "tap": "^15.1.2",
120
116
  "tslib": "^2.3.1",
121
- "typescript": "^4.4.3"
117
+ "typescript": "^4.5.2"
122
118
  },
123
119
  "engines": {
124
- "node": ">=12"
120
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
125
121
  }
126
122
  }