string-range-expander 4.0.27 → 4.0.29
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/.eslintcache +1 -0
- package/LICENSE +2 -2
- package/README.md +2 -2
- package/dist/string-range-expander.esm.js +4 -4
- package/dist/string-range-expander.umd.js +5 -5
- package/package.json +3 -3
package/.eslintcache
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[{"/home/runner/work/codsen/codsen/packages/string-range-expander/examples/_quickTake.js":"1","/home/runner/work/codsen/codsen/packages/string-range-expander/perf/check.js":"2","/home/runner/work/codsen/codsen/packages/string-range-expander/rollup.config.js":"3","/home/runner/work/codsen/codsen/packages/string-range-expander/src/main.ts":"4","/home/runner/work/codsen/codsen/packages/string-range-expander/test/cropItToo.js":"5","/home/runner/work/codsen/codsen/packages/string-range-expander/test/extendToOneSide.js":"6","/home/runner/work/codsen/codsen/packages/string-range-expander/test/test.js":"7","/home/runner/work/codsen/codsen/packages/string-range-expander/test/throws.js":"8","/home/runner/work/codsen/codsen/packages/string-range-expander/test/tight.js":"9","/home/runner/work/codsen/codsen/packages/string-range-expander/test/wipeAllWhitespace.js":"10"},{"size":507,"mtime":1760280945971,"results":"11","hashOfConfig":"12"},{"size":380,"mtime":1760280945971,"results":"13","hashOfConfig":"14"},{"size":373,"mtime":1760280945971,"results":"15","hashOfConfig":"12"},{"size":11944,"mtime":1760280945971,"results":"16","hashOfConfig":"14"},{"size":1677,"mtime":1760280945971,"results":"17","hashOfConfig":"18"},{"size":880,"mtime":1760280945971,"results":"19","hashOfConfig":"18"},{"size":16027,"mtime":1760280945971,"results":"20","hashOfConfig":"18"},{"size":4407,"mtime":1760280945971,"results":"21","hashOfConfig":"18"},{"size":5179,"mtime":1760280945971,"results":"22","hashOfConfig":"18"},{"size":6734,"mtime":1760280945971,"results":"23","hashOfConfig":"18"},{"filePath":"24","messages":"25","suppressedMessages":"26","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"1f1u168",{"filePath":"27","messages":"28","suppressedMessages":"29","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"91l1rm",{"filePath":"30","messages":"31","suppressedMessages":"32","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"33","messages":"34","suppressedMessages":"35","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"36","messages":"37","suppressedMessages":"38","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"ns3qdb",{"filePath":"39","messages":"40","suppressedMessages":"41","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"42","messages":"43","suppressedMessages":"44","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"45","messages":"46","suppressedMessages":"47","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"48","messages":"49","suppressedMessages":"50","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},{"filePath":"51","messages":"52","suppressedMessages":"53","errorCount":0,"fatalErrorCount":0,"warningCount":0,"fixableErrorCount":0,"fixableWarningCount":0},"/home/runner/work/codsen/codsen/packages/string-range-expander/examples/_quickTake.js",[],[],"/home/runner/work/codsen/codsen/packages/string-range-expander/perf/check.js",[],[],"/home/runner/work/codsen/codsen/packages/string-range-expander/rollup.config.js",[],[],"/home/runner/work/codsen/codsen/packages/string-range-expander/src/main.ts",[],[],"/home/runner/work/codsen/codsen/packages/string-range-expander/test/cropItToo.js",[],["54","55","56","57","58","59"],"/home/runner/work/codsen/codsen/packages/string-range-expander/test/extendToOneSide.js",[],["60","61","62","63","64","65"],"/home/runner/work/codsen/codsen/packages/string-range-expander/test/test.js",[],["66","67","68","69","70","71"],"/home/runner/work/codsen/codsen/packages/string-range-expander/test/throws.js",[],["72","73","74","75","76"],"/home/runner/work/codsen/codsen/packages/string-range-expander/test/tight.js",[],["77","78","79","80","81","82"],"/home/runner/work/codsen/codsen/packages/string-range-expander/test/wipeAllWhitespace.js",[],["83","84","85","86","87","88"],{"ruleId":"89","severity":2,"message":"90","line":3,"column":17,"nodeType":null,"messageId":"91","endLine":3,"endColumn":19,"suppressions":"92"},{"ruleId":"89","severity":2,"message":"93","line":3,"column":21,"nodeType":null,"messageId":"91","endLine":3,"endColumn":23,"suppressions":"94"},{"ruleId":"89","severity":2,"message":"95","line":3,"column":25,"nodeType":null,"messageId":"91","endLine":3,"endColumn":31,"suppressions":"96"},{"ruleId":"89","severity":2,"message":"97","line":3,"column":33,"nodeType":null,"messageId":"91","endLine":3,"endColumn":37,"suppressions":"98"},{"ruleId":"89","severity":2,"message":"99","line":3,"column":39,"nodeType":null,"messageId":"91","endLine":3,"endColumn":42,"suppressions":"100"},{"ruleId":"89","severity":2,"message":"101","line":3,"column":44,"nodeType":null,"messageId":"91","endLine":3,"endColumn":49,"suppressions":"102"},{"ruleId":"89","severity":2,"message":"90","line":3,"column":17,"nodeType":null,"messageId":"91","endLine":3,"endColumn":19,"suppressions":"103"},{"ruleId":"89","severity":2,"message":"93","line":3,"column":21,"nodeType":null,"messageId":"91","endLine":3,"endColumn":23,"suppressions":"104"},{"ruleId":"89","severity":2,"message":"95","line":3,"column":25,"nodeType":null,"messageId":"91","endLine":3,"endColumn":31,"suppressions":"105"},{"ruleId":"89","severity":2,"message":"97","line":3,"column":33,"nodeType":null,"messageId":"91","endLine":3,"endColumn":37,"suppressions":"106"},{"ruleId":"89","severity":2,"message":"99","line":3,"column":39,"nodeType":null,"messageId":"91","endLine":3,"endColumn":42,"suppressions":"107"},{"ruleId":"89","severity":2,"message":"101","line":3,"column":44,"nodeType":null,"messageId":"91","endLine":3,"endColumn":49,"suppressions":"108"},{"ruleId":"89","severity":2,"message":"90","line":3,"column":17,"nodeType":null,"messageId":"91","endLine":3,"endColumn":19,"suppressions":"109"},{"ruleId":"89","severity":2,"message":"93","line":3,"column":21,"nodeType":null,"messageId":"91","endLine":3,"endColumn":23,"suppressions":"110"},{"ruleId":"89","severity":2,"message":"95","line":3,"column":25,"nodeType":null,"messageId":"91","endLine":3,"endColumn":31,"suppressions":"111"},{"ruleId":"89","severity":2,"message":"97","line":3,"column":33,"nodeType":null,"messageId":"91","endLine":3,"endColumn":37,"suppressions":"112"},{"ruleId":"89","severity":2,"message":"99","line":3,"column":39,"nodeType":null,"messageId":"91","endLine":3,"endColumn":42,"suppressions":"113"},{"ruleId":"89","severity":2,"message":"101","line":3,"column":44,"nodeType":null,"messageId":"91","endLine":3,"endColumn":49,"suppressions":"114"},{"ruleId":"89","severity":2,"message":"115","line":3,"column":10,"nodeType":null,"messageId":"91","endLine":3,"endColumn":15,"suppressions":"116"},{"ruleId":"89","severity":2,"message":"90","line":3,"column":17,"nodeType":null,"messageId":"91","endLine":3,"endColumn":19,"suppressions":"117"},{"ruleId":"89","severity":2,"message":"93","line":3,"column":21,"nodeType":null,"messageId":"91","endLine":3,"endColumn":23,"suppressions":"118"},{"ruleId":"89","severity":2,"message":"97","line":3,"column":33,"nodeType":null,"messageId":"91","endLine":3,"endColumn":37,"suppressions":"119"},{"ruleId":"89","severity":2,"message":"101","line":3,"column":44,"nodeType":null,"messageId":"91","endLine":3,"endColumn":49,"suppressions":"120"},{"ruleId":"89","severity":2,"message":"90","line":3,"column":17,"nodeType":null,"messageId":"91","endLine":3,"endColumn":19,"suppressions":"121"},{"ruleId":"89","severity":2,"message":"93","line":3,"column":21,"nodeType":null,"messageId":"91","endLine":3,"endColumn":23,"suppressions":"122"},{"ruleId":"89","severity":2,"message":"95","line":3,"column":25,"nodeType":null,"messageId":"91","endLine":3,"endColumn":31,"suppressions":"123"},{"ruleId":"89","severity":2,"message":"97","line":3,"column":33,"nodeType":null,"messageId":"91","endLine":3,"endColumn":37,"suppressions":"124"},{"ruleId":"89","severity":2,"message":"99","line":3,"column":39,"nodeType":null,"messageId":"91","endLine":3,"endColumn":42,"suppressions":"125"},{"ruleId":"89","severity":2,"message":"101","line":3,"column":44,"nodeType":null,"messageId":"91","endLine":3,"endColumn":49,"suppressions":"126"},{"ruleId":"89","severity":2,"message":"90","line":3,"column":17,"nodeType":null,"messageId":"91","endLine":3,"endColumn":19,"suppressions":"127"},{"ruleId":"89","severity":2,"message":"93","line":3,"column":21,"nodeType":null,"messageId":"91","endLine":3,"endColumn":23,"suppressions":"128"},{"ruleId":"89","severity":2,"message":"95","line":3,"column":25,"nodeType":null,"messageId":"91","endLine":3,"endColumn":31,"suppressions":"129"},{"ruleId":"89","severity":2,"message":"97","line":3,"column":33,"nodeType":null,"messageId":"91","endLine":3,"endColumn":37,"suppressions":"130"},{"ruleId":"89","severity":2,"message":"99","line":3,"column":39,"nodeType":null,"messageId":"91","endLine":3,"endColumn":42,"suppressions":"131"},{"ruleId":"89","severity":2,"message":"101","line":3,"column":44,"nodeType":null,"messageId":"91","endLine":3,"endColumn":49,"suppressions":"132"},"@typescript-eslint/no-unused-vars","'is' is defined but never used.","unusedVar",["133"],"'ok' is defined but never used.",["134"],"'throws' is defined but never used.",["135"],"'type' is defined but never used.",["136"],"'not' is defined but never used.",["137"],"'match' is defined but never used.",["138"],["139"],["140"],["141"],["142"],["143"],["144"],["145"],["146"],["147"],["148"],["149"],["150"],"'equal' is defined but never used.",["151"],["152"],["153"],["154"],["155"],["156"],["157"],["158"],["159"],["160"],["161"],["162"],["163"],["164"],["165"],["166"],["167"],{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},{"kind":"168","justification":"169"},"directive",""]
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright
|
|
3
|
+
Copyright © 2010-2025 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
|
|
@@ -19,4 +19,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
19
19
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
20
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
21
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -64,8 +64,8 @@ To report bugs or request features or assistance, [raise an issue](https://githu
|
|
|
64
64
|
|
|
65
65
|
## Licence
|
|
66
66
|
|
|
67
|
-
MIT License
|
|
67
|
+
MIT License
|
|
68
68
|
|
|
69
|
-
Copyright © 2010-2025 Roy Revelt and other contributors
|
|
69
|
+
Copyright © 2010-2025 Roy Revelt and other contributors
|
|
70
70
|
|
|
71
71
|
<p align="center"><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"></p>
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name string-range-expander
|
|
3
3
|
* @fileoverview Expands string index ranges within whitespace boundaries until letters are met
|
|
4
|
-
* @version 4.0.
|
|
5
|
-
* @author Roy Revelt
|
|
4
|
+
* @version 4.0.29
|
|
5
|
+
* @author Roy Revelt
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/string-range-expander/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import{isStr as s,isInt as f,isPlainObject as u}from"codsen-utils";var h="4.0.
|
|
11
|
-
${JSON.stringify(e,null,4)}.`,new Error(`string-range-expander: [THROW_ID_01] Input must be a plain object ${t}`)}if(!f(e.from))throw new Error(`string-range-expander: [THROW_ID_03] The input's "from" value resolvedOpts.from, is not a number! It's been given as ${typeof e.from}, equal to ${JSON.stringify(e.from,null,0)}`);if(!f(e.to))throw new Error(`string-range-expander: [THROW_ID_04] The input's "to" value resolvedOpts.to, is not a number! It's been given as ${typeof e.to}, equal to ${JSON.stringify(e.to,null,0)}`);if(e?.str&&!e.str[e.from]&&e.from!==e.to)throw new Error(`string-range-expander: [THROW_ID_05] The given input string resolvedOpts.str ("${e.str}") must contain the character at index "from" ("${e.from}")`);if(e?.str&&!e.str[e.to-1])throw new Error(`string-range-expander: [THROW_ID_06] The given input string, resolvedOpts.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(e.extendToOneSide===null||s(e.extendToOneSide)&&e.extendToOneSide!=="left"&&e.extendToOneSide!=="right"||!s(e.extendToOneSide)&&e.extendToOneSide!==void 0&&e.extendToOneSide)throw new Error(`string-range-expander: [THROW_ID_08] The options value "extendToOneSide" is not recognisable! It's set to: "${e.extendToOneSide}" (${typeof e.extendToOneSide}). It has to be either Boolean "false" or one of strings: "left" or "right"`);if(e?.ifLeftSideIncludesThisThenCropTightly&&!s(e.ifLeftSideIncludesThisThenCropTightly))throw new Error(`string-range-expander: [THROW_ID_09] The option "ifLeftSideIncludesThisThenCropTightly", is not a string! It's been given as ${typeof e.ifLeftSideIncludesThisThenCropTightly}, equal to ${JSON.stringify(e.ifLeftSideIncludesThisThenCropTightly,null,0)}`);if(e?.ifLeftSideIncludesThisCropItToo&&!s(e.ifLeftSideIncludesThisCropItToo))throw new Error(`string-range-expander: [THROW_ID_10] The option "ifLeftSideIncludesThisCropItToo", is not a string! It's been given as ${typeof e.ifLeftSideIncludesThisCropItToo}, equal to ${JSON.stringify(e.ifLeftSideIncludesThisCropItToo,null,0)}`);if(e?.ifRightSideIncludesThisThenCropTightly&&!s(e.ifRightSideIncludesThisThenCropTightly))throw new Error(`string-range-expander: [THROW_ID_11] The option "ifRightSideIncludesThisThenCropTightly", is not a string! It's been given as ${typeof e.ifRightSideIncludesThisThenCropTightly}, equal to ${JSON.stringify(e.ifRightSideIncludesThisThenCropTightly,null,0)}`);if(e?.ifRightSideIncludesThisCropItToo&&!s(e.ifRightSideIncludesThisCropItToo))throw new Error(`string-range-expander: [THROW_ID_12] The option "ifRightSideIncludesThisCropItToo", is not a string! It's been given as ${typeof e.ifRightSideIncludesThisCropItToo}, equal to ${JSON.stringify(e.ifRightSideIncludesThisCropItToo,null,0)}`);let i={...
|
|
10
|
+
import{isStr as s,isInt as f,isPlainObject as u}from"codsen-utils";var h="4.0.29";var I=h,c={str:"",from:0,to:0,ifLeftSideIncludesThisThenCropTightly:"",ifLeftSideIncludesThisCropItToo:"",ifRightSideIncludesThisThenCropTightly:"",ifRightSideIncludesThisCropItToo:"",extendToOneSide:!1,wipeAllWhitespaceOnLeft:!1,wipeAllWhitespaceOnRight:!1,addSingleSpaceToPreventAccidentalConcatenation:!1};function S(e){let d=/^[0-9a-zA-Z]+$/;function l(t){return s(t)&&!t.trim()}if(u(e)){if(!Object.keys(e).length)throw new Error(`string-range-expander: [THROW_ID_02] Input must be a plain object but it's been given as a plain object without any keys. However, "from" and "to" settings are obligatory!`)}else{let t;throw e===void 0?t="but it is missing completely.":e===null?t="but it was given as null.":t=`but it was given as ${typeof e}, equal to:
|
|
11
|
+
${JSON.stringify(e,null,4)}.`,new Error(`string-range-expander: [THROW_ID_01] Input must be a plain object ${t}`)}if(!f(e.from))throw new Error(`string-range-expander: [THROW_ID_03] The input's "from" value resolvedOpts.from, is not a number! It's been given as ${typeof e.from}, equal to ${JSON.stringify(e.from,null,0)}`);if(!f(e.to))throw new Error(`string-range-expander: [THROW_ID_04] The input's "to" value resolvedOpts.to, is not a number! It's been given as ${typeof e.to}, equal to ${JSON.stringify(e.to,null,0)}`);if(e?.str&&!e.str[e.from]&&e.from!==e.to)throw new Error(`string-range-expander: [THROW_ID_05] The given input string resolvedOpts.str ("${e.str}") must contain the character at index "from" ("${e.from}")`);if(e?.str&&!e.str[e.to-1])throw new Error(`string-range-expander: [THROW_ID_06] The given input string, resolvedOpts.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(e.extendToOneSide===null||s(e.extendToOneSide)&&e.extendToOneSide!=="left"&&e.extendToOneSide!=="right"||!s(e.extendToOneSide)&&e.extendToOneSide!==void 0&&e.extendToOneSide)throw new Error(`string-range-expander: [THROW_ID_08] The options value "extendToOneSide" is not recognisable! It's set to: "${e.extendToOneSide}" (${typeof e.extendToOneSide}). It has to be either Boolean "false" or one of strings: "left" or "right"`);if(e?.ifLeftSideIncludesThisThenCropTightly&&!s(e.ifLeftSideIncludesThisThenCropTightly))throw new Error(`string-range-expander: [THROW_ID_09] The option "ifLeftSideIncludesThisThenCropTightly", is not a string! It's been given as ${typeof e.ifLeftSideIncludesThisThenCropTightly}, equal to ${JSON.stringify(e.ifLeftSideIncludesThisThenCropTightly,null,0)}`);if(e?.ifLeftSideIncludesThisCropItToo&&!s(e.ifLeftSideIncludesThisCropItToo))throw new Error(`string-range-expander: [THROW_ID_10] The option "ifLeftSideIncludesThisCropItToo", is not a string! It's been given as ${typeof e.ifLeftSideIncludesThisCropItToo}, equal to ${JSON.stringify(e.ifLeftSideIncludesThisCropItToo,null,0)}`);if(e?.ifRightSideIncludesThisThenCropTightly&&!s(e.ifRightSideIncludesThisThenCropTightly))throw new Error(`string-range-expander: [THROW_ID_11] The option "ifRightSideIncludesThisThenCropTightly", is not a string! It's been given as ${typeof e.ifRightSideIncludesThisThenCropTightly}, equal to ${JSON.stringify(e.ifRightSideIncludesThisThenCropTightly,null,0)}`);if(e?.ifRightSideIncludesThisCropItToo&&!s(e.ifRightSideIncludesThisCropItToo))throw new Error(`string-range-expander: [THROW_ID_12] The option "ifRightSideIncludesThisCropItToo", is not a string! It's been given as ${typeof e.ifRightSideIncludesThisCropItToo}, equal to ${JSON.stringify(e.ifRightSideIncludesThisCropItToo,null,0)}`);let i={...c,...e},n=i.str,r=i.from,o=i.to;if(i.extendToOneSide!=="right"&&(l(n[r-1])&&(l(n[r-2])||i.ifLeftSideIncludesThisCropItToo.includes(n[r-2]))||n[r-1]&&i.ifLeftSideIncludesThisCropItToo.includes(n[r-1])||i.wipeAllWhitespaceOnLeft&&l(n[r-1]))){for(let t=r;t--;)if(!i.ifLeftSideIncludesThisCropItToo.includes(n[t])){if(n[t].trim()){i.wipeAllWhitespaceOnLeft||i.ifLeftSideIncludesThisCropItToo.includes(n[t+1])?r=t+1:r=t+2;break}else if(t===0){i.wipeAllWhitespaceOnLeft?r=0:r=1;break}}}if(i.extendToOneSide!=="left"&&(l(n[o])&&(i.wipeAllWhitespaceOnRight||l(n[o+1]))||i.ifRightSideIncludesThisCropItToo.includes(n[o]))){for(let t=o,g=n.length;t<g;t++)if(!i.ifRightSideIncludesThisCropItToo.includes(n[t])){if(n[t].trim()){i.wipeAllWhitespaceOnRight||i.ifRightSideIncludesThisCropItToo.includes(n[t-1])?o=t:o=t-1;break}else if(t===n.length-1){i.wipeAllWhitespaceOnRight?o=n.length:o=n.length-1;break}}}return(i.extendToOneSide!=="right"&&s(i.ifLeftSideIncludesThisThenCropTightly)&&i.ifLeftSideIncludesThisThenCropTightly&&(n[r-2]&&i.ifLeftSideIncludesThisThenCropTightly.includes(n[r-2])||n[r-1]&&i.ifLeftSideIncludesThisThenCropTightly.includes(n[r-1]))||i.extendToOneSide!=="left"&&s(i.ifRightSideIncludesThisThenCropTightly)&&i.ifRightSideIncludesThisThenCropTightly&&(n[o+1]&&i.ifRightSideIncludesThisThenCropTightly.includes(n[o+1])||n[o]&&i.ifRightSideIncludesThisThenCropTightly.includes(n[o])))&&(i.extendToOneSide!=="right"&&l(n[r-1])&&!i.wipeAllWhitespaceOnLeft&&(r-=1),i.extendToOneSide!=="left"&&l(n[o])&&!i.wipeAllWhitespaceOnRight&&(o+=1)),i.addSingleSpaceToPreventAccidentalConcatenation&&n[r-1]?.trim()&&n[o]?.trim()&&(!i.ifLeftSideIncludesThisThenCropTightly&&!i.ifRightSideIncludesThisThenCropTightly||!((!i.ifLeftSideIncludesThisThenCropTightly||i.ifLeftSideIncludesThisThenCropTightly.includes(n[r-1]))&&(!i.ifRightSideIncludesThisThenCropTightly||n[o]&&i.ifRightSideIncludesThisThenCropTightly.includes(n[o]))))&&(d.test(n[r-1])||d.test(n[o]))?[r,o," "]:[r,o]}export{c as defaults,S as expander,I as version};
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name string-range-expander
|
|
3
3
|
* @fileoverview Expands string index ranges within whitespace boundaries until letters are met
|
|
4
|
-
* @version 4.0.
|
|
5
|
-
* @author Roy Revelt
|
|
4
|
+
* @version 4.0.29
|
|
5
|
+
* @author Roy Revelt
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/string-range-expander/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
"use strict";var stringRangeExpander=(()=>{var v=Object.create;var m=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames,I=Object.getOwnPropertySymbols,k=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable;var $=(e,o,l)=>o in e?m(e,o,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[o]=l,b=(e,o)=>{for(var l in o||(o={}))O.call(o,l)&&$(e,l,o[l]);if(I)for(var l of I(o))W.call(o,l)&&$(e,l,o[l]);return e};var B=(e,o)=>()=>(o||e((o={exports:{}}).exports,o),o.exports),V=(e,o)=>{for(var l in o)m(e,l,{get:o[l],enumerable:!0})},w=(e,o,l,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of L(o))!O.call(e,r)&&r!==l&&m(e,r,{get:()=>o[r],enumerable:!(i=j(o,r))||i.enumerable});return e};var _=(e,o,l)=>(l=e!=null?v(k(e)):{},w(o||!e||!e.__esModule?m(l,"default",{value:e,enumerable:!0}):l,e)),H=e=>w(m({},"__esModule",{value:!0}),e);var x=B((Q,C)=>{"use strict";C.exports=N;function T(e){return e instanceof Buffer?Buffer.from(e):new e.constructor(e.buffer.slice(),e.byteOffset,e.length)}function N(e){if(e=e||{},e.circles)return P(e);let o=new Map;if(o.set(Date,t=>new Date(t)),o.set(Map,(t,a)=>new Map(i(Array.from(t),a))),o.set(Set,(t,a)=>new Set(i(Array.from(t),a))),e.constructorHandlers)for(let t of e.constructorHandlers)o.set(t[0],t[1]);let l=null;return e.proto?c:r;function i(t,a){let s=Object.keys(t),n=new Array(s.length);for(let f=0;f<s.length;f++){let u=s[f],d=t[u];typeof d!="object"||d===null?n[u]=d:d.constructor!==Object&&(l=o.get(d.constructor))?n[u]=l(d,a):ArrayBuffer.isView(d)?n[u]=T(d):n[u]=a(d)}return n}function r(t){if(typeof t!="object"||t===null)return t;if(Array.isArray(t))return i(t,r);if(t.constructor!==Object&&(l=o.get(t.constructor)))return l(t,r);let a={};for(let s in t){if(Object.hasOwnProperty.call(t,s)===!1)continue;let n=t[s];typeof n!="object"||n===null?a[s]=n:n.constructor!==Object&&(l=o.get(n.constructor))?a[s]=l(n,r):ArrayBuffer.isView(n)?a[s]=T(n):a[s]=r(n)}return a}function c(t){if(typeof t!="object"||t===null)return t;if(Array.isArray(t))return i(t,c);if(t.constructor!==Object&&(l=o.get(t.constructor)))return l(t,c);let a={};for(let s in t){let n=t[s];typeof n!="object"||n===null?a[s]=n:n.constructor!==Object&&(l=o.get(n.constructor))?a[s]=l(n,c):ArrayBuffer.isView(n)?a[s]=T(n):a[s]=c(n)}return a}}function P(e){let o=[],l=[],i=new Map;if(i.set(Date,s=>new Date(s)),i.set(Map,(s,n)=>new Map(c(Array.from(s),n))),i.set(Set,(s,n)=>new Set(c(Array.from(s),n))),e.constructorHandlers)for(let s of e.constructorHandlers)i.set(s[0],s[1]);let r=null;return e.proto?a:t;function c(s,n){let f=Object.keys(s),u=new Array(f.length);for(let d=0;d<f.length;d++){let p=f[d],h=s[p];if(typeof h!="object"||h===null)u[p]=h;else if(h.constructor!==Object&&(r=i.get(h.constructor)))u[p]=r(h,n);else if(ArrayBuffer.isView(h))u[p]=T(h);else{let S=o.indexOf(h);S!==-1?u[p]=l[S]:u[p]=n(h)}}return u}function t(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return c(s,t);if(s.constructor!==Object&&(r=i.get(s.constructor)))return r(s,t);let n={};o.push(s),l.push(n);for(let f in s){if(Object.hasOwnProperty.call(s,f)===!1)continue;let u=s[f];if(typeof u!="object"||u===null)n[f]=u;else if(u.constructor!==Object&&(r=i.get(u.constructor)))n[f]=r(u,t);else if(ArrayBuffer.isView(u))n[f]=T(u);else{let d=o.indexOf(u);d!==-1?n[f]=l[d]:n[f]=t(u)}}return o.pop(),l.pop(),n}function a(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return c(s,a);if(s.constructor!==Object&&(r=i.get(s.constructor)))return r(s,a);let n={};o.push(s),l.push(n);for(let f in s){let u=s[f];if(typeof u!="object"||u===null)n[f]=u;else if(u.constructor!==Object&&(r=i.get(u.constructor)))n[f]=r(u,a);else if(ArrayBuffer.isView(u))n[f]=T(u);else{let d=o.indexOf(u);d!==-1?n[f]=l[d]:n[f]=a(u)}}return o.pop(),l.pop(),n}}});var q={};V(q,{defaults:()=>D,expander:()=>J,version:()=>F});var A=_(x(),1);var K=(0,A.default)();function R(e){if(e==null||typeof e!="object")return!1;let o=Object.getPrototypeOf(e);return o!==null&&o!==Object.prototype&&Object.getPrototypeOf(o)!==null?!1:!(Symbol.iterator in e)&&!(Symbol.toStringTag in e)}function g(e){return typeof e=="string"}function y(e){return Number.isSafeInteger(e)&&e>=0}var E="4.0.27";var F=E,D={str:"",from:0,to:0,ifLeftSideIncludesThisThenCropTightly:"",ifLeftSideIncludesThisCropItToo:"",ifRightSideIncludesThisThenCropTightly:"",ifRightSideIncludesThisCropItToo:"",extendToOneSide:!1,wipeAllWhitespaceOnLeft:!1,wipeAllWhitespaceOnRight:!1,addSingleSpaceToPreventAccidentalConcatenation:!1};function J(e){var a,s;let o=/^[0-9a-zA-Z]+$/;function l(n){return g(n)&&!n.trim()}if(R(e)){if(!Object.keys(e).length)throw new Error('string-range-expander: [THROW_ID_02] Input must be a plain object but it\'s been given as a plain object without any keys. However, "from" and "to" settings are obligatory!')}else{let n;throw e===void 0?n="but it is missing completely.":e===null?n="but it was given as null.":n="but it was given as ".concat(typeof e,", equal to:\n").concat(JSON.stringify(e,null,4),"."),new Error("string-range-expander: [THROW_ID_01] Input must be a plain object ".concat(n))}if(!y(e.from))throw new Error("string-range-expander: [THROW_ID_03] The input's \"from\" value resolvedOpts.from, is not a number! It's been given as ".concat(typeof e.from,", equal to ").concat(JSON.stringify(e.from,null,0)));if(!y(e.to))throw new Error("string-range-expander: [THROW_ID_04] The input's \"to\" value resolvedOpts.to, is not a number! It's been given as ".concat(typeof e.to,", equal to ").concat(JSON.stringify(e.to,null,0)));if(e!=null&&e.str&&!e.str[e.from]&&e.from!==e.to)throw new Error('string-range-expander: [THROW_ID_05] The given input string resolvedOpts.str ("'.concat(e.str,'") must contain the character at index "from" ("').concat(e.from,'")'));if(e!=null&&e.str&&!e.str[e.to-1])throw new Error('string-range-expander: [THROW_ID_06] The given input string, resolvedOpts.str ("'.concat(e.str,'") must contain the character at index before "to" ("').concat(e.to-1,'")'));if(e.from>e.to)throw new Error('string-range-expander: [THROW_ID_07] The given "from" index, "'.concat(e.from,'" is greater than "to" index, "').concat(e.to,"\". That's wrong!"));if(e.extendToOneSide===null||g(e.extendToOneSide)&&e.extendToOneSide!=="left"&&e.extendToOneSide!=="right"||!g(e.extendToOneSide)&&e.extendToOneSide!==void 0&&e.extendToOneSide)throw new Error('string-range-expander: [THROW_ID_08] The options value "extendToOneSide" is not recognisable! It\'s set to: "'.concat(e.extendToOneSide,'" (').concat(typeof e.extendToOneSide,'). It has to be either Boolean "false" or one of strings: "left" or "right"'));if(e!=null&&e.ifLeftSideIncludesThisThenCropTightly&&!g(e.ifLeftSideIncludesThisThenCropTightly))throw new Error('string-range-expander: [THROW_ID_09] The option "ifLeftSideIncludesThisThenCropTightly", is not a string! It\'s been given as '.concat(typeof e.ifLeftSideIncludesThisThenCropTightly,", equal to ").concat(JSON.stringify(e.ifLeftSideIncludesThisThenCropTightly,null,0)));if(e!=null&&e.ifLeftSideIncludesThisCropItToo&&!g(e.ifLeftSideIncludesThisCropItToo))throw new Error('string-range-expander: [THROW_ID_10] The option "ifLeftSideIncludesThisCropItToo", is not a string! It\'s been given as '.concat(typeof e.ifLeftSideIncludesThisCropItToo,", equal to ").concat(JSON.stringify(e.ifLeftSideIncludesThisCropItToo,null,0)));if(e!=null&&e.ifRightSideIncludesThisThenCropTightly&&!g(e.ifRightSideIncludesThisThenCropTightly))throw new Error('string-range-expander: [THROW_ID_11] The option "ifRightSideIncludesThisThenCropTightly", is not a string! It\'s been given as '.concat(typeof e.ifRightSideIncludesThisThenCropTightly,", equal to ").concat(JSON.stringify(e.ifRightSideIncludesThisThenCropTightly,null,0)));if(e!=null&&e.ifRightSideIncludesThisCropItToo&&!g(e.ifRightSideIncludesThisCropItToo))throw new Error('string-range-expander: [THROW_ID_12] The option "ifRightSideIncludesThisCropItToo", is not a string! It\'s been given as '.concat(typeof e.ifRightSideIncludesThisCropItToo,", equal to ").concat(JSON.stringify(e.ifRightSideIncludesThisCropItToo,null,0)));let i=b(b({},D),e),r=i.str,c=i.from,t=i.to;if(i.extendToOneSide!=="right"&&(l(r[c-1])&&(l(r[c-2])||i.ifLeftSideIncludesThisCropItToo.includes(r[c-2]))||r[c-1]&&i.ifLeftSideIncludesThisCropItToo.includes(r[c-1])||i.wipeAllWhitespaceOnLeft&&l(r[c-1]))){for(let n=c;n--;)if(!i.ifLeftSideIncludesThisCropItToo.includes(r[n])){if(r[n].trim()){i.wipeAllWhitespaceOnLeft||i.ifLeftSideIncludesThisCropItToo.includes(r[n+1])?c=n+1:c=n+2;break}else if(n===0){i.wipeAllWhitespaceOnLeft?c=0:c=1;break}}}if(i.extendToOneSide!=="left"&&(l(r[t])&&(i.wipeAllWhitespaceOnRight||l(r[t+1]))||i.ifRightSideIncludesThisCropItToo.includes(r[t]))){for(let n=t,f=r.length;n<f;n++)if(!i.ifRightSideIncludesThisCropItToo.includes(r[n])){if(r[n].trim()){i.wipeAllWhitespaceOnRight||i.ifRightSideIncludesThisCropItToo.includes(r[n-1])?t=n:t=n-1;break}else if(n===r.length-1){i.wipeAllWhitespaceOnRight?t=r.length:t=r.length-1;break}}}return(i.extendToOneSide!=="right"&&g(i.ifLeftSideIncludesThisThenCropTightly)&&i.ifLeftSideIncludesThisThenCropTightly&&(r[c-2]&&i.ifLeftSideIncludesThisThenCropTightly.includes(r[c-2])||r[c-1]&&i.ifLeftSideIncludesThisThenCropTightly.includes(r[c-1]))||i.extendToOneSide!=="left"&&g(i.ifRightSideIncludesThisThenCropTightly)&&i.ifRightSideIncludesThisThenCropTightly&&(r[t+1]&&i.ifRightSideIncludesThisThenCropTightly.includes(r[t+1])||r[t]&&i.ifRightSideIncludesThisThenCropTightly.includes(r[t])))&&(i.extendToOneSide!=="right"&&l(r[c-1])&&!i.wipeAllWhitespaceOnLeft&&(c-=1),i.extendToOneSide!=="left"&&l(r[t])&&!i.wipeAllWhitespaceOnRight&&(t+=1)),i.addSingleSpaceToPreventAccidentalConcatenation&&((a=r[c-1])!=null&&a.trim())&&((s=r[t])!=null&&s.trim())&&(!i.ifLeftSideIncludesThisThenCropTightly&&!i.ifRightSideIncludesThisThenCropTightly||!((!i.ifLeftSideIncludesThisThenCropTightly||i.ifLeftSideIncludesThisThenCropTightly.includes(r[c-1]))&&(!i.ifRightSideIncludesThisThenCropTightly||r[t]&&i.ifRightSideIncludesThisThenCropTightly.includes(r[t]))))&&(o.test(r[c-1])||o.test(r[t]))?[c,t," "]:[c,t]}return H(q);})();
|
|
10
|
+
"use strict";var stringRangeExpander=(()=>{var v=Object.create;var m=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames,I=Object.getOwnPropertySymbols,k=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable;var $=(e,o,l)=>o in e?m(e,o,{enumerable:!0,configurable:!0,writable:!0,value:l}):e[o]=l,b=(e,o)=>{for(var l in o||(o={}))O.call(o,l)&&$(e,l,o[l]);if(I)for(var l of I(o))W.call(o,l)&&$(e,l,o[l]);return e};var B=(e,o)=>()=>(o||e((o={exports:{}}).exports,o),o.exports),V=(e,o)=>{for(var l in o)m(e,l,{get:o[l],enumerable:!0})},w=(e,o,l,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let r of L(o))!O.call(e,r)&&r!==l&&m(e,r,{get:()=>o[r],enumerable:!(i=j(o,r))||i.enumerable});return e};var _=(e,o,l)=>(l=e!=null?v(k(e)):{},w(o||!e||!e.__esModule?m(l,"default",{value:e,enumerable:!0}):l,e)),H=e=>w(m({},"__esModule",{value:!0}),e);var x=B((Q,C)=>{"use strict";C.exports=N;function T(e){return e instanceof Buffer?Buffer.from(e):new e.constructor(e.buffer.slice(),e.byteOffset,e.length)}function N(e){if(e=e||{},e.circles)return P(e);let o=new Map;if(o.set(Date,t=>new Date(t)),o.set(Map,(t,a)=>new Map(i(Array.from(t),a))),o.set(Set,(t,a)=>new Set(i(Array.from(t),a))),e.constructorHandlers)for(let t of e.constructorHandlers)o.set(t[0],t[1]);let l=null;return e.proto?c:r;function i(t,a){let s=Object.keys(t),n=new Array(s.length);for(let f=0;f<s.length;f++){let u=s[f],d=t[u];typeof d!="object"||d===null?n[u]=d:d.constructor!==Object&&(l=o.get(d.constructor))?n[u]=l(d,a):ArrayBuffer.isView(d)?n[u]=T(d):n[u]=a(d)}return n}function r(t){if(typeof t!="object"||t===null)return t;if(Array.isArray(t))return i(t,r);if(t.constructor!==Object&&(l=o.get(t.constructor)))return l(t,r);let a={};for(let s in t){if(Object.hasOwnProperty.call(t,s)===!1)continue;let n=t[s];typeof n!="object"||n===null?a[s]=n:n.constructor!==Object&&(l=o.get(n.constructor))?a[s]=l(n,r):ArrayBuffer.isView(n)?a[s]=T(n):a[s]=r(n)}return a}function c(t){if(typeof t!="object"||t===null)return t;if(Array.isArray(t))return i(t,c);if(t.constructor!==Object&&(l=o.get(t.constructor)))return l(t,c);let a={};for(let s in t){let n=t[s];typeof n!="object"||n===null?a[s]=n:n.constructor!==Object&&(l=o.get(n.constructor))?a[s]=l(n,c):ArrayBuffer.isView(n)?a[s]=T(n):a[s]=c(n)}return a}}function P(e){let o=[],l=[],i=new Map;if(i.set(Date,s=>new Date(s)),i.set(Map,(s,n)=>new Map(c(Array.from(s),n))),i.set(Set,(s,n)=>new Set(c(Array.from(s),n))),e.constructorHandlers)for(let s of e.constructorHandlers)i.set(s[0],s[1]);let r=null;return e.proto?a:t;function c(s,n){let f=Object.keys(s),u=new Array(f.length);for(let d=0;d<f.length;d++){let p=f[d],h=s[p];if(typeof h!="object"||h===null)u[p]=h;else if(h.constructor!==Object&&(r=i.get(h.constructor)))u[p]=r(h,n);else if(ArrayBuffer.isView(h))u[p]=T(h);else{let S=o.indexOf(h);S!==-1?u[p]=l[S]:u[p]=n(h)}}return u}function t(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return c(s,t);if(s.constructor!==Object&&(r=i.get(s.constructor)))return r(s,t);let n={};o.push(s),l.push(n);for(let f in s){if(Object.hasOwnProperty.call(s,f)===!1)continue;let u=s[f];if(typeof u!="object"||u===null)n[f]=u;else if(u.constructor!==Object&&(r=i.get(u.constructor)))n[f]=r(u,t);else if(ArrayBuffer.isView(u))n[f]=T(u);else{let d=o.indexOf(u);d!==-1?n[f]=l[d]:n[f]=t(u)}}return o.pop(),l.pop(),n}function a(s){if(typeof s!="object"||s===null)return s;if(Array.isArray(s))return c(s,a);if(s.constructor!==Object&&(r=i.get(s.constructor)))return r(s,a);let n={};o.push(s),l.push(n);for(let f in s){let u=s[f];if(typeof u!="object"||u===null)n[f]=u;else if(u.constructor!==Object&&(r=i.get(u.constructor)))n[f]=r(u,a);else if(ArrayBuffer.isView(u))n[f]=T(u);else{let d=o.indexOf(u);d!==-1?n[f]=l[d]:n[f]=a(u)}}return o.pop(),l.pop(),n}}});var q={};V(q,{defaults:()=>D,expander:()=>J,version:()=>F});var A=_(x(),1);var K=(0,A.default)();function R(e){if(e==null||typeof e!="object")return!1;let o=Object.getPrototypeOf(e);return o!==null&&o!==Object.prototype&&Object.getPrototypeOf(o)!==null?!1:!(Symbol.iterator in e)&&!(Symbol.toStringTag in e)}function g(e){return typeof e=="string"}function y(e){return Number.isSafeInteger(e)&&e>=0}var E="4.0.29";var F=E,D={str:"",from:0,to:0,ifLeftSideIncludesThisThenCropTightly:"",ifLeftSideIncludesThisCropItToo:"",ifRightSideIncludesThisThenCropTightly:"",ifRightSideIncludesThisCropItToo:"",extendToOneSide:!1,wipeAllWhitespaceOnLeft:!1,wipeAllWhitespaceOnRight:!1,addSingleSpaceToPreventAccidentalConcatenation:!1};function J(e){var a,s;let o=/^[0-9a-zA-Z]+$/;function l(n){return g(n)&&!n.trim()}if(R(e)){if(!Object.keys(e).length)throw new Error('string-range-expander: [THROW_ID_02] Input must be a plain object but it\'s been given as a plain object without any keys. However, "from" and "to" settings are obligatory!')}else{let n;throw e===void 0?n="but it is missing completely.":e===null?n="but it was given as null.":n="but it was given as ".concat(typeof e,", equal to:\n").concat(JSON.stringify(e,null,4),"."),new Error("string-range-expander: [THROW_ID_01] Input must be a plain object ".concat(n))}if(!y(e.from))throw new Error("string-range-expander: [THROW_ID_03] The input's \"from\" value resolvedOpts.from, is not a number! It's been given as ".concat(typeof e.from,", equal to ").concat(JSON.stringify(e.from,null,0)));if(!y(e.to))throw new Error("string-range-expander: [THROW_ID_04] The input's \"to\" value resolvedOpts.to, is not a number! It's been given as ".concat(typeof e.to,", equal to ").concat(JSON.stringify(e.to,null,0)));if(e!=null&&e.str&&!e.str[e.from]&&e.from!==e.to)throw new Error('string-range-expander: [THROW_ID_05] The given input string resolvedOpts.str ("'.concat(e.str,'") must contain the character at index "from" ("').concat(e.from,'")'));if(e!=null&&e.str&&!e.str[e.to-1])throw new Error('string-range-expander: [THROW_ID_06] The given input string, resolvedOpts.str ("'.concat(e.str,'") must contain the character at index before "to" ("').concat(e.to-1,'")'));if(e.from>e.to)throw new Error('string-range-expander: [THROW_ID_07] The given "from" index, "'.concat(e.from,'" is greater than "to" index, "').concat(e.to,"\". That's wrong!"));if(e.extendToOneSide===null||g(e.extendToOneSide)&&e.extendToOneSide!=="left"&&e.extendToOneSide!=="right"||!g(e.extendToOneSide)&&e.extendToOneSide!==void 0&&e.extendToOneSide)throw new Error('string-range-expander: [THROW_ID_08] The options value "extendToOneSide" is not recognisable! It\'s set to: "'.concat(e.extendToOneSide,'" (').concat(typeof e.extendToOneSide,'). It has to be either Boolean "false" or one of strings: "left" or "right"'));if(e!=null&&e.ifLeftSideIncludesThisThenCropTightly&&!g(e.ifLeftSideIncludesThisThenCropTightly))throw new Error('string-range-expander: [THROW_ID_09] The option "ifLeftSideIncludesThisThenCropTightly", is not a string! It\'s been given as '.concat(typeof e.ifLeftSideIncludesThisThenCropTightly,", equal to ").concat(JSON.stringify(e.ifLeftSideIncludesThisThenCropTightly,null,0)));if(e!=null&&e.ifLeftSideIncludesThisCropItToo&&!g(e.ifLeftSideIncludesThisCropItToo))throw new Error('string-range-expander: [THROW_ID_10] The option "ifLeftSideIncludesThisCropItToo", is not a string! It\'s been given as '.concat(typeof e.ifLeftSideIncludesThisCropItToo,", equal to ").concat(JSON.stringify(e.ifLeftSideIncludesThisCropItToo,null,0)));if(e!=null&&e.ifRightSideIncludesThisThenCropTightly&&!g(e.ifRightSideIncludesThisThenCropTightly))throw new Error('string-range-expander: [THROW_ID_11] The option "ifRightSideIncludesThisThenCropTightly", is not a string! It\'s been given as '.concat(typeof e.ifRightSideIncludesThisThenCropTightly,", equal to ").concat(JSON.stringify(e.ifRightSideIncludesThisThenCropTightly,null,0)));if(e!=null&&e.ifRightSideIncludesThisCropItToo&&!g(e.ifRightSideIncludesThisCropItToo))throw new Error('string-range-expander: [THROW_ID_12] The option "ifRightSideIncludesThisCropItToo", is not a string! It\'s been given as '.concat(typeof e.ifRightSideIncludesThisCropItToo,", equal to ").concat(JSON.stringify(e.ifRightSideIncludesThisCropItToo,null,0)));let i=b(b({},D),e),r=i.str,c=i.from,t=i.to;if(i.extendToOneSide!=="right"&&(l(r[c-1])&&(l(r[c-2])||i.ifLeftSideIncludesThisCropItToo.includes(r[c-2]))||r[c-1]&&i.ifLeftSideIncludesThisCropItToo.includes(r[c-1])||i.wipeAllWhitespaceOnLeft&&l(r[c-1]))){for(let n=c;n--;)if(!i.ifLeftSideIncludesThisCropItToo.includes(r[n])){if(r[n].trim()){i.wipeAllWhitespaceOnLeft||i.ifLeftSideIncludesThisCropItToo.includes(r[n+1])?c=n+1:c=n+2;break}else if(n===0){i.wipeAllWhitespaceOnLeft?c=0:c=1;break}}}if(i.extendToOneSide!=="left"&&(l(r[t])&&(i.wipeAllWhitespaceOnRight||l(r[t+1]))||i.ifRightSideIncludesThisCropItToo.includes(r[t]))){for(let n=t,f=r.length;n<f;n++)if(!i.ifRightSideIncludesThisCropItToo.includes(r[n])){if(r[n].trim()){i.wipeAllWhitespaceOnRight||i.ifRightSideIncludesThisCropItToo.includes(r[n-1])?t=n:t=n-1;break}else if(n===r.length-1){i.wipeAllWhitespaceOnRight?t=r.length:t=r.length-1;break}}}return(i.extendToOneSide!=="right"&&g(i.ifLeftSideIncludesThisThenCropTightly)&&i.ifLeftSideIncludesThisThenCropTightly&&(r[c-2]&&i.ifLeftSideIncludesThisThenCropTightly.includes(r[c-2])||r[c-1]&&i.ifLeftSideIncludesThisThenCropTightly.includes(r[c-1]))||i.extendToOneSide!=="left"&&g(i.ifRightSideIncludesThisThenCropTightly)&&i.ifRightSideIncludesThisThenCropTightly&&(r[t+1]&&i.ifRightSideIncludesThisThenCropTightly.includes(r[t+1])||r[t]&&i.ifRightSideIncludesThisThenCropTightly.includes(r[t])))&&(i.extendToOneSide!=="right"&&l(r[c-1])&&!i.wipeAllWhitespaceOnLeft&&(c-=1),i.extendToOneSide!=="left"&&l(r[t])&&!i.wipeAllWhitespaceOnRight&&(t+=1)),i.addSingleSpaceToPreventAccidentalConcatenation&&((a=r[c-1])!=null&&a.trim())&&((s=r[t])!=null&&s.trim())&&(!i.ifLeftSideIncludesThisThenCropTightly&&!i.ifRightSideIncludesThisThenCropTightly||!((!i.ifLeftSideIncludesThisThenCropTightly||i.ifLeftSideIncludesThisThenCropTightly.includes(r[c-1]))&&(!i.ifRightSideIncludesThisThenCropTightly||r[t]&&i.ifRightSideIncludesThisThenCropTightly.includes(r[t]))))&&(o.test(r[c-1])||o.test(r[t]))?[c,t," "]:[c,t]}return H(q);})();
|
|
11
11
|
/**
|
|
12
12
|
* @name codsen-utils
|
|
13
13
|
* @fileoverview Various utility functions
|
|
14
|
-
* @version 1.6.
|
|
15
|
-
* @author Roy Revelt
|
|
14
|
+
* @version 1.6.19
|
|
15
|
+
* @author Roy Revelt
|
|
16
16
|
* @license MIT
|
|
17
17
|
* {@link https://codsen.com/os/codsen-utils/}
|
|
18
18
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "string-range-expander",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.29",
|
|
4
4
|
"description": "Expands string index ranges within whitespace boundaries until letters are met",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"expand",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"examples": "node '../../ops/scripts/run-examples.js'",
|
|
43
43
|
"lect": "node '../../ops/lect/lect.js' && npm run prettier -- 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
|
|
44
44
|
"letspublish": "npm publish --provenance || :",
|
|
45
|
-
"lint": "eslint . --fix",
|
|
45
|
+
"lint": "eslint . --fix --concurrency=auto --cache",
|
|
46
46
|
"perf": "node perf/check.js",
|
|
47
47
|
"prep": "echo 'ready'",
|
|
48
48
|
"prettier": "prettier",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"codsen-utils": "^1.6.
|
|
73
|
+
"codsen-utils": "^1.6.19"
|
|
74
74
|
},
|
|
75
75
|
"publishConfig": {
|
|
76
76
|
"registry": "https://registry.npmjs.org/"
|