string-range-expander 4.2.0 → 4.2.1

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,18 @@
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
+ ## 4.2.1 (2026-08-22)
7
+
8
+ ### Performance Improvements
9
+
10
+ - optimise package hot paths and JSON editing ([f3112bd](https://github.com/codsen/codsen/commit/f3112bd7fc0d7c9bc09312d3744c950691d72ca5))
11
+
6
12
  ## 4.2.0 (2026-08-19)
7
13
 
8
14
  ### Bug Fixes
9
15
 
10
16
  - make validation diagnostics safe ([7b01074](https://github.com/codsen/codsen/commit/7b0107476f12734aeb8e82852ba980b187280110))
11
- - resolve review findings REV-004 through REV-007 ([b60e9ee](https://github.com/codsen/codsen/commit/b60e9eeb499af94685cfb87b4970fe025be1fc10))
17
+ - resolve various review findings ([b60e9ee](https://github.com/codsen/codsen/commit/b60e9eeb499af94685cfb87b4970fe025be1fc10))
12
18
  - retire direct publish aliases ([f98e31e](https://github.com/codsen/codsen/commit/f98e31eb89bc185471225664e610b55f34fbf648))
13
19
  - standardise range expander errs ([67d9156](https://github.com/codsen/codsen/commit/67d91562a045bc0deefde365cb4a03fdcff215fb))
14
20
 
@@ -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.2.0
4
+ * @version 4.2.1
5
5
  * @author Roy Revelt
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/string-range-expander/}
8
8
  */
9
9
 
10
- import{formatDiagnosticValue as d,isInt as c,isPlainObject as T,isStr as s}from"codsen-utils";var a="4.2.0";var $=a,u={str:"",from:0,to:0,ifLeftSideIncludesThisThenCropTightly:"",ifLeftSideIncludesThisCropItToo:"",ifRightSideIncludesThisThenCropTightly:"",ifRightSideIncludesThisCropItToo:"",extendToOneSide:!1,wipeAllWhitespaceOnLeft:!1,wipeAllWhitespaceOnRight:!1,addSingleSpaceToPreventAccidentalConcatenation:!1};function S(e){let h=/^[0-9a-zA-Z]+$/;function l(t){return s(t)&&!t.trim()}if(T(e)){if(!Object.keys(e).length)throw new Error(`string-range-expander/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:
10
+ import{formatDiagnosticValue as d,isInt as c,isPlainObject as T,isStr as s}from"codsen-utils";var a="4.2.1";var $=a,u={str:"",from:0,to:0,ifLeftSideIncludesThisThenCropTightly:"",ifLeftSideIncludesThisCropItToo:"",ifRightSideIncludesThisThenCropTightly:"",ifRightSideIncludesThisCropItToo:"",extendToOneSide:!1,wipeAllWhitespaceOnLeft:!1,wipeAllWhitespaceOnRight:!1,addSingleSpaceToPreventAccidentalConcatenation:!1};function S(e){let h=/^[0-9a-zA-Z]+$/;function l(t){return s(t)&&!t.trim()}if(T(e)){if(!Object.keys(e).length)throw new Error(`string-range-expander/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
11
  ${d(e,4)}.`,new Error(`string-range-expander/expander(): [THROW_ID_01] Input must be a plain object ${t}`)}if(!c(e.from))throw new Error(`string-range-expander/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 ${d(e.from)}`);if(!c(e.to))throw new Error(`string-range-expander/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 ${d(e.to)}`);if(e?.str&&!e.str[e.from]&&e.from!==e.to)throw new Error(`string-range-expander/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/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/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/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/expander(): [THROW_ID_09] The option "ifLeftSideIncludesThisThenCropTightly", is not a string! It's been given as ${typeof e.ifLeftSideIncludesThisThenCropTightly}, equal to ${d(e.ifLeftSideIncludesThisThenCropTightly)}`);if(e?.ifLeftSideIncludesThisCropItToo&&!s(e.ifLeftSideIncludesThisCropItToo))throw new Error(`string-range-expander/expander(): [THROW_ID_10] The option "ifLeftSideIncludesThisCropItToo", is not a string! It's been given as ${typeof e.ifLeftSideIncludesThisCropItToo}, equal to ${d(e.ifLeftSideIncludesThisCropItToo)}`);if(e?.ifRightSideIncludesThisThenCropTightly&&!s(e.ifRightSideIncludesThisThenCropTightly))throw new Error(`string-range-expander/expander(): [THROW_ID_11] The option "ifRightSideIncludesThisThenCropTightly", is not a string! It's been given as ${typeof e.ifRightSideIncludesThisThenCropTightly}, equal to ${d(e.ifRightSideIncludesThisThenCropTightly)}`);if(e?.ifRightSideIncludesThisCropItToo&&!s(e.ifRightSideIncludesThisCropItToo))throw new Error(`string-range-expander/expander(): [THROW_ID_12] The option "ifRightSideIncludesThisCropItToo", is not a string! It's been given as ${typeof e.ifRightSideIncludesThisCropItToo}, equal to ${d(e.ifRightSideIncludesThisCropItToo)}`);let i={...u,...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,f=n.length;t<f;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]))))&&(h.test(n[r-1])||h.test(n[o]))?[r,o," "]:[r,o]}export{u as defaults,S as expander,$ as version};
@@ -1,17 +1,17 @@
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.2.0
4
+ * @version 4.2.1
5
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 y=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames,w=Object.getOwnPropertySymbols;var O=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable;var C=(e,i,t)=>i in e?y(e,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[i]=t,$=(e,i)=>{for(var t in i||(i={}))O.call(i,t)&&C(e,t,i[t]);if(w)for(var t of w(i))B.call(i,t)&&C(e,t,i[t]);return e};var M=(e,i)=>{for(var t in i)y(e,t,{get:i[t],enumerable:!0})},V=(e,i,t,n)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of _(i))!O.call(e,r)&&r!==t&&y(e,r,{get:()=>i[r],enumerable:!(n=j(i,r))||n.enumerable});return e};var P=e=>V(y({},"__esModule",{value:!0}),e);var Q={};M(Q,{defaults:()=>W,expander:()=>K,version:()=>q});function H(){let e=[],i=0,t=!1;return{append(n){return t?!1:i+n.length>1999?(e.push("\u2026"),i+=1,t=!0,!1):(e.push(n),i+=n.length,!0)},result(){return e.join("")},stopped(){return t}}}function U(e){return"\\u".concat(e.toString(16).padStart(4,"0"))}function S(e,i){if(e.append('"')){for(let t=0;t<i.length&&!e.stopped();t+=1){let n=i.charCodeAt(t);n===34?e.append('\\"'):n===92?e.append("\\\\"):n===8?e.append("\\b"):n===9?e.append("\\t"):n===10?e.append("\\n"):n===12?e.append("\\f"):n===13?e.append("\\r"):n<32||n===8232||n===8233||n>=55296&&n<=57343?e.append(U(n)):e.append(i[t])}e.append('"')}}function F(e){return e.get&&e.set?"[Getter/Setter]":e.get?"[Getter]":e.set?"[Setter]":"[Accessor]"}function R(e,i){e.append("Symbol(");let t=String(i);t.length>8&&S(e,t.slice(7,-1)),e.append(")")}function A(e,i){typeof i=="symbol"?R(e,i):S(e,String(i))}function g(e,i=0){let t=H(),n=i===4?4:0,r=new WeakSet,s=0;function u(l){n&&t.append(" ".repeat(l*n))}function m(l,a){l&&t.append(","),n&&(t.append("\n"),u(a+1))}function b(l,a,f){n&&a&&(t.append("\n"),u(f)),t.append(l)}function o(l,a){Object.prototype.hasOwnProperty.call(l,"value")?x(l.value,a):t.append(F(l))}function I(l,a){let f;try{f=Reflect.getOwnPropertyDescriptor(l,"length")}catch(d){t.append("[Uninspectable]");return}let c=f==null?void 0:f.value;if(!Number.isSafeInteger(c)||c<0){t.append("[Uninspectable]");return}t.append("[");let p=!1;for(let d=0;d<c&&!t.stopped();d+=1){if(m(p,a),p=!0,s>=50){t.append("[MaxEntries]");break}s+=1;let T;try{T=Reflect.getOwnPropertyDescriptor(l,String(d))}catch(z){t.append("[Uninspectable]");continue}T!=null&&T.enumerable?o(T,a+1):t.append("[Empty]")}b("]",p,a)}function k(l,a){let f;try{f=Reflect.ownKeys(l)}catch(p){t.append("[Uninspectable]");return}t.append("{");let c=!1;for(let p of f){if(t.stopped())break;if(s>=50){m(c,a),c=!0,S(t,"\u2026"),t.append(n?": ":":"),t.append("[MaxEntries]");break}s+=1;let d;try{d=Reflect.getOwnPropertyDescriptor(l,p)}catch(T){m(c,a),c=!0,A(t,p),t.append(n?": ":":"),t.append("[Uninspectable]");continue}d!=null&&d.enumerable&&(m(c,a),c=!0,A(t,p),t.append(n?": ":":"),o(d,a+1))}b("}",c,a)}function L(l,a){if(r.has(l)){t.append("[Circular]");return}if(a>=5){t.append("[MaxDepth]");return}let f;try{f=Array.isArray(l)}catch(c){t.append("[Uninspectable]");return}r.add(l);try{f?I(l,a):k(l,a)}finally{r.delete(l)}}function x(l,a){l===null?t.append("null"):typeof l=="string"?S(t,l):typeof l=="number"?t.append(Object.is(l,-0)?"-0":String(l)):typeof l=="boolean"?t.append(l?"true":"false"):typeof l>"u"?t.append("undefined"):typeof l=="bigint"?t.append("".concat(l,"n")):typeof l=="symbol"?R(t,l):typeof l=="function"?t.append("[Function]"):L(l,a)}try{return x(e,0),t.result()}catch(l){return"[Uninspectable]"}}var J=new Set([..."\u060B$\u20BC\u17DB\xA5\u20A1\u20B1\xA3\u20AC\xA2\u20B9\uFDFC\u20AA\u20A9\u20AD\u20A8\u20AE\u20A6\u20BD\u20AB\u0E3F\u20A9\u20BA\u20B4","$U","$b","B/.","BZ$","Br","Bs","C$","CHF","Ft","Gs","J$","KM","K\u010D","L","MT","NT$","P","Q","R","R$","RD$","RM","Rp","S","S/.","TT$","Z$","kn","kr","lei","z\u0142","\u0192","\u0414\u0438\u043D.","\u0434\u0435\u043D","\u043B\u0432","\u062F.\u0625","Lek"]);function D(e){if(e==null||typeof e!="object")return!1;let i=Object.getPrototypeOf(e);return i!==null&&i!==Object.prototype&&Object.getPrototypeOf(i)!==null?!1:!(Symbol.iterator in e)&&!(Symbol.toStringTag in e)}function h(e){return typeof e=="string"}function v(e){return Number.isSafeInteger(e)&&e>=0}var E="4.2.0";var q=E,W={str:"",from:0,to:0,ifLeftSideIncludesThisThenCropTightly:"",ifLeftSideIncludesThisCropItToo:"",ifRightSideIncludesThisThenCropTightly:"",ifRightSideIncludesThisCropItToo:"",extendToOneSide:!1,wipeAllWhitespaceOnLeft:!1,wipeAllWhitespaceOnRight:!1,addSingleSpaceToPreventAccidentalConcatenation:!1};function K(e){var m,b;let i=/^[0-9a-zA-Z]+$/;function t(o){return h(o)&&!o.trim()}if(D(e)){if(!Object.keys(e).length)throw new Error('string-range-expander/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 o;throw e===void 0?o="but it is missing completely.":e===null?o="but it was given as null.":o="but it was given as ".concat(typeof e,", equal to:\n").concat(g(e,4),"."),new Error("string-range-expander/expander(): [THROW_ID_01] Input must be a plain object ".concat(o))}if(!v(e.from))throw new Error("string-range-expander/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(g(e.from)));if(!v(e.to))throw new Error("string-range-expander/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(g(e.to)));if(e!=null&&e.str&&!e.str[e.from]&&e.from!==e.to)throw new Error('string-range-expander/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/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/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||h(e.extendToOneSide)&&e.extendToOneSide!=="left"&&e.extendToOneSide!=="right"||!h(e.extendToOneSide)&&e.extendToOneSide!==void 0&&e.extendToOneSide)throw new Error('string-range-expander/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&&!h(e.ifLeftSideIncludesThisThenCropTightly))throw new Error('string-range-expander/expander(): [THROW_ID_09] The option "ifLeftSideIncludesThisThenCropTightly", is not a string! It\'s been given as '.concat(typeof e.ifLeftSideIncludesThisThenCropTightly,", equal to ").concat(g(e.ifLeftSideIncludesThisThenCropTightly)));if(e!=null&&e.ifLeftSideIncludesThisCropItToo&&!h(e.ifLeftSideIncludesThisCropItToo))throw new Error('string-range-expander/expander(): [THROW_ID_10] The option "ifLeftSideIncludesThisCropItToo", is not a string! It\'s been given as '.concat(typeof e.ifLeftSideIncludesThisCropItToo,", equal to ").concat(g(e.ifLeftSideIncludesThisCropItToo)));if(e!=null&&e.ifRightSideIncludesThisThenCropTightly&&!h(e.ifRightSideIncludesThisThenCropTightly))throw new Error('string-range-expander/expander(): [THROW_ID_11] The option "ifRightSideIncludesThisThenCropTightly", is not a string! It\'s been given as '.concat(typeof e.ifRightSideIncludesThisThenCropTightly,", equal to ").concat(g(e.ifRightSideIncludesThisThenCropTightly)));if(e!=null&&e.ifRightSideIncludesThisCropItToo&&!h(e.ifRightSideIncludesThisCropItToo))throw new Error('string-range-expander/expander(): [THROW_ID_12] The option "ifRightSideIncludesThisCropItToo", is not a string! It\'s been given as '.concat(typeof e.ifRightSideIncludesThisCropItToo,", equal to ").concat(g(e.ifRightSideIncludesThisCropItToo)));let n=$($({},W),e),r=n.str,s=n.from,u=n.to;if(n.extendToOneSide!=="right"&&(t(r[s-1])&&(t(r[s-2])||n.ifLeftSideIncludesThisCropItToo.includes(r[s-2]))||r[s-1]&&n.ifLeftSideIncludesThisCropItToo.includes(r[s-1])||n.wipeAllWhitespaceOnLeft&&t(r[s-1]))){for(let o=s;o--;)if(!n.ifLeftSideIncludesThisCropItToo.includes(r[o])){if(r[o].trim()){n.wipeAllWhitespaceOnLeft||n.ifLeftSideIncludesThisCropItToo.includes(r[o+1])?s=o+1:s=o+2;break}else if(o===0){n.wipeAllWhitespaceOnLeft?s=0:s=1;break}}}if(n.extendToOneSide!=="left"&&(t(r[u])&&(n.wipeAllWhitespaceOnRight||t(r[u+1]))||n.ifRightSideIncludesThisCropItToo.includes(r[u]))){for(let o=u,I=r.length;o<I;o++)if(!n.ifRightSideIncludesThisCropItToo.includes(r[o])){if(r[o].trim()){n.wipeAllWhitespaceOnRight||n.ifRightSideIncludesThisCropItToo.includes(r[o-1])?u=o:u=o-1;break}else if(o===r.length-1){n.wipeAllWhitespaceOnRight?u=r.length:u=r.length-1;break}}}return(n.extendToOneSide!=="right"&&h(n.ifLeftSideIncludesThisThenCropTightly)&&n.ifLeftSideIncludesThisThenCropTightly&&(r[s-2]&&n.ifLeftSideIncludesThisThenCropTightly.includes(r[s-2])||r[s-1]&&n.ifLeftSideIncludesThisThenCropTightly.includes(r[s-1]))||n.extendToOneSide!=="left"&&h(n.ifRightSideIncludesThisThenCropTightly)&&n.ifRightSideIncludesThisThenCropTightly&&(r[u+1]&&n.ifRightSideIncludesThisThenCropTightly.includes(r[u+1])||r[u]&&n.ifRightSideIncludesThisThenCropTightly.includes(r[u])))&&(n.extendToOneSide!=="right"&&t(r[s-1])&&!n.wipeAllWhitespaceOnLeft&&(s-=1),n.extendToOneSide!=="left"&&t(r[u])&&!n.wipeAllWhitespaceOnRight&&(u+=1)),n.addSingleSpaceToPreventAccidentalConcatenation&&((m=r[s-1])!=null&&m.trim())&&((b=r[u])!=null&&b.trim())&&(!n.ifLeftSideIncludesThisThenCropTightly&&!n.ifRightSideIncludesThisThenCropTightly||!((!n.ifLeftSideIncludesThisThenCropTightly||n.ifLeftSideIncludesThisThenCropTightly.includes(r[s-1]))&&(!n.ifRightSideIncludesThisThenCropTightly||r[u]&&n.ifRightSideIncludesThisThenCropTightly.includes(r[u]))))&&(i.test(r[s-1])||i.test(r[u]))?[s,u," "]:[s,u]}return P(Q);})();
10
+ "use strict";var stringRangeExpander=(()=>{var y=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames,C=Object.getOwnPropertySymbols;var w=Object.prototype.hasOwnProperty,V=Object.prototype.propertyIsEnumerable;var O=(e,i,t)=>i in e?y(e,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[i]=t,$=(e,i)=>{for(var t in i||(i={}))w.call(i,t)&&O(e,t,i[t]);if(C)for(var t of C(i))V.call(i,t)&&O(e,t,i[t]);return e};var P=(e,i)=>{for(var t in i)y(e,t,{get:i[t],enumerable:!0})},M=(e,i,t,n)=>{if(i&&typeof i=="object"||typeof i=="function")for(let r of B(i))!w.call(e,r)&&r!==t&&y(e,r,{get:()=>i[r],enumerable:!(n=_(i,r))||n.enumerable});return e};var H=e=>M(y({},"__esModule",{value:!0}),e);var z={};P(z,{defaults:()=>k,expander:()=>Q,version:()=>K});function U(){let e=[],i=0,t=!1;return{append(n){return t?!1:i+n.length>1999?(e.push("\u2026"),i+=1,t=!0,!1):(e.push(n),i+=n.length,!0)},result(){return e.join("")},stopped(){return t}}}function F(e){return"\\u".concat(e.toString(16).padStart(4,"0"))}function S(e,i){if(e.append('"')){for(let t=0;t<i.length&&!e.stopped();t+=1){let n=i.charCodeAt(t);n===34?e.append('\\"'):n===92?e.append("\\\\"):n===8?e.append("\\b"):n===9?e.append("\\t"):n===10?e.append("\\n"):n===12?e.append("\\f"):n===13?e.append("\\r"):n<32||n===8232||n===8233||n>=55296&&n<=57343?e.append(F(n)):e.append(i[t])}e.append('"')}}function N(e){return e.get&&e.set?"[Getter/Setter]":e.get?"[Getter]":e.set?"[Setter]":"[Accessor]"}function D(e,i){e.append("Symbol(");let t=String(i);t.length>8&&S(e,t.slice(7,-1)),e.append(")")}function A(e,i){typeof i=="symbol"?D(e,i):S(e,String(i))}function g(e,i=0){let t=U(),n=i===4?4:0,r=new WeakSet,o=0;function u(l){n&&t.append(" ".repeat(l*n))}function m(l,a){l&&t.append(","),n&&(t.append("\n"),u(a+1))}function b(l,a,f){n&&a&&(t.append("\n"),u(f)),t.append(l)}function s(l,a){Object.prototype.hasOwnProperty.call(l,"value")?v(l.value,a):t.append(N(l))}function I(l,a){let f;try{f=Reflect.getOwnPropertyDescriptor(l,"length")}catch(d){t.append("[Uninspectable]");return}let c=f==null?void 0:f.value;if(!Number.isSafeInteger(c)||c<0){t.append("[Uninspectable]");return}t.append("[");let p=!1;for(let d=0;d<c&&!t.stopped();d+=1){if(m(p,a),p=!0,o>=50){t.append("[MaxEntries]");break}o+=1;let T;try{T=Reflect.getOwnPropertyDescriptor(l,String(d))}catch(Z){t.append("[Uninspectable]");continue}T!=null&&T.enumerable?s(T,a+1):t.append("[Empty]")}b("]",p,a)}function L(l,a){let f;try{f=Reflect.ownKeys(l)}catch(p){t.append("[Uninspectable]");return}t.append("{");let c=!1;for(let p of f){if(t.stopped())break;if(o>=50){m(c,a),c=!0,S(t,"\u2026"),t.append(n?": ":":"),t.append("[MaxEntries]");break}o+=1;let d;try{d=Reflect.getOwnPropertyDescriptor(l,p)}catch(T){m(c,a),c=!0,A(t,p),t.append(n?": ":":"),t.append("[Uninspectable]");continue}d!=null&&d.enumerable&&(m(c,a),c=!0,A(t,p),t.append(n?": ":":"),s(d,a+1))}b("}",c,a)}function j(l,a){if(r.has(l)){t.append("[Circular]");return}if(a>=5){t.append("[MaxDepth]");return}let f;try{f=Array.isArray(l)}catch(c){t.append("[Uninspectable]");return}r.add(l);try{f?I(l,a):L(l,a)}finally{r.delete(l)}}function v(l,a){l===null?t.append("null"):typeof l=="string"?S(t,l):typeof l=="number"?t.append(Object.is(l,-0)?"-0":String(l)):typeof l=="boolean"?t.append(l?"true":"false"):typeof l>"u"?t.append("undefined"):typeof l=="bigint"?t.append("".concat(l,"n")):typeof l=="symbol"?D(t,l):typeof l=="function"?t.append("[Function]"):j(l,a)}try{return v(e,0),t.result()}catch(l){return"[Uninspectable]"}}var Y=new Set([..."\u060B$\u20BC\u17DB\xA5\u20A1\u20B1\xA3\u20AC\xA2\u20B9\uFDFC\u20AA\u20A9\u20AD\u20A8\u20AE\u20A6\u20BD\u20AB\u0E3F\u20A9\u20BA\u20B4","$U","$b","B/.","BZ$","Br","Bs","C$","CHF","Ft","Gs","J$","KM","K\u010D","L","MT","NT$","P","Q","R","R$","RD$","RM","Rp","S","S/.","TT$","Z$","kn","kr","lei","z\u0142","\u0192","\u0414\u0438\u043D.","\u0434\u0435\u043D","\u043B\u0432","\u062F.\u0625","Lek"]);function E(e){if(e==null||typeof e!="object")return!1;let i=Object.getPrototypeOf(e);return i!==null&&i!==Object.prototype&&Object.getPrototypeOf(i)!==null?!1:!(Symbol.iterator in e)&&!(Symbol.toStringTag in e)}function h(e){return typeof e=="string"}function x(e){return Number.isSafeInteger(e)&&e>=0}var R,X=(R=Object.getOwnPropertyDescriptor(RegExp.prototype,"source"))==null?void 0:R.get;var ee=Date.prototype.getTime;var W="4.2.1";var K=W,k={str:"",from:0,to:0,ifLeftSideIncludesThisThenCropTightly:"",ifLeftSideIncludesThisCropItToo:"",ifRightSideIncludesThisThenCropTightly:"",ifRightSideIncludesThisCropItToo:"",extendToOneSide:!1,wipeAllWhitespaceOnLeft:!1,wipeAllWhitespaceOnRight:!1,addSingleSpaceToPreventAccidentalConcatenation:!1};function Q(e){var m,b;let i=/^[0-9a-zA-Z]+$/;function t(s){return h(s)&&!s.trim()}if(E(e)){if(!Object.keys(e).length)throw new Error('string-range-expander/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 s;throw e===void 0?s="but it is missing completely.":e===null?s="but it was given as null.":s="but it was given as ".concat(typeof e,", equal to:\n").concat(g(e,4),"."),new Error("string-range-expander/expander(): [THROW_ID_01] Input must be a plain object ".concat(s))}if(!x(e.from))throw new Error("string-range-expander/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(g(e.from)));if(!x(e.to))throw new Error("string-range-expander/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(g(e.to)));if(e!=null&&e.str&&!e.str[e.from]&&e.from!==e.to)throw new Error('string-range-expander/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/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/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||h(e.extendToOneSide)&&e.extendToOneSide!=="left"&&e.extendToOneSide!=="right"||!h(e.extendToOneSide)&&e.extendToOneSide!==void 0&&e.extendToOneSide)throw new Error('string-range-expander/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&&!h(e.ifLeftSideIncludesThisThenCropTightly))throw new Error('string-range-expander/expander(): [THROW_ID_09] The option "ifLeftSideIncludesThisThenCropTightly", is not a string! It\'s been given as '.concat(typeof e.ifLeftSideIncludesThisThenCropTightly,", equal to ").concat(g(e.ifLeftSideIncludesThisThenCropTightly)));if(e!=null&&e.ifLeftSideIncludesThisCropItToo&&!h(e.ifLeftSideIncludesThisCropItToo))throw new Error('string-range-expander/expander(): [THROW_ID_10] The option "ifLeftSideIncludesThisCropItToo", is not a string! It\'s been given as '.concat(typeof e.ifLeftSideIncludesThisCropItToo,", equal to ").concat(g(e.ifLeftSideIncludesThisCropItToo)));if(e!=null&&e.ifRightSideIncludesThisThenCropTightly&&!h(e.ifRightSideIncludesThisThenCropTightly))throw new Error('string-range-expander/expander(): [THROW_ID_11] The option "ifRightSideIncludesThisThenCropTightly", is not a string! It\'s been given as '.concat(typeof e.ifRightSideIncludesThisThenCropTightly,", equal to ").concat(g(e.ifRightSideIncludesThisThenCropTightly)));if(e!=null&&e.ifRightSideIncludesThisCropItToo&&!h(e.ifRightSideIncludesThisCropItToo))throw new Error('string-range-expander/expander(): [THROW_ID_12] The option "ifRightSideIncludesThisCropItToo", is not a string! It\'s been given as '.concat(typeof e.ifRightSideIncludesThisCropItToo,", equal to ").concat(g(e.ifRightSideIncludesThisCropItToo)));let n=$($({},k),e),r=n.str,o=n.from,u=n.to;if(n.extendToOneSide!=="right"&&(t(r[o-1])&&(t(r[o-2])||n.ifLeftSideIncludesThisCropItToo.includes(r[o-2]))||r[o-1]&&n.ifLeftSideIncludesThisCropItToo.includes(r[o-1])||n.wipeAllWhitespaceOnLeft&&t(r[o-1]))){for(let s=o;s--;)if(!n.ifLeftSideIncludesThisCropItToo.includes(r[s])){if(r[s].trim()){n.wipeAllWhitespaceOnLeft||n.ifLeftSideIncludesThisCropItToo.includes(r[s+1])?o=s+1:o=s+2;break}else if(s===0){n.wipeAllWhitespaceOnLeft?o=0:o=1;break}}}if(n.extendToOneSide!=="left"&&(t(r[u])&&(n.wipeAllWhitespaceOnRight||t(r[u+1]))||n.ifRightSideIncludesThisCropItToo.includes(r[u]))){for(let s=u,I=r.length;s<I;s++)if(!n.ifRightSideIncludesThisCropItToo.includes(r[s])){if(r[s].trim()){n.wipeAllWhitespaceOnRight||n.ifRightSideIncludesThisCropItToo.includes(r[s-1])?u=s:u=s-1;break}else if(s===r.length-1){n.wipeAllWhitespaceOnRight?u=r.length:u=r.length-1;break}}}return(n.extendToOneSide!=="right"&&h(n.ifLeftSideIncludesThisThenCropTightly)&&n.ifLeftSideIncludesThisThenCropTightly&&(r[o-2]&&n.ifLeftSideIncludesThisThenCropTightly.includes(r[o-2])||r[o-1]&&n.ifLeftSideIncludesThisThenCropTightly.includes(r[o-1]))||n.extendToOneSide!=="left"&&h(n.ifRightSideIncludesThisThenCropTightly)&&n.ifRightSideIncludesThisThenCropTightly&&(r[u+1]&&n.ifRightSideIncludesThisThenCropTightly.includes(r[u+1])||r[u]&&n.ifRightSideIncludesThisThenCropTightly.includes(r[u])))&&(n.extendToOneSide!=="right"&&t(r[o-1])&&!n.wipeAllWhitespaceOnLeft&&(o-=1),n.extendToOneSide!=="left"&&t(r[u])&&!n.wipeAllWhitespaceOnRight&&(u+=1)),n.addSingleSpaceToPreventAccidentalConcatenation&&((m=r[o-1])!=null&&m.trim())&&((b=r[u])!=null&&b.trim())&&(!n.ifLeftSideIncludesThisThenCropTightly&&!n.ifRightSideIncludesThisThenCropTightly||!((!n.ifLeftSideIncludesThisThenCropTightly||n.ifLeftSideIncludesThisThenCropTightly.includes(r[o-1]))&&(!n.ifRightSideIncludesThisThenCropTightly||r[u]&&n.ifRightSideIncludesThisThenCropTightly.includes(r[u]))))&&(i.test(r[o-1])||i.test(r[u]))?[o,u," "]:[o,u]}return H(z);})();
11
11
  /**
12
12
  * @name codsen-utils
13
13
  * @fileoverview Various utility functions
14
- * @version 1.8.0
14
+ * @version 1.9.0
15
15
  * @author Roy Revelt
16
16
  * @license MIT
17
17
  * {@link https://codsen.com/os/codsen-utils/}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "string-range-expander",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
4
4
  "description": "Expands string index ranges within whitespace boundaries until letters are met",
5
5
  "keywords": [
6
6
  "expand",
@@ -68,7 +68,7 @@
68
68
  }
69
69
  },
70
70
  "dependencies": {
71
- "codsen-utils": "^1.8.0"
71
+ "codsen-utils": "^1.9.0"
72
72
  },
73
73
  "engines": {
74
74
  "node": ">=18.20.8"