string-range-expander 4.0.11 → 4.0.12
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.
|
@@ -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.
|
|
4
|
+
* @version 4.0.12
|
|
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
|
-
import{isStr as s,isInt as f,isPlainObject as u}from"codsen-utils";var h="4.0.
|
|
10
|
+
import{isStr as s,isInt as f,isPlainObject as u}from"codsen-utils";var h="4.0.12";var I=h,a={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
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={...a,...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{a 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.
|
|
4
|
+
* @version 4.0.12
|
|
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 D=Object.create;var p=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames,S=Object.getOwnPropertySymbols,L=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var b=(e,o,a)=>o in e?p(e,o,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[o]=a,T=(e,o)=>{for(var a in o||(o={}))w.call(o,a)&&b(e,a,o[a]);if(S)for(var a of S(o))j.call(o,a)&&b(e,a,o[a]);return e};var W=(e,o)=>()=>(o||e((o={exports:{}}).exports,o),o.exports),B=(e,o)=>{for(var a in o)p(e,a,{get:o[a],enumerable:!0})},I=(e,o,a,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of E(o))!w.call(e,n)&&n!==a&&p(e,n,{get:()=>o[n],enumerable:!(r=R(o,n))||r.enumerable});return e};var V=(e,o,a)=>(a=e!=null?D(L(e)):{},I(o||!e||!e.__esModule?p(a,"default",{value:e,enumerable:!0}):a,e)),_=e=>I(p({},"__esModule",{value:!0}),e);var A=W((U,$)=>{"use strict";$.exports=M;function g(e){return e instanceof Buffer?Buffer.from(e):new e.constructor(e.buffer.slice(),e.byteOffset,e.length)}function M(e){if(e=e||{},e.circles)return N(e);return e.proto?r:a;function o(n,l){for(var i=Object.keys(n),s=new Array(i.length),f=0;f<i.length;f++){var t=i[f],u=n[t];typeof u!="object"||u===null?s[t]=u:u instanceof Date?s[t]=new Date(u):ArrayBuffer.isView(u)?s[t]=g(u):s[t]=l(u)}return s}function a(n){if(typeof n!="object"||n===null)return n;if(n instanceof Date)return new Date(n);if(Array.isArray(n))return o(n,a);if(n instanceof Map)return new Map(o(Array.from(n),a));if(n instanceof Set)return new Set(o(Array.from(n),a));var l={};for(var i in n)if(Object.hasOwnProperty.call(n,i)!==!1){var s=n[i];typeof s!="object"||s===null?l[i]=s:s instanceof Date?l[i]=new Date(s):s instanceof Map?l[i]=new Map(o(Array.from(s),a)):s instanceof Set?l[i]=new Set(o(Array.from(s),a)):ArrayBuffer.isView(s)?l[i]=g(s):l[i]=a(s)}return l}function r(n){if(typeof n!="object"||n===null)return n;if(n instanceof Date)return new Date(n);if(Array.isArray(n))return o(n,r);if(n instanceof Map)return new Map(o(Array.from(n),r));if(n instanceof Set)return new Set(o(Array.from(n),r));var l={};for(var i in n){var s=n[i];typeof s!="object"||s===null?l[i]=s:s instanceof Date?l[i]=new Date(s):s instanceof Map?l[i]=new Map(o(Array.from(s),r)):s instanceof Set?l[i]=new Set(o(Array.from(s),r)):ArrayBuffer.isView(s)?l[i]=g(s):l[i]=r(s)}return l}}function N(e){var o=[],a=[];return e.proto?l:n;function r(i,s){for(var f=Object.keys(i),t=new Array(f.length),u=0;u<f.length;u++){var h=f[u],c=i[h];if(typeof c!="object"||c===null)t[h]=c;else if(c instanceof Date)t[h]=new Date(c);else if(ArrayBuffer.isView(c))t[h]=g(c);else{var y=o.indexOf(c);y!==-1?t[h]=a[y]:t[h]=s(c)}}return t}function n(i){if(typeof i!="object"||i===null)return i;if(i instanceof Date)return new Date(i);if(Array.isArray(i))return r(i,n);if(i instanceof Map)return new Map(r(Array.from(i),n));if(i instanceof Set)return new Set(r(Array.from(i),n));var s={};o.push(i),a.push(s);for(var f in i)if(Object.hasOwnProperty.call(i,f)!==!1){var t=i[f];if(typeof t!="object"||t===null)s[f]=t;else if(t instanceof Date)s[f]=new Date(t);else if(t instanceof Map)s[f]=new Map(r(Array.from(t),n));else if(t instanceof Set)s[f]=new Set(r(Array.from(t),n));else if(ArrayBuffer.isView(t))s[f]=g(t);else{var u=o.indexOf(t);u!==-1?s[f]=a[u]:s[f]=n(t)}}return o.pop(),a.pop(),s}function l(i){if(typeof i!="object"||i===null)return i;if(i instanceof Date)return new Date(i);if(Array.isArray(i))return r(i,l);if(i instanceof Map)return new Map(r(Array.from(i),l));if(i instanceof Set)return new Set(r(Array.from(i),l));var s={};o.push(i),a.push(s);for(var f in i){var t=i[f];if(typeof t!="object"||t===null)s[f]=t;else if(t instanceof Date)s[f]=new Date(t);else if(t instanceof Map)s[f]=new Map(r(Array.from(t),l));else if(t instanceof Set)s[f]=new Set(r(Array.from(t),l));else if(ArrayBuffer.isView(t))s[f]=g(t);else{var u=o.indexOf(t);u!==-1?s[f]=a[u]:s[f]=l(t)}}return o.pop(),a.pop(),s}}});var J={};B(J,{defaults:()=>x,expander:()=>F,version:()=>H});var O=V(A(),1);var Q=(0,O.default)();function C(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 d(e){return typeof e=="string"}function m(e){return Number.isSafeInteger(e)&&e>=0}var v="4.0.
|
|
10
|
+
"use strict";var stringRangeExpander=(()=>{var D=Object.create;var p=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames,S=Object.getOwnPropertySymbols,L=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty,j=Object.prototype.propertyIsEnumerable;var b=(e,o,a)=>o in e?p(e,o,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[o]=a,T=(e,o)=>{for(var a in o||(o={}))w.call(o,a)&&b(e,a,o[a]);if(S)for(var a of S(o))j.call(o,a)&&b(e,a,o[a]);return e};var W=(e,o)=>()=>(o||e((o={exports:{}}).exports,o),o.exports),B=(e,o)=>{for(var a in o)p(e,a,{get:o[a],enumerable:!0})},I=(e,o,a,r)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of E(o))!w.call(e,n)&&n!==a&&p(e,n,{get:()=>o[n],enumerable:!(r=R(o,n))||r.enumerable});return e};var V=(e,o,a)=>(a=e!=null?D(L(e)):{},I(o||!e||!e.__esModule?p(a,"default",{value:e,enumerable:!0}):a,e)),_=e=>I(p({},"__esModule",{value:!0}),e);var A=W((U,$)=>{"use strict";$.exports=M;function g(e){return e instanceof Buffer?Buffer.from(e):new e.constructor(e.buffer.slice(),e.byteOffset,e.length)}function M(e){if(e=e||{},e.circles)return N(e);return e.proto?r:a;function o(n,l){for(var i=Object.keys(n),s=new Array(i.length),f=0;f<i.length;f++){var t=i[f],u=n[t];typeof u!="object"||u===null?s[t]=u:u instanceof Date?s[t]=new Date(u):ArrayBuffer.isView(u)?s[t]=g(u):s[t]=l(u)}return s}function a(n){if(typeof n!="object"||n===null)return n;if(n instanceof Date)return new Date(n);if(Array.isArray(n))return o(n,a);if(n instanceof Map)return new Map(o(Array.from(n),a));if(n instanceof Set)return new Set(o(Array.from(n),a));var l={};for(var i in n)if(Object.hasOwnProperty.call(n,i)!==!1){var s=n[i];typeof s!="object"||s===null?l[i]=s:s instanceof Date?l[i]=new Date(s):s instanceof Map?l[i]=new Map(o(Array.from(s),a)):s instanceof Set?l[i]=new Set(o(Array.from(s),a)):ArrayBuffer.isView(s)?l[i]=g(s):l[i]=a(s)}return l}function r(n){if(typeof n!="object"||n===null)return n;if(n instanceof Date)return new Date(n);if(Array.isArray(n))return o(n,r);if(n instanceof Map)return new Map(o(Array.from(n),r));if(n instanceof Set)return new Set(o(Array.from(n),r));var l={};for(var i in n){var s=n[i];typeof s!="object"||s===null?l[i]=s:s instanceof Date?l[i]=new Date(s):s instanceof Map?l[i]=new Map(o(Array.from(s),r)):s instanceof Set?l[i]=new Set(o(Array.from(s),r)):ArrayBuffer.isView(s)?l[i]=g(s):l[i]=r(s)}return l}}function N(e){var o=[],a=[];return e.proto?l:n;function r(i,s){for(var f=Object.keys(i),t=new Array(f.length),u=0;u<f.length;u++){var h=f[u],c=i[h];if(typeof c!="object"||c===null)t[h]=c;else if(c instanceof Date)t[h]=new Date(c);else if(ArrayBuffer.isView(c))t[h]=g(c);else{var y=o.indexOf(c);y!==-1?t[h]=a[y]:t[h]=s(c)}}return t}function n(i){if(typeof i!="object"||i===null)return i;if(i instanceof Date)return new Date(i);if(Array.isArray(i))return r(i,n);if(i instanceof Map)return new Map(r(Array.from(i),n));if(i instanceof Set)return new Set(r(Array.from(i),n));var s={};o.push(i),a.push(s);for(var f in i)if(Object.hasOwnProperty.call(i,f)!==!1){var t=i[f];if(typeof t!="object"||t===null)s[f]=t;else if(t instanceof Date)s[f]=new Date(t);else if(t instanceof Map)s[f]=new Map(r(Array.from(t),n));else if(t instanceof Set)s[f]=new Set(r(Array.from(t),n));else if(ArrayBuffer.isView(t))s[f]=g(t);else{var u=o.indexOf(t);u!==-1?s[f]=a[u]:s[f]=n(t)}}return o.pop(),a.pop(),s}function l(i){if(typeof i!="object"||i===null)return i;if(i instanceof Date)return new Date(i);if(Array.isArray(i))return r(i,l);if(i instanceof Map)return new Map(r(Array.from(i),l));if(i instanceof Set)return new Set(r(Array.from(i),l));var s={};o.push(i),a.push(s);for(var f in i){var t=i[f];if(typeof t!="object"||t===null)s[f]=t;else if(t instanceof Date)s[f]=new Date(t);else if(t instanceof Map)s[f]=new Map(r(Array.from(t),l));else if(t instanceof Set)s[f]=new Set(r(Array.from(t),l));else if(ArrayBuffer.isView(t))s[f]=g(t);else{var u=o.indexOf(t);u!==-1?s[f]=a[u]:s[f]=l(t)}}return o.pop(),a.pop(),s}}});var J={};B(J,{defaults:()=>x,expander:()=>F,version:()=>H});var O=V(A(),1);var Q=(0,O.default)();function C(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 d(e){return typeof e=="string"}function m(e){return Number.isSafeInteger(e)&&e>=0}var v="4.0.12";var H=v,x={str:"",from:0,to:0,ifLeftSideIncludesThisThenCropTightly:"",ifLeftSideIncludesThisCropItToo:"",ifRightSideIncludesThisThenCropTightly:"",ifRightSideIncludesThisCropItToo:"",extendToOneSide:!1,wipeAllWhitespaceOnLeft:!1,wipeAllWhitespaceOnRight:!1,addSingleSpaceToPreventAccidentalConcatenation:!1};function F(e){var s,f;let o=/^[0-9a-zA-Z]+$/;function a(t){return d(t)&&!t.trim()}if(C(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
11
|
${JSON.stringify(e,null,4)}.`,new Error(`string-range-expander: [THROW_ID_01] Input must be a plain object ${t}`)}if(!m(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(!m(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!=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||d(e.extendToOneSide)&&e.extendToOneSide!=="left"&&e.extendToOneSide!=="right"||!d(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!=null&&e.ifLeftSideIncludesThisThenCropTightly&&!d(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!=null&&e.ifLeftSideIncludesThisCropItToo&&!d(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!=null&&e.ifRightSideIncludesThisThenCropTightly&&!d(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!=null&&e.ifRightSideIncludesThisCropItToo&&!d(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 r=T(T({},x),e),n=r.str,l=r.from,i=r.to;if(r.extendToOneSide!=="right"&&(a(n[l-1])&&(a(n[l-2])||r.ifLeftSideIncludesThisCropItToo.includes(n[l-2]))||n[l-1]&&r.ifLeftSideIncludesThisCropItToo.includes(n[l-1])||r.wipeAllWhitespaceOnLeft&&a(n[l-1]))){for(let t=l;t--;)if(!r.ifLeftSideIncludesThisCropItToo.includes(n[t])){if(n[t].trim()){r.wipeAllWhitespaceOnLeft||r.ifLeftSideIncludesThisCropItToo.includes(n[t+1])?l=t+1:l=t+2;break}else if(t===0){r.wipeAllWhitespaceOnLeft?l=0:l=1;break}}}if(r.extendToOneSide!=="left"&&(a(n[i])&&(r.wipeAllWhitespaceOnRight||a(n[i+1]))||r.ifRightSideIncludesThisCropItToo.includes(n[i]))){for(let t=i,u=n.length;t<u;t++)if(!r.ifRightSideIncludesThisCropItToo.includes(n[t])){if(n[t].trim()){r.wipeAllWhitespaceOnRight||r.ifRightSideIncludesThisCropItToo.includes(n[t-1])?i=t:i=t-1;break}else if(t===n.length-1){r.wipeAllWhitespaceOnRight?i=n.length:i=n.length-1;break}}}return(r.extendToOneSide!=="right"&&d(r.ifLeftSideIncludesThisThenCropTightly)&&r.ifLeftSideIncludesThisThenCropTightly&&(n[l-2]&&r.ifLeftSideIncludesThisThenCropTightly.includes(n[l-2])||n[l-1]&&r.ifLeftSideIncludesThisThenCropTightly.includes(n[l-1]))||r.extendToOneSide!=="left"&&d(r.ifRightSideIncludesThisThenCropTightly)&&r.ifRightSideIncludesThisThenCropTightly&&(n[i+1]&&r.ifRightSideIncludesThisThenCropTightly.includes(n[i+1])||n[i]&&r.ifRightSideIncludesThisThenCropTightly.includes(n[i])))&&(r.extendToOneSide!=="right"&&a(n[l-1])&&!r.wipeAllWhitespaceOnLeft&&(l-=1),r.extendToOneSide!=="left"&&a(n[i])&&!r.wipeAllWhitespaceOnRight&&(i+=1)),r.addSingleSpaceToPreventAccidentalConcatenation&&((s=n[l-1])!=null&&s.trim())&&((f=n[i])!=null&&f.trim())&&(!r.ifLeftSideIncludesThisThenCropTightly&&!r.ifRightSideIncludesThisThenCropTightly||!((!r.ifLeftSideIncludesThisThenCropTightly||r.ifLeftSideIncludesThisThenCropTightly.includes(n[l-1]))&&(!r.ifRightSideIncludesThisThenCropTightly||n[i]&&r.ifRightSideIncludesThisThenCropTightly.includes(n[i]))))&&(o.test(n[l-1])||o.test(n[i]))?[l,i," "]:[l,i]}return _(J);})();
|
|
12
12
|
/**
|
|
13
13
|
* @name codsen-utils
|
|
14
14
|
* @fileoverview Various utility functions
|
|
15
|
-
* @version 1.6.
|
|
15
|
+
* @version 1.6.2
|
|
16
16
|
* @author Roy Revelt, Codsen Ltd
|
|
17
17
|
* @license MIT
|
|
18
18
|
* {@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.0.
|
|
3
|
+
"version": "4.0.12",
|
|
4
4
|
"description": "Expands string index ranges within whitespace boundaries until letters are met",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"expand",
|
|
@@ -70,6 +70,6 @@
|
|
|
70
70
|
}
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
|
-
"codsen-utils": "^1.6.
|
|
73
|
+
"codsen-utils": "^1.6.2"
|
|
74
74
|
}
|
|
75
75
|
}
|
package/types/index.d.ts
CHANGED