string-range-expander
Advanced tools
Comparing version 4.0.9 to 4.0.10
/** | ||
* @name string-range-expander | ||
* @fileoverview Expands string index ranges within whitespace boundaries until letters are met | ||
* @version 4.0.9 | ||
* @version 4.0.10 | ||
* @author Roy Revelt, Codsen Ltd | ||
@@ -10,3 +10,3 @@ * @license MIT | ||
import{isStr as s,isInt as f,isPlainObject as u}from"codsen-utils";var h="4.0.9";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: | ||
import{isStr as s,isInt as f,isPlainObject as u}from"codsen-utils";var h="4.0.10";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: | ||
${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}; |
/** | ||
* @name string-range-expander | ||
* @fileoverview Expands string index ranges within whitespace boundaries until letters are met | ||
* @version 4.0.9 | ||
* @version 4.0.10 | ||
* @author Roy Revelt, Codsen Ltd | ||
@@ -10,8 +10,8 @@ * @license MIT | ||
"use strict";var stringRangeExpander=(()=>{var a=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames,g=Object.getOwnPropertySymbols;var p=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var T=(e,t,s)=>t in e?a(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,d=(e,t)=>{for(var s in t||(t={}))p.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 O=(e,t)=>{for(var s in t)a(e,s,{get:t[s],enumerable:!0})},x=(e,t,s,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of y(t))!p.call(e,n)&&n!==s&&a(e,n,{get:()=>t[n],enumerable:!(i=I(t,n))||i.enumerable});return e};var w=e=>x(a({},"__esModule",{value:!0}),e);var v={};O(v,{defaults:()=>b,expander:()=>A,version:()=>E});function m(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 u(e){return typeof e=="string"}function c(e){return Number.isSafeInteger(e)&&e>=0}var S="4.0.9";var E=S,b={str:"",from:0,to:0,ifLeftSideIncludesThisThenCropTightly:"",ifLeftSideIncludesThisCropItToo:"",ifRightSideIncludesThisThenCropTightly:"",ifRightSideIncludesThisCropItToo:"",extendToOneSide:!1,wipeAllWhitespaceOnLeft:!1,wipeAllWhitespaceOnRight:!1,addSingleSpaceToPreventAccidentalConcatenation:!1};function A(e){var f,h;let t=/^[0-9a-zA-Z]+$/;function s(r){return u(r)&&!r.trim()}if(m(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 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: | ||
${JSON.stringify(e,null,4)}.`,new Error(`string-range-expander: [THROW_ID_01] Input must be a plain object ${r}`)}if(!c(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(!c(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||u(e.extendToOneSide)&&e.extendToOneSide!=="left"&&e.extendToOneSide!=="right"||!u(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&&!u(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&&!u(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&&!u(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&&!u(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=d(d({},b),e),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,$=n.length;r<$;r++)if(!i.ifRightSideIncludesThisCropItToo.includes(n[r])){if(n[r].trim()){i.wipeAllWhitespaceOnRight||i.ifRightSideIncludesThisCropItToo.includes(n[r-1])?l=r:l=r-1;break}else if(r===n.length-1){i.wipeAllWhitespaceOnRight?l=n.length:l=n.length-1;break}}}return(i.extendToOneSide!=="right"&&u(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"&&u(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&&((f=n[o-1])!=null&&f.trim())&&((h=n[l])!=null&&h.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 w(v);})(); | ||
"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";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: | ||
${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);})(); | ||
/** | ||
* @name codsen-utils | ||
* @fileoverview Various utility functions | ||
* @version 1.5.0 | ||
* @version 1.6.0 | ||
* @author Roy Revelt, Codsen Ltd | ||
@@ -18,0 +18,0 @@ * @license MIT |
{ | ||
"name": "string-range-expander", | ||
"version": "4.0.9", | ||
"version": "4.0.10", | ||
"description": "Expands string index ranges within whitespace boundaries until letters are met", | ||
@@ -73,4 +73,4 @@ "keywords": [ | ||
"dependencies": { | ||
"codsen-utils": "^1.5.0" | ||
"codsen-utils": "^1.6.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27614
106
Updatedcodsen-utils@^1.6.0