string-range-expander 4.0.5 → 4.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2010-2022 Roy Revelt and other contributors
3
+ Copyright (c) 2010-2023 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
package/README.md CHANGED
@@ -66,6 +66,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
66
66
 
67
67
  MIT License.
68
68
 
69
- Copyright © 2010-2022 Roy Revelt and other contributors.
69
+ Copyright © 2010-2023 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,12 +1,20 @@
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
4
+ * @version 4.0.6
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 u="4.0.5";var m=u,g={str:"",from:0,to:0,ifLeftSideIncludesThisThenCropTightly:"",ifLeftSideIncludesThisCropItToo:"",ifRightSideIncludesThisThenCropTightly:"",ifRightSideIncludesThisCropItToo:"",extendToOneSide:!1,wipeAllWhitespaceOnLeft:!1,wipeAllWhitespaceOnRight:!1,addSingleSpaceToPreventAccidentalConcatenation:!1};function $(t){let f=/^[0-9a-zA-Z]+$/;function o(n){return!n||typeof n!="string"?!1:!n.trim()}function l(n){return typeof n=="string"}if(!t||typeof t!="object"||Array.isArray(t)){let n;throw t===void 0?n="but it is missing completely.":t===null?n="but it was given as null.":n=`but it was given as ${typeof t}, equal to:
11
- ${JSON.stringify(t,null,4)}.`,new Error(`string-range-expander: [THROW_ID_01] Input must be a plain object ${n}`)}else if(typeof t=="object"&&t!==null&&!Array.isArray(t)&&!Object.keys(t).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(typeof t.from!="number")throw new Error(`string-range-expander: [THROW_ID_03] The input's "from" value resolvedOpts.from, is not a number! Currently it's given as ${typeof t.from}, equal to ${JSON.stringify(t.from,null,0)}`);if(typeof t.to!="number")throw new Error(`string-range-expander: [THROW_ID_04] The input's "to" value resolvedOpts.to, is not a number! Currently it's given as ${typeof t.to}, equal to ${JSON.stringify(t.to,null,0)}`);if(t?.str&&!t.str[t.from]&&t.from!==t.to)throw new Error(`string-range-expander: [THROW_ID_05] The given input string resolvedOpts.str ("${t.str}") must contain the character at index "from" ("${t.from}")`);if(t?.str&&!t.str[t.to-1])throw new Error(`string-range-expander: [THROW_ID_06] The given input string, resolvedOpts.str ("${t.str}") must contain the character at index before "to" ("${t.to-1}")`);if(t.from>t.to)throw new Error(`string-range-expander: [THROW_ID_07] The given "from" index, "${t.from}" is greater than "to" index, "${t.to}". That's wrong!`);if(l(t.extendToOneSide)&&t.extendToOneSide!=="left"&&t.extendToOneSide!=="right"||!l(t.extendToOneSide)&&t.extendToOneSide!==void 0&&t.extendToOneSide!==!1)throw new Error(`string-range-expander: [THROW_ID_08] The resolvedOpts.extendToOneSide value is not recognisable! It's set to: "${t.extendToOneSide}" (${typeof t.extendToOneSide}). It has to be either Boolean "false" or strings "left" or "right"`);let e={...g,...t};if(Array.isArray(e.ifLeftSideIncludesThisThenCropTightly)){let n,d;if(e.ifLeftSideIncludesThisThenCropTightly.every((a,h)=>l(a)?!0:(n=h,d=a,!1)))e.ifLeftSideIncludesThisThenCropTightly=e.ifLeftSideIncludesThisThenCropTightly.join("");else throw new Error(`string-range-expander: [THROW_ID_09] The resolvedOpts.ifLeftSideIncludesThisThenCropTightly was set to an array:
12
- ${JSON.stringify(e.ifLeftSideIncludesThisThenCropTightly,null,4)}. Now, that array contains not only string elements. For example, an element at index ${n} is of a type ${typeof d} (equal to ${JSON.stringify(d,null,0)}).`)}let i=e.str,r=e.from,s=e.to;if(e.extendToOneSide!=="right"&&(o(i[r-1])&&(o(i[r-2])||e.ifLeftSideIncludesThisCropItToo.includes(i[r-2]))||i[r-1]&&e.ifLeftSideIncludesThisCropItToo.includes(i[r-1])||e.wipeAllWhitespaceOnLeft&&o(i[r-1]))){for(let n=r;n--;)if(!e.ifLeftSideIncludesThisCropItToo.includes(i[n])){if(i[n].trim()){e.wipeAllWhitespaceOnLeft||e.ifLeftSideIncludesThisCropItToo.includes(i[n+1])?r=n+1:r=n+2;break}else if(n===0){e.wipeAllWhitespaceOnLeft?r=0:r=1;break}}}if(e.extendToOneSide!=="left"&&(o(i[s])&&(e.wipeAllWhitespaceOnRight||o(i[s+1]))||e.ifRightSideIncludesThisCropItToo.includes(i[s]))){for(let n=s,d=i.length;n<d;n++)if(!e.ifRightSideIncludesThisCropItToo.includes(i[n])&&i[n]?.trim()){e.wipeAllWhitespaceOnRight||e.ifRightSideIncludesThisCropItToo.includes(i[n-1])?s=n:s=n-1;break}}return(e.extendToOneSide!=="right"&&l(e.ifLeftSideIncludesThisThenCropTightly)&&e.ifLeftSideIncludesThisThenCropTightly&&(i[r-2]&&e.ifLeftSideIncludesThisThenCropTightly.includes(i[r-2])||i[r-1]&&e.ifLeftSideIncludesThisThenCropTightly.includes(i[r-1]))||e.extendToOneSide!=="left"&&l(e.ifRightSideIncludesThisThenCropTightly)&&e.ifRightSideIncludesThisThenCropTightly&&(i[s+1]&&e.ifRightSideIncludesThisThenCropTightly.includes(i[s+1])||i[s]&&e.ifRightSideIncludesThisThenCropTightly.includes(i[s])))&&(e.extendToOneSide!=="right"&&o(i[r-1])&&!e.wipeAllWhitespaceOnLeft&&(r-=1),e.extendToOneSide!=="left"&&o(i[s])&&!e.wipeAllWhitespaceOnRight&&(s+=1)),e.addSingleSpaceToPreventAccidentalConcatenation&&i[r-1]&&i[r-1].trim()&&i[s]&&i[s].trim()&&(!e.ifLeftSideIncludesThisThenCropTightly&&!e.ifRightSideIncludesThisThenCropTightly||!((!e.ifLeftSideIncludesThisThenCropTightly||e.ifLeftSideIncludesThisThenCropTightly.includes(i[r-1]))&&(!e.ifRightSideIncludesThisThenCropTightly||i[s]&&e.ifRightSideIncludesThisThenCropTightly.includes(i[s]))))&&(f.test(i[r-1])||f.test(i[s]))?[r,s," "]:[r,s]}export{g as defaults,$ as expander,m as version};
10
+ function f(e){if(e==null||typeof e!="object")return!1;let a=Object.getPrototypeOf(e);return a!==null&&a!==Object.prototype&&Object.getPrototypeOf(a)!==null?!1:!(Symbol.iterator in e)&&!(Symbol.toStringTag in e)}function l(e){return typeof e=="string"}function d(e){return Number.isSafeInteger(e)&&e>=0}var h="4.0.6";var y=h,T={str:"",from:0,to:0,ifLeftSideIncludesThisThenCropTightly:"",ifLeftSideIncludesThisCropItToo:"",ifRightSideIncludesThisThenCropTightly:"",ifRightSideIncludesThisCropItToo:"",extendToOneSide:!1,wipeAllWhitespaceOnLeft:!1,wipeAllWhitespaceOnRight:!1,addSingleSpaceToPreventAccidentalConcatenation:!1};function x(e){let a=/^[0-9a-zA-Z]+$/;function o(n){return l(n)&&!n.trim()}if(f(e)){if(!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.")}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 ${typeof e}, equal to:
11
+ ${JSON.stringify(e,null,4)}.`,new Error(`string-range-expander: [THROW_ID_01] Input must be a plain object ${n}`)}if(!d(e.from))throw new Error(`string-range-expander: [THROW_ID_03] The input's "from" value resolvedOpts.from, is not a number! Currently it's given as ${typeof e.from}, equal to ${JSON.stringify(e.from,null,0)}`);if(!d(e.to))throw new Error(`string-range-expander: [THROW_ID_04] The input's "to" value resolvedOpts.to, is not a number! Currently it's 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||l(e.extendToOneSide)&&e.extendToOneSide!=="left"&&e.extendToOneSide!=="right"||!l(e.extendToOneSide)&&e.extendToOneSide!==void 0&&e.extendToOneSide)throw new Error(`string-range-expander: [THROW_ID_08] The resolvedOpts.extendToOneSide value is not recognisable! It's set to: "${e.extendToOneSide}" (${typeof e.extendToOneSide}). It has to be either Boolean "false" or strings "left" or "right"`);let i={...T,...e};if(Array.isArray(i.ifLeftSideIncludesThisThenCropTightly)){let n,u;if(i.ifLeftSideIncludesThisThenCropTightly.every((c,p)=>l(c)?!0:(n=p,u=c,!1)))i.ifLeftSideIncludesThisThenCropTightly=i.ifLeftSideIncludesThisThenCropTightly.join("");else throw new Error(`string-range-expander: [THROW_ID_09] The resolvedOpts.ifLeftSideIncludesThisThenCropTightly was set to an array:
12
+ ${JSON.stringify(i.ifLeftSideIncludesThisThenCropTightly,null,4)}. Now, that array contains not only string elements. For example, an element at index ${n} is of a type ${typeof u} (equal to ${JSON.stringify(u,null,0)}).`)}let t=i.str,r=i.from,s=i.to;if(i.extendToOneSide!=="right"&&(o(t[r-1])&&(o(t[r-2])||i.ifLeftSideIncludesThisCropItToo.includes(t[r-2]))||t[r-1]&&i.ifLeftSideIncludesThisCropItToo.includes(t[r-1])||i.wipeAllWhitespaceOnLeft&&o(t[r-1]))){for(let n=r;n--;)if(!i.ifLeftSideIncludesThisCropItToo.includes(t[n])){if(t[n].trim()){i.wipeAllWhitespaceOnLeft||i.ifLeftSideIncludesThisCropItToo.includes(t[n+1])?r=n+1:r=n+2;break}else if(n===0){i.wipeAllWhitespaceOnLeft?r=0:r=1;break}}}if(i.extendToOneSide!=="left"&&(o(t[s])&&(i.wipeAllWhitespaceOnRight||o(t[s+1]))||i.ifRightSideIncludesThisCropItToo.includes(t[s]))){for(let n=s,u=t.length;n<u;n++)if(!i.ifRightSideIncludesThisCropItToo.includes(t[n])&&t[n]?.trim()){i.wipeAllWhitespaceOnRight||i.ifRightSideIncludesThisCropItToo.includes(t[n-1])?s=n:s=n-1;break}}return(i.extendToOneSide!=="right"&&l(i.ifLeftSideIncludesThisThenCropTightly)&&i.ifLeftSideIncludesThisThenCropTightly&&(t[r-2]&&i.ifLeftSideIncludesThisThenCropTightly.includes(t[r-2])||t[r-1]&&i.ifLeftSideIncludesThisThenCropTightly.includes(t[r-1]))||i.extendToOneSide!=="left"&&l(i.ifRightSideIncludesThisThenCropTightly)&&i.ifRightSideIncludesThisThenCropTightly&&(t[s+1]&&i.ifRightSideIncludesThisThenCropTightly.includes(t[s+1])||t[s]&&i.ifRightSideIncludesThisThenCropTightly.includes(t[s])))&&(i.extendToOneSide!=="right"&&o(t[r-1])&&!i.wipeAllWhitespaceOnLeft&&(r-=1),i.extendToOneSide!=="left"&&o(t[s])&&!i.wipeAllWhitespaceOnRight&&(s+=1)),i.addSingleSpaceToPreventAccidentalConcatenation&&t[r-1]&&t[r-1].trim()&&t[s]&&t[s].trim()&&(!i.ifLeftSideIncludesThisThenCropTightly&&!i.ifRightSideIncludesThisThenCropTightly||!((!i.ifLeftSideIncludesThisThenCropTightly||i.ifLeftSideIncludesThisThenCropTightly.includes(t[r-1]))&&(!i.ifRightSideIncludesThisThenCropTightly||t[s]&&i.ifRightSideIncludesThisThenCropTightly.includes(t[s]))))&&(a.test(t[r-1])||a.test(t[s]))?[r,s," "]:[r,s]}export{T as defaults,x as expander,y as version};
13
+ /**
14
+ * @name codsen-utils
15
+ * @fileoverview Various utility functions
16
+ * @version 1.3.0
17
+ * @author Roy Revelt, Codsen Ltd
18
+ * @license MIT
19
+ * {@link https://codsen.com/os/codsen-utils/}
20
+ */
@@ -1,12 +1,20 @@
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
4
+ * @version 4.0.6
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
- "use strict";var stringRangeExpander=(()=>{var a=Object.defineProperty;var S=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames,g=Object.getOwnPropertySymbols;var p=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable;var T=(e,r,s)=>r in e?a(e,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[r]=s,u=(e,r)=>{for(var s in r||(r={}))p.call(r,s)&&T(e,s,r[s]);if(g)for(var s of g(r))b.call(r,s)&&T(e,s,r[s]);return e};var I=(e,r)=>{for(var s in r)a(e,s,{get:r[s],enumerable:!0})},O=(e,r,s,d)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of x(r))!p.call(e,i)&&i!==s&&a(e,i,{get:()=>r[i],enumerable:!(d=S(r,i))||d.enumerable});return e};var w=e=>O(a({},"__esModule",{value:!0}),e);var v={};I(v,{defaults:()=>$,expander:()=>E,version:()=>C});var m="4.0.5";var C=m,$={str:"",from:0,to:0,ifLeftSideIncludesThisThenCropTightly:"",ifLeftSideIncludesThisCropItToo:"",ifRightSideIncludesThisThenCropTightly:"",ifRightSideIncludesThisCropItToo:"",extendToOneSide:!1,wipeAllWhitespaceOnLeft:!1,wipeAllWhitespaceOnRight:!1,addSingleSpaceToPreventAccidentalConcatenation:!1};function E(e){var h;let r=/^[0-9a-zA-Z]+$/;function s(n){return!n||typeof n!="string"?!1:!n.trim()}function d(n){return typeof n=="string"}if(!e||typeof e!="object"||Array.isArray(e)){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 ${typeof e}, equal to:
11
- ${JSON.stringify(e,null,4)}.`,new Error(`string-range-expander: [THROW_ID_01] Input must be a plain object ${n}`)}else if(typeof e=="object"&&e!==null&&!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(typeof e.from!="number")throw new Error(`string-range-expander: [THROW_ID_03] The input's "from" value resolvedOpts.from, is not a number! Currently it's given as ${typeof e.from}, equal to ${JSON.stringify(e.from,null,0)}`);if(typeof e.to!="number")throw new Error(`string-range-expander: [THROW_ID_04] The input's "to" value resolvedOpts.to, is not a number! Currently it's given as ${typeof e.to}, equal to ${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 ("${e.str}") must contain the character at index "from" ("${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 ("${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(d(e.extendToOneSide)&&e.extendToOneSide!=="left"&&e.extendToOneSide!=="right"||!d(e.extendToOneSide)&&e.extendToOneSide!==void 0&&e.extendToOneSide!==!1)throw new Error(`string-range-expander: [THROW_ID_08] The resolvedOpts.extendToOneSide value is not recognisable! It's set to: "${e.extendToOneSide}" (${typeof e.extendToOneSide}). It has to be either Boolean "false" or strings "left" or "right"`);let i=u(u({},$),e);if(Array.isArray(i.ifLeftSideIncludesThisThenCropTightly)){let n,f;if(i.ifLeftSideIncludesThisThenCropTightly.every((c,y)=>d(c)?!0:(n=y,f=c,!1)))i.ifLeftSideIncludesThisThenCropTightly=i.ifLeftSideIncludesThisThenCropTightly.join("");else throw new Error(`string-range-expander: [THROW_ID_09] The resolvedOpts.ifLeftSideIncludesThisThenCropTightly was set to an array:
12
- ${JSON.stringify(i.ifLeftSideIncludesThisThenCropTightly,null,4)}. Now, that array contains not only string elements. For example, an element at index ${n} is of a type ${typeof f} (equal to ${JSON.stringify(f,null,0)}).`)}let t=i.str,o=i.from,l=i.to;if(i.extendToOneSide!=="right"&&(s(t[o-1])&&(s(t[o-2])||i.ifLeftSideIncludesThisCropItToo.includes(t[o-2]))||t[o-1]&&i.ifLeftSideIncludesThisCropItToo.includes(t[o-1])||i.wipeAllWhitespaceOnLeft&&s(t[o-1]))){for(let n=o;n--;)if(!i.ifLeftSideIncludesThisCropItToo.includes(t[n])){if(t[n].trim()){i.wipeAllWhitespaceOnLeft||i.ifLeftSideIncludesThisCropItToo.includes(t[n+1])?o=n+1:o=n+2;break}else if(n===0){i.wipeAllWhitespaceOnLeft?o=0:o=1;break}}}if(i.extendToOneSide!=="left"&&(s(t[l])&&(i.wipeAllWhitespaceOnRight||s(t[l+1]))||i.ifRightSideIncludesThisCropItToo.includes(t[l]))){for(let n=l,f=t.length;n<f;n++)if(!i.ifRightSideIncludesThisCropItToo.includes(t[n])&&((h=t[n])!=null&&h.trim())){i.wipeAllWhitespaceOnRight||i.ifRightSideIncludesThisCropItToo.includes(t[n-1])?l=n:l=n-1;break}}return(i.extendToOneSide!=="right"&&d(i.ifLeftSideIncludesThisThenCropTightly)&&i.ifLeftSideIncludesThisThenCropTightly&&(t[o-2]&&i.ifLeftSideIncludesThisThenCropTightly.includes(t[o-2])||t[o-1]&&i.ifLeftSideIncludesThisThenCropTightly.includes(t[o-1]))||i.extendToOneSide!=="left"&&d(i.ifRightSideIncludesThisThenCropTightly)&&i.ifRightSideIncludesThisThenCropTightly&&(t[l+1]&&i.ifRightSideIncludesThisThenCropTightly.includes(t[l+1])||t[l]&&i.ifRightSideIncludesThisThenCropTightly.includes(t[l])))&&(i.extendToOneSide!=="right"&&s(t[o-1])&&!i.wipeAllWhitespaceOnLeft&&(o-=1),i.extendToOneSide!=="left"&&s(t[l])&&!i.wipeAllWhitespaceOnRight&&(l+=1)),i.addSingleSpaceToPreventAccidentalConcatenation&&t[o-1]&&t[o-1].trim()&&t[l]&&t[l].trim()&&(!i.ifLeftSideIncludesThisThenCropTightly&&!i.ifRightSideIncludesThisThenCropTightly||!((!i.ifLeftSideIncludesThisThenCropTightly||i.ifLeftSideIncludesThisThenCropTightly.includes(t[o-1]))&&(!i.ifRightSideIncludesThisThenCropTightly||t[l]&&i.ifRightSideIncludesThisThenCropTightly.includes(t[l]))))&&(r.test(t[o-1])||r.test(t[l]))?[o,l," "]:[o,l]}return w(v);})();
10
+ "use strict";var stringRangeExpander=(()=>{var d=Object.defineProperty;var x=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames,g=Object.getOwnPropertySymbols;var m=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var T=(e,t,s)=>t in e?d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,c=(e,t)=>{for(var s in t||(t={}))m.call(t,s)&&T(e,s,t[s]);if(g)for(var s of g(t))C.call(t,s)&&T(e,s,t[s]);return e};var I=(e,t)=>{for(var s in t)d(e,s,{get:t[s],enumerable:!0})},w=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of O(t))!m.call(e,n)&&n!==s&&d(e,n,{get:()=>t[n],enumerable:!(i=x(t,n))||i.enumerable});return e};var A=e=>w(d({},"__esModule",{value:!0}),e);var L={};I(L,{defaults:()=>$,expander:()=>D,version:()=>v});function b(e){if(e==null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null?!1:!(Symbol.iterator in e)&&!(Symbol.toStringTag in e)}function a(e){return typeof e=="string"}function f(e){return Number.isSafeInteger(e)&&e>=0}var S="4.0.6";var v=S,$={str:"",from:0,to:0,ifLeftSideIncludesThisThenCropTightly:"",ifLeftSideIncludesThisCropItToo:"",ifRightSideIncludesThisThenCropTightly:"",ifRightSideIncludesThisCropItToo:"",extendToOneSide:!1,wipeAllWhitespaceOnLeft:!1,wipeAllWhitespaceOnRight:!1,addSingleSpaceToPreventAccidentalConcatenation:!1};function D(e){var h;let t=/^[0-9a-zA-Z]+$/;function s(r){return a(r)&&!r.trim()}if(b(e)){if(!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.")}else{let r;throw e===void 0?r="but it is missing completely.":e===null?r="but it was given as null.":r=`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 ${r}`)}if(!f(e.from))throw new Error(`string-range-expander: [THROW_ID_03] The input's "from" value resolvedOpts.from, is not a number! Currently it's 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! Currently it's given as ${typeof e.to}, equal to ${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 ("${e.str}") must contain the character at index "from" ("${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 ("${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||a(e.extendToOneSide)&&e.extendToOneSide!=="left"&&e.extendToOneSide!=="right"||!a(e.extendToOneSide)&&e.extendToOneSide!==void 0&&e.extendToOneSide)throw new Error(`string-range-expander: [THROW_ID_08] The resolvedOpts.extendToOneSide value is not recognisable! It's set to: "${e.extendToOneSide}" (${typeof e.extendToOneSide}). It has to be either Boolean "false" or strings "left" or "right"`);let i=c(c({},$),e);if(Array.isArray(i.ifLeftSideIncludesThisThenCropTightly)){let r,u;if(i.ifLeftSideIncludesThisThenCropTightly.every((p,y)=>a(p)?!0:(r=y,u=p,!1)))i.ifLeftSideIncludesThisThenCropTightly=i.ifLeftSideIncludesThisThenCropTightly.join("");else throw new Error(`string-range-expander: [THROW_ID_09] The resolvedOpts.ifLeftSideIncludesThisThenCropTightly was set to an array:
12
+ ${JSON.stringify(i.ifLeftSideIncludesThisThenCropTightly,null,4)}. Now, that array contains not only string elements. For example, an element at index ${r} is of a type ${typeof u} (equal to ${JSON.stringify(u,null,0)}).`)}let n=i.str,o=i.from,l=i.to;if(i.extendToOneSide!=="right"&&(s(n[o-1])&&(s(n[o-2])||i.ifLeftSideIncludesThisCropItToo.includes(n[o-2]))||n[o-1]&&i.ifLeftSideIncludesThisCropItToo.includes(n[o-1])||i.wipeAllWhitespaceOnLeft&&s(n[o-1]))){for(let r=o;r--;)if(!i.ifLeftSideIncludesThisCropItToo.includes(n[r])){if(n[r].trim()){i.wipeAllWhitespaceOnLeft||i.ifLeftSideIncludesThisCropItToo.includes(n[r+1])?o=r+1:o=r+2;break}else if(r===0){i.wipeAllWhitespaceOnLeft?o=0:o=1;break}}}if(i.extendToOneSide!=="left"&&(s(n[l])&&(i.wipeAllWhitespaceOnRight||s(n[l+1]))||i.ifRightSideIncludesThisCropItToo.includes(n[l]))){for(let r=l,u=n.length;r<u;r++)if(!i.ifRightSideIncludesThisCropItToo.includes(n[r])&&((h=n[r])!=null&&h.trim())){i.wipeAllWhitespaceOnRight||i.ifRightSideIncludesThisCropItToo.includes(n[r-1])?l=r:l=r-1;break}}return(i.extendToOneSide!=="right"&&a(i.ifLeftSideIncludesThisThenCropTightly)&&i.ifLeftSideIncludesThisThenCropTightly&&(n[o-2]&&i.ifLeftSideIncludesThisThenCropTightly.includes(n[o-2])||n[o-1]&&i.ifLeftSideIncludesThisThenCropTightly.includes(n[o-1]))||i.extendToOneSide!=="left"&&a(i.ifRightSideIncludesThisThenCropTightly)&&i.ifRightSideIncludesThisThenCropTightly&&(n[l+1]&&i.ifRightSideIncludesThisThenCropTightly.includes(n[l+1])||n[l]&&i.ifRightSideIncludesThisThenCropTightly.includes(n[l])))&&(i.extendToOneSide!=="right"&&s(n[o-1])&&!i.wipeAllWhitespaceOnLeft&&(o-=1),i.extendToOneSide!=="left"&&s(n[l])&&!i.wipeAllWhitespaceOnRight&&(l+=1)),i.addSingleSpaceToPreventAccidentalConcatenation&&n[o-1]&&n[o-1].trim()&&n[l]&&n[l].trim()&&(!i.ifLeftSideIncludesThisThenCropTightly&&!i.ifRightSideIncludesThisThenCropTightly||!((!i.ifLeftSideIncludesThisThenCropTightly||i.ifLeftSideIncludesThisThenCropTightly.includes(n[o-1]))&&(!i.ifRightSideIncludesThisThenCropTightly||n[l]&&i.ifRightSideIncludesThisThenCropTightly.includes(n[l]))))&&(t.test(n[o-1])||t.test(n[l]))?[o,l," "]:[o,l]}return A(L);})();
13
+ /**
14
+ * @name codsen-utils
15
+ * @fileoverview Various utility functions
16
+ * @version 1.3.0
17
+ * @author Roy Revelt, Codsen Ltd
18
+ * @license MIT
19
+ * {@link https://codsen.com/os/codsen-utils/}
20
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "string-range-expander",
3
- "version": "4.0.5",
3
+ "version": "4.0.6",
4
4
  "description": "Expands string index ranges within whitespace boundaries until letters are met",
5
5
  "keywords": [
6
6
  "expand",