string-range-expander 3.0.2 → 3.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,20 @@
|
|
|
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
|
+
## 3.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
|
+
|
|
6
20
|
## 3.0.1 (2021-09-13)
|
|
7
21
|
|
|
8
22
|
### Bug Fixes
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name string-range-expander
|
|
3
3
|
* @fileoverview Expands string index ranges within whitespace boundaries until letters are met
|
|
4
|
-
* @version 3.0.
|
|
4
|
+
* @version 3.0.3
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/string-range-expander/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
var version$1 = "3.0.
|
|
10
|
+
var version$1 = "3.0.3";
|
|
11
11
|
|
|
12
12
|
const version = version$1;
|
|
13
13
|
const defaults = {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name string-range-expander
|
|
3
3
|
* @fileoverview Expands string index ranges within whitespace boundaries until letters are met
|
|
4
|
-
* @version 3.0.
|
|
4
|
+
* @version 3.0.3
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/string-range-expander/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((e="undefined"!=typeof globalThis?globalThis:e||self).stringRangeExpander={})}(this,(function(e){"use strict";const i={str:"",from:0,to:0,ifLeftSideIncludesThisThenCropTightly:"",ifLeftSideIncludesThisCropItToo:"",ifRightSideIncludesThisThenCropTightly:"",ifRightSideIncludesThisCropItToo:"",extendToOneSide:!1,wipeAllWhitespaceOnLeft:!1,wipeAllWhitespaceOnRight:!1,addSingleSpaceToPreventAccidentalConcatenation:!1};e.defaults=i,e.expander=function(e){const t=/^[0-9a-zA-Z]+$/;function n(e){return!(!e||"string"!=typeof e)&&!e.trim()}function r(e){return"string"==typeof e}if(!e||"object"!=typeof e||Array.isArray(e)){let i;throw i=void 0===e?"but it is missing completely.":null===e?"but it was given as null.":`but it was given as ${typeof e}, equal to:\n${JSON.stringify(e,null,4)}.`,new Error(`string-range-expander: [THROW_ID_01] Input must be a plain object ${i}`)}if("object"==typeof e&&null!==e&&!Array.isArray(e)&&!Object.keys(e).length)throw new Error("string-range-expander: [THROW_ID_02] Input must be a plain object but it was given as a plain object without any keys.");if("number"!=typeof e.from)throw new Error(`string-range-expander: [THROW_ID_03] The input's "from" value opts.from, is not a number! Currently it's given as ${typeof e.from}, equal to ${JSON.stringify(e.from,null,0)}`);if("number"!=typeof e.to)throw new Error(`string-range-expander: [THROW_ID_04] The input's "to" value opts.to, is not a number! Currently it's given as ${typeof e.to}, equal to ${JSON.stringify(e.to,null,0)}`);if(e&&e.str&&!e.str[e.from]&&e.from!==e.to)throw new Error(`string-range-expander: [THROW_ID_05] The given input string opts.str ("${e.str}") must contain the character at index "from" ("${e.from}")`);if(e&&e.str&&!e.str[e.to-1])throw new Error(`string-range-expander: [THROW_ID_06] The given input string, opts.str ("${e.str}") must contain the character at index before "to" ("${e.to-1}")`);if(e.from>e.to)throw new Error(`string-range-expander: [THROW_ID_07] The given "from" index, "${e.from}" is greater than "to" index, "${e.to}". That's wrong!`);if(r(e.extendToOneSide)&&"left"!==e.extendToOneSide&&"right"!==e.extendToOneSide||!r(e.extendToOneSide)&&void 0!==e.extendToOneSide&&!1!==e.extendToOneSide)throw new Error(`string-range-expander: [THROW_ID_08] The opts.extendToOneSide value is not recogniseable! It's set to: "${e.extendToOneSide}" (${typeof e.extendToOneSide}). It has to be either Boolean "false" or strings "left" or "right"`);const o={...i,...e};if(Array.isArray(o.ifLeftSideIncludesThisThenCropTightly)){let e,i;if(!o.ifLeftSideIncludesThisThenCropTightly.every(((t,n)=>!!r(t)||(e=n,i=t,!1))))throw new Error(`string-range-expander: [THROW_ID_09] The opts.ifLeftSideIncludesThisThenCropTightly was set to an array:\n${JSON.stringify(o.ifLeftSideIncludesThisThenCropTightly,null,4)}. Now, that array contains not only string elements. For example, an element at index ${e} is of a type ${typeof i} (equal to ${JSON.stringify(i,null,0)}).`);o.ifLeftSideIncludesThisThenCropTightly=o.ifLeftSideIncludesThisThenCropTightly.join("")}const s=o.str;let l=o.from,d=o.to;if("right"!==o.extendToOneSide&&(n(s[l-1])&&(n(s[l-2])||o.ifLeftSideIncludesThisCropItToo.includes(s[l-2]))||s[l-1]&&o.ifLeftSideIncludesThisCropItToo.includes(s[l-1])||o.wipeAllWhitespaceOnLeft&&n(s[l-1])))for(let e=l;e--;)if(!o.ifLeftSideIncludesThisCropItToo.includes(s[e])){if(s[e].trim()){l=o.wipeAllWhitespaceOnLeft||o.ifLeftSideIncludesThisCropItToo.includes(s[e+1])?e+1:e+2;break}if(0===e){l=o.wipeAllWhitespaceOnLeft?0:1;break}}if("left"!==o.extendToOneSide&&(n(s[d])&&(o.wipeAllWhitespaceOnRight||n(s[d+1]))||o.ifRightSideIncludesThisCropItToo.includes(s[d])))for(let e=d,i=s.length;e<i;e++)if(!o.ifRightSideIncludesThisCropItToo.includes(s[e])&&(s[e]&&s[e].trim()||void 0===s[e])){d=o.wipeAllWhitespaceOnRight||o.ifRightSideIncludesThisCropItToo.includes(s[e-1])?e:e-1;break}return("right"!==o.extendToOneSide&&r(o.ifLeftSideIncludesThisThenCropTightly)&&o.ifLeftSideIncludesThisThenCropTightly&&(s[l-2]&&o.ifLeftSideIncludesThisThenCropTightly.includes(s[l-2])||s[l-1]&&o.ifLeftSideIncludesThisThenCropTightly.includes(s[l-1]))||"left"!==o.extendToOneSide&&r(o.ifRightSideIncludesThisThenCropTightly)&&o.ifRightSideIncludesThisThenCropTightly&&(s[d+1]&&o.ifRightSideIncludesThisThenCropTightly.includes(s[d+1])||s[d]&&o.ifRightSideIncludesThisThenCropTightly.includes(s[d])))&&("right"!==o.extendToOneSide&&n(s[l-1])&&!o.wipeAllWhitespaceOnLeft&&(l-=1),"left"!==o.extendToOneSide&&n(s[d])&&!o.wipeAllWhitespaceOnRight&&(d+=1)),o.addSingleSpaceToPreventAccidentalConcatenation&&s[l-1]&&s[l-1].trim()&&s[d]&&s[d].trim()&&(!o.ifLeftSideIncludesThisThenCropTightly&&!o.ifRightSideIncludesThisThenCropTightly||o.ifLeftSideIncludesThisThenCropTightly&&!o.ifLeftSideIncludesThisThenCropTightly.includes(s[l-1])||!(!o.ifRightSideIncludesThisThenCropTightly||s[d]&&o.ifRightSideIncludesThisThenCropTightly.includes(s[d])))&&(t.test(s[l-1])||t.test(s[d]))?[l,d," "]:[l,d]},e.version="3.0.
|
|
10
|
+
!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((e="undefined"!=typeof globalThis?globalThis:e||self).stringRangeExpander={})}(this,(function(e){"use strict";const i={str:"",from:0,to:0,ifLeftSideIncludesThisThenCropTightly:"",ifLeftSideIncludesThisCropItToo:"",ifRightSideIncludesThisThenCropTightly:"",ifRightSideIncludesThisCropItToo:"",extendToOneSide:!1,wipeAllWhitespaceOnLeft:!1,wipeAllWhitespaceOnRight:!1,addSingleSpaceToPreventAccidentalConcatenation:!1};e.defaults=i,e.expander=function(e){const t=/^[0-9a-zA-Z]+$/;function n(e){return!(!e||"string"!=typeof e)&&!e.trim()}function r(e){return"string"==typeof e}if(!e||"object"!=typeof e||Array.isArray(e)){let i;throw i=void 0===e?"but it is missing completely.":null===e?"but it was given as null.":`but it was given as ${typeof e}, equal to:\n${JSON.stringify(e,null,4)}.`,new Error(`string-range-expander: [THROW_ID_01] Input must be a plain object ${i}`)}if("object"==typeof e&&null!==e&&!Array.isArray(e)&&!Object.keys(e).length)throw new Error("string-range-expander: [THROW_ID_02] Input must be a plain object but it was given as a plain object without any keys.");if("number"!=typeof e.from)throw new Error(`string-range-expander: [THROW_ID_03] The input's "from" value opts.from, is not a number! Currently it's given as ${typeof e.from}, equal to ${JSON.stringify(e.from,null,0)}`);if("number"!=typeof e.to)throw new Error(`string-range-expander: [THROW_ID_04] The input's "to" value opts.to, is not a number! Currently it's given as ${typeof e.to}, equal to ${JSON.stringify(e.to,null,0)}`);if(e&&e.str&&!e.str[e.from]&&e.from!==e.to)throw new Error(`string-range-expander: [THROW_ID_05] The given input string opts.str ("${e.str}") must contain the character at index "from" ("${e.from}")`);if(e&&e.str&&!e.str[e.to-1])throw new Error(`string-range-expander: [THROW_ID_06] The given input string, opts.str ("${e.str}") must contain the character at index before "to" ("${e.to-1}")`);if(e.from>e.to)throw new Error(`string-range-expander: [THROW_ID_07] The given "from" index, "${e.from}" is greater than "to" index, "${e.to}". That's wrong!`);if(r(e.extendToOneSide)&&"left"!==e.extendToOneSide&&"right"!==e.extendToOneSide||!r(e.extendToOneSide)&&void 0!==e.extendToOneSide&&!1!==e.extendToOneSide)throw new Error(`string-range-expander: [THROW_ID_08] The opts.extendToOneSide value is not recogniseable! It's set to: "${e.extendToOneSide}" (${typeof e.extendToOneSide}). It has to be either Boolean "false" or strings "left" or "right"`);const o={...i,...e};if(Array.isArray(o.ifLeftSideIncludesThisThenCropTightly)){let e,i;if(!o.ifLeftSideIncludesThisThenCropTightly.every(((t,n)=>!!r(t)||(e=n,i=t,!1))))throw new Error(`string-range-expander: [THROW_ID_09] The opts.ifLeftSideIncludesThisThenCropTightly was set to an array:\n${JSON.stringify(o.ifLeftSideIncludesThisThenCropTightly,null,4)}. Now, that array contains not only string elements. For example, an element at index ${e} is of a type ${typeof i} (equal to ${JSON.stringify(i,null,0)}).`);o.ifLeftSideIncludesThisThenCropTightly=o.ifLeftSideIncludesThisThenCropTightly.join("")}const s=o.str;let l=o.from,d=o.to;if("right"!==o.extendToOneSide&&(n(s[l-1])&&(n(s[l-2])||o.ifLeftSideIncludesThisCropItToo.includes(s[l-2]))||s[l-1]&&o.ifLeftSideIncludesThisCropItToo.includes(s[l-1])||o.wipeAllWhitespaceOnLeft&&n(s[l-1])))for(let e=l;e--;)if(!o.ifLeftSideIncludesThisCropItToo.includes(s[e])){if(s[e].trim()){l=o.wipeAllWhitespaceOnLeft||o.ifLeftSideIncludesThisCropItToo.includes(s[e+1])?e+1:e+2;break}if(0===e){l=o.wipeAllWhitespaceOnLeft?0:1;break}}if("left"!==o.extendToOneSide&&(n(s[d])&&(o.wipeAllWhitespaceOnRight||n(s[d+1]))||o.ifRightSideIncludesThisCropItToo.includes(s[d])))for(let e=d,i=s.length;e<i;e++)if(!o.ifRightSideIncludesThisCropItToo.includes(s[e])&&(s[e]&&s[e].trim()||void 0===s[e])){d=o.wipeAllWhitespaceOnRight||o.ifRightSideIncludesThisCropItToo.includes(s[e-1])?e:e-1;break}return("right"!==o.extendToOneSide&&r(o.ifLeftSideIncludesThisThenCropTightly)&&o.ifLeftSideIncludesThisThenCropTightly&&(s[l-2]&&o.ifLeftSideIncludesThisThenCropTightly.includes(s[l-2])||s[l-1]&&o.ifLeftSideIncludesThisThenCropTightly.includes(s[l-1]))||"left"!==o.extendToOneSide&&r(o.ifRightSideIncludesThisThenCropTightly)&&o.ifRightSideIncludesThisThenCropTightly&&(s[d+1]&&o.ifRightSideIncludesThisThenCropTightly.includes(s[d+1])||s[d]&&o.ifRightSideIncludesThisThenCropTightly.includes(s[d])))&&("right"!==o.extendToOneSide&&n(s[l-1])&&!o.wipeAllWhitespaceOnLeft&&(l-=1),"left"!==o.extendToOneSide&&n(s[d])&&!o.wipeAllWhitespaceOnRight&&(d+=1)),o.addSingleSpaceToPreventAccidentalConcatenation&&s[l-1]&&s[l-1].trim()&&s[d]&&s[d].trim()&&(!o.ifLeftSideIncludesThisThenCropTightly&&!o.ifRightSideIncludesThisThenCropTightly||o.ifLeftSideIncludesThisThenCropTightly&&!o.ifLeftSideIncludesThisThenCropTightly.includes(s[l-1])||!(!o.ifRightSideIncludesThisThenCropTightly||s[d]&&o.ifRightSideIncludesThisThenCropTightly.includes(s[d])))&&(t.test(s[l-1])||t.test(s[d]))?[l,d," "]:[l,d]},e.version="3.0.3",Object.defineProperty(e,"__esModule",{value:!0})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "string-range-expander",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"description": "Expands string index ranges within whitespace boundaries until letters are met",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"expand",
|
|
@@ -33,11 +33,13 @@
|
|
|
33
33
|
"types": "types/index.d.ts",
|
|
34
34
|
"scripts": {
|
|
35
35
|
"build": "rollup -c",
|
|
36
|
-
"esbuild": "node '../../scripts/esbuild.js'",
|
|
37
|
-
"esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
|
|
38
36
|
"ci_test": "npm run build && npm run format && tap --no-only --reporter=silent --output-file=testStats.md && npm run clean_cov",
|
|
37
|
+
"clean_cov": "../../scripts/leaveCoverageTotalOnly.js",
|
|
38
|
+
"clean_types": "../../scripts/cleanTypes.js",
|
|
39
39
|
"dev": "rollup -c --dev",
|
|
40
40
|
"devunittest": "npm run dev && tap --only -R 'base'",
|
|
41
|
+
"esbuild": "node '../../scripts/esbuild.js'",
|
|
42
|
+
"esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
|
|
41
43
|
"format": "npm run lect && npm run prettier && npm run lint",
|
|
42
44
|
"lect": "lect",
|
|
43
45
|
"lint": "../../node_modules/eslint/bin/eslint.js . --ext .js --ext .ts --fix --config \"../../.eslintrc.json\" --quiet",
|
|
@@ -45,13 +47,11 @@
|
|
|
45
47
|
"prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
|
|
46
48
|
"republish": "npm publish || :",
|
|
47
49
|
"tap": "tap",
|
|
48
|
-
"tsc": "tsc",
|
|
49
50
|
"pretest": "npm run build",
|
|
50
51
|
"test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
|
|
51
52
|
"test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"clean_types": "../../scripts/cleanTypes.js"
|
|
53
|
+
"tsc": "tsc",
|
|
54
|
+
"unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf"
|
|
55
55
|
},
|
|
56
56
|
"tap": {
|
|
57
57
|
"check-coverage": false,
|
|
@@ -78,45 +78,45 @@
|
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
80
|
"dependencies": {
|
|
81
|
-
"@babel/runtime": "^7.
|
|
81
|
+
"@babel/runtime": "^7.16.0"
|
|
82
82
|
},
|
|
83
83
|
"devDependencies": {
|
|
84
|
-
"@babel/cli": "^7.
|
|
85
|
-
"@babel/core": "^7.
|
|
86
|
-
"@babel/node": "^7.
|
|
87
|
-
"@babel/plugin-external-helpers": "^7.
|
|
88
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
89
|
-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.
|
|
90
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.
|
|
91
|
-
"@babel/plugin-proposal-optional-chaining": "^7.
|
|
92
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
93
|
-
"@babel/preset-env": "^7.
|
|
94
|
-
"@babel/preset-typescript": "^7.
|
|
95
|
-
"@babel/register": "^7.
|
|
84
|
+
"@babel/cli": "^7.16.0",
|
|
85
|
+
"@babel/core": "^7.16.0",
|
|
86
|
+
"@babel/node": "^7.16.0",
|
|
87
|
+
"@babel/plugin-external-helpers": "^7.16.0",
|
|
88
|
+
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
|
89
|
+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
|
|
90
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.16.0",
|
|
91
|
+
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
|
|
92
|
+
"@babel/plugin-transform-runtime": "^7.16.0",
|
|
93
|
+
"@babel/preset-env": "^7.16.0",
|
|
94
|
+
"@babel/preset-typescript": "^7.16.0",
|
|
95
|
+
"@babel/register": "^7.16.0",
|
|
96
96
|
"@istanbuljs/esm-loader-hook": "^0.1.2",
|
|
97
97
|
"@rollup/plugin-babel": "^5.3.0",
|
|
98
|
-
"@rollup/plugin-commonjs": "^
|
|
98
|
+
"@rollup/plugin-commonjs": "^21.0.1",
|
|
99
99
|
"@rollup/plugin-json": "^4.1.0",
|
|
100
|
-
"@rollup/plugin-node-resolve": "^13.0.
|
|
100
|
+
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
101
101
|
"@rollup/plugin-strip": "^2.1.0",
|
|
102
|
-
"@rollup/plugin-typescript": "^8.
|
|
103
|
-
"@types/node": "^16.
|
|
102
|
+
"@rollup/plugin-typescript": "^8.3.0",
|
|
103
|
+
"@types/node": "^16.11.6",
|
|
104
104
|
"@types/tap": "^15.0.5",
|
|
105
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
106
|
-
"@typescript-eslint/parser": "^
|
|
107
|
-
"core-js": "^3.
|
|
105
|
+
"@typescript-eslint/eslint-plugin": "^5.2.0",
|
|
106
|
+
"@typescript-eslint/parser": "^5.2.0",
|
|
107
|
+
"core-js": "^3.19.0",
|
|
108
108
|
"cross-env": "^7.0.3",
|
|
109
|
-
"eslint": "^
|
|
110
|
-
"lect": "^0.18.
|
|
111
|
-
"rollup": "^2.
|
|
109
|
+
"eslint": "^8.1.0",
|
|
110
|
+
"lect": "^0.18.3",
|
|
111
|
+
"rollup": "^2.59.0",
|
|
112
112
|
"rollup-plugin-ascii": "^0.0.3",
|
|
113
113
|
"rollup-plugin-banner": "^0.2.1",
|
|
114
114
|
"rollup-plugin-cleanup": "^3.2.1",
|
|
115
115
|
"rollup-plugin-dts": "^4.0.0",
|
|
116
116
|
"rollup-plugin-terser": "^7.0.2",
|
|
117
|
-
"tap": "^15.0.
|
|
117
|
+
"tap": "^15.0.10",
|
|
118
118
|
"tslib": "^2.3.1",
|
|
119
|
-
"typescript": "^4.4.
|
|
119
|
+
"typescript": "^4.4.4"
|
|
120
120
|
},
|
|
121
121
|
"engines": {
|
|
122
122
|
"node": ">=12"
|