string-left-right 6.0.12 → 6.0.13

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,13 +1,13 @@
1
1
  /**
2
2
  * @name string-left-right
3
3
  * @fileoverview Looks up the first non-whitespace character to the left/right of a given index
4
- * @version 6.0.12
4
+ * @version 6.0.13
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/string-left-right/}
8
8
  */
9
9
 
10
- import{isPlainObject as p,isStr as b,isInt as R}from"codsen-utils";import I from"rfdc";var S="6.0.12";var $=I(),j=S,c="\xA0";function J(n){let e={value:n,hungry:!1,optional:!1};return(e.value.endsWith("?*")||e.value.endsWith("*?"))&&e.value.length>2?(e.value=e.value.slice(0,e.value.length-2),e.optional=!0,e.hungry=!0):e.value.endsWith("?")&&e.value.length>1?(e.value=e.value.slice(0,~-e.value.length),e.optional=!0):e.value.endsWith("*")&&e.value.length>1&&(e.value=e.value.slice(0,~-e.value.length),e.hungry=!0),e}function D({str:n,idx:e=0,stopAtNewlines:l=!1,stopAtRawNbsp:u=!1}){if(typeof n!="string"||!n.length||((!e||typeof e!="number")&&(e=0),!n[e+1]))return null;if(n[e+1]&&(n[e+1].trim()||l&&`
10
+ import{isPlainObject as p,isStr as b,isInt as R}from"codsen-utils";import I from"rfdc";var S="6.0.13";var $=I(),j=S,c="\xA0";function J(n){let e={value:n,hungry:!1,optional:!1};return(e.value.endsWith("?*")||e.value.endsWith("*?"))&&e.value.length>2?(e.value=e.value.slice(0,e.value.length-2),e.optional=!0,e.hungry=!0):e.value.endsWith("?")&&e.value.length>1?(e.value=e.value.slice(0,~-e.value.length),e.optional=!0):e.value.endsWith("*")&&e.value.length>1&&(e.value=e.value.slice(0,~-e.value.length),e.hungry=!0),e}function D({str:n,idx:e=0,stopAtNewlines:l=!1,stopAtRawNbsp:u=!1}){if(typeof n!="string"||!n.length||((!e||typeof e!="number")&&(e=0),!n[e+1]))return null;if(n[e+1]&&(n[e+1].trim()||l&&`
11
11
  \r`.includes(n[e+1])||u&&n[e+1]===c))return e+1;if(n[e+2]&&(n[e+2].trim()||l&&`
12
12
  \r`.includes(n[e+2])||u&&n[e+2]===c))return e+2;for(let t=e+1,m=n.length;t<m;t++)if(n[t].trim()||l&&`
13
13
  \r`.includes(n[t])||u&&n[t]===c)return t;return null}function E(n,e=0){return D({str:n,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!1})}function k(n,e){return D({str:n,idx:e,stopAtNewlines:!0,stopAtRawNbsp:!1})}function M(n,e){return D({str:n,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!0})}function V({str:n,idx:e,stopAtNewlines:l,stopAtRawNbsp:u}){if(typeof n!="string"||!n.length||((!e||typeof e!="number")&&(e=0),e<1))return null;if(n[~-e]&&(n[~-e].trim()||l&&`
@@ -1,31 +1,31 @@
1
1
  /**
2
2
  * @name string-left-right
3
3
  * @fileoverview Looks up the first non-whitespace character to the left/right of a given index
4
- * @version 6.0.12
4
+ * @version 6.0.13
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/string-left-right/}
8
8
  */
9
9
 
10
- "use strict";var stringLeftRight=(()=>{var P=Object.create;var D=Object.defineProperty;var W=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames,T=Object.getOwnPropertySymbols,Q=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable;var C=(n,e,l)=>e in n?D(n,e,{enumerable:!0,configurable:!0,writable:!0,value:l}):n[e]=l,p=(n,e)=>{for(var l in e||(e={}))I.call(e,l)&&C(n,l,e[l]);if(T)for(var l of T(e))H.call(e,l)&&C(n,l,e[l]);return n};var _=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),K=(n,e)=>{for(var l in e)D(n,l,{get:e[l],enumerable:!0})},L=(n,e,l,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of x(e))!I.call(n,r)&&r!==l&&D(n,r,{get:()=>e[r],enumerable:!(s=W(e,r))||s.enumerable});return n};var Z=(n,e,l)=>(l=n!=null?P(Q(n)):{},L(e||!n||!n.__esModule?D(l,"default",{value:n,enumerable:!0}):l,n)),z=n=>L(D({},"__esModule",{value:!0}),n);var F=_((fe,j)=>{"use strict";j.exports=G;function d(n){return n instanceof Buffer?Buffer.from(n):new n.constructor(n.buffer.slice(),n.byteOffset,n.length)}function G(n){if(n=n||{},n.circles)return Y(n);return n.proto?s:l;function e(r,u){for(var t=Object.keys(r),i=new Array(t.length),f=0;f<t.length;f++){var o=t[f],a=r[o];typeof a!="object"||a===null?i[o]=a:a instanceof Date?i[o]=new Date(a):ArrayBuffer.isView(a)?i[o]=d(a):i[o]=u(a)}return i}function l(r){if(typeof r!="object"||r===null)return r;if(r instanceof Date)return new Date(r);if(Array.isArray(r))return e(r,l);if(r instanceof Map)return new Map(e(Array.from(r),l));if(r instanceof Set)return new Set(e(Array.from(r),l));var u={};for(var t in r)if(Object.hasOwnProperty.call(r,t)!==!1){var i=r[t];typeof i!="object"||i===null?u[t]=i:i instanceof Date?u[t]=new Date(i):i instanceof Map?u[t]=new Map(e(Array.from(i),l)):i instanceof Set?u[t]=new Set(e(Array.from(i),l)):ArrayBuffer.isView(i)?u[t]=d(i):u[t]=l(i)}return u}function s(r){if(typeof r!="object"||r===null)return r;if(r instanceof Date)return new Date(r);if(Array.isArray(r))return e(r,s);if(r instanceof Map)return new Map(e(Array.from(r),s));if(r instanceof Set)return new Set(e(Array.from(r),s));var u={};for(var t in r){var i=r[t];typeof i!="object"||i===null?u[t]=i:i instanceof Date?u[t]=new Date(i):i instanceof Map?u[t]=new Map(e(Array.from(i),s)):i instanceof Set?u[t]=new Set(e(Array.from(i),s)):ArrayBuffer.isView(i)?u[t]=d(i):u[t]=s(i)}return u}}function Y(n){var e=[],l=[];return n.proto?u:r;function s(t,i){for(var f=Object.keys(t),o=new Array(f.length),a=0;a<f.length;a++){var m=f[a],g=t[m];if(typeof g!="object"||g===null)o[m]=g;else if(g instanceof Date)o[m]=new Date(g);else if(ArrayBuffer.isView(g))o[m]=d(g);else{var w=e.indexOf(g);w!==-1?o[m]=l[w]:o[m]=i(g)}}return o}function r(t){if(typeof t!="object"||t===null)return t;if(t instanceof Date)return new Date(t);if(Array.isArray(t))return s(t,r);if(t instanceof Map)return new Map(s(Array.from(t),r));if(t instanceof Set)return new Set(s(Array.from(t),r));var i={};e.push(t),l.push(i);for(var f in t)if(Object.hasOwnProperty.call(t,f)!==!1){var o=t[f];if(typeof o!="object"||o===null)i[f]=o;else if(o instanceof Date)i[f]=new Date(o);else if(o instanceof Map)i[f]=new Map(s(Array.from(o),r));else if(o instanceof Set)i[f]=new Set(s(Array.from(o),r));else if(ArrayBuffer.isView(o))i[f]=d(o);else{var a=e.indexOf(o);a!==-1?i[f]=l[a]:i[f]=r(o)}}return e.pop(),l.pop(),i}function u(t){if(typeof t!="object"||t===null)return t;if(t instanceof Date)return new Date(t);if(Array.isArray(t))return s(t,u);if(t instanceof Map)return new Map(s(Array.from(t),u));if(t instanceof Set)return new Set(s(Array.from(t),u));var i={};e.push(t),l.push(i);for(var f in t){var o=t[f];if(typeof o!="object"||o===null)i[f]=o;else if(o instanceof Date)i[f]=new Date(o);else if(o instanceof Map)i[f]=new Map(s(Array.from(o),u));else if(o instanceof Set)i[f]=new Set(s(Array.from(o),u));else if(ArrayBuffer.isView(o))i[f]=d(o);else{var a=e.indexOf(o);a!==-1?i[f]=l[a]:i[f]=u(o)}}return e.pop(),l.pop(),i}}});var se={};K(se,{chompLeft:()=>ie,chompRight:()=>oe,left:()=>A,leftSeq:()=>B,leftStopAtNewLines:()=>le,leftStopAtRawNbsp:()=>re,right:()=>S,rightSeq:()=>q,rightStopAtNewLines:()=>ne,rightStopAtRawNbsp:()=>te,version:()=>k});function $(n){if(n==null||typeof n!="object")return!1;let e=Object.getPrototypeOf(n);return e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null?!1:!(Symbol.iterator in n)&&!(Symbol.toStringTag in n)}function b(n){return typeof n=="string"}function v(n){return Number.isSafeInteger(n)&&n>=0}var M=Z(F(),1);var J="6.0.12";var h=(0,M.default)(),k=J,y="\xA0";function ee(n){let e={value:n,hungry:!1,optional:!1};return(e.value.endsWith("?*")||e.value.endsWith("*?"))&&e.value.length>2?(e.value=e.value.slice(0,e.value.length-2),e.optional=!0,e.hungry=!0):e.value.endsWith("?")&&e.value.length>1?(e.value=e.value.slice(0,~-e.value.length),e.optional=!0):e.value.endsWith("*")&&e.value.length>1&&(e.value=e.value.slice(0,~-e.value.length),e.hungry=!0),e}function O({str:n,idx:e=0,stopAtNewlines:l=!1,stopAtRawNbsp:s=!1}){if(typeof n!="string"||!n.length||((!e||typeof e!="number")&&(e=0),!n[e+1]))return null;if(n[e+1]&&(n[e+1].trim()||l&&`
10
+ "use strict";var stringLeftRight=(()=>{var x=Object.create;var D=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames,C=Object.getOwnPropertySymbols,H=Object.getPrototypeOf,L=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable;var I=(n,e,l)=>e in n?D(n,e,{enumerable:!0,configurable:!0,writable:!0,value:l}):n[e]=l,p=(n,e)=>{for(var l in e||(e={}))L.call(e,l)&&I(n,l,e[l]);if(C)for(var l of C(e))K.call(e,l)&&I(n,l,e[l]);return n};var Z=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),z=(n,e)=>{for(var l in e)D(n,l,{get:e[l],enumerable:!0})},j=(n,e,l,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of _(e))!L.call(n,r)&&r!==l&&D(n,r,{get:()=>e[r],enumerable:!(s=Q(e,r))||s.enumerable});return n};var F=(n,e,l)=>(l=n!=null?x(H(n)):{},j(e||!n||!n.__esModule?D(l,"default",{value:n,enumerable:!0}):l,n)),G=n=>j(D({},"__esModule",{value:!0}),n);var V=Z((fe,J)=>{"use strict";J.exports=Y;function b(n){return n instanceof Buffer?Buffer.from(n):new n.constructor(n.buffer.slice(),n.byteOffset,n.length)}function Y(n){if(n=n||{},n.circles)return X(n);return n.proto?s:l;function e(r,u){for(var t=Object.keys(r),o=new Array(t.length),f=0;f<t.length;f++){var i=t[f],a=r[i];typeof a!="object"||a===null?o[i]=a:a instanceof Date?o[i]=new Date(a):ArrayBuffer.isView(a)?o[i]=b(a):o[i]=u(a)}return o}function l(r){if(typeof r!="object"||r===null)return r;if(r instanceof Date)return new Date(r);if(Array.isArray(r))return e(r,l);if(r instanceof Map)return new Map(e(Array.from(r),l));if(r instanceof Set)return new Set(e(Array.from(r),l));var u={};for(var t in r)if(Object.hasOwnProperty.call(r,t)!==!1){var o=r[t];typeof o!="object"||o===null?u[t]=o:o instanceof Date?u[t]=new Date(o):o instanceof Map?u[t]=new Map(e(Array.from(o),l)):o instanceof Set?u[t]=new Set(e(Array.from(o),l)):ArrayBuffer.isView(o)?u[t]=b(o):u[t]=l(o)}return u}function s(r){if(typeof r!="object"||r===null)return r;if(r instanceof Date)return new Date(r);if(Array.isArray(r))return e(r,s);if(r instanceof Map)return new Map(e(Array.from(r),s));if(r instanceof Set)return new Set(e(Array.from(r),s));var u={};for(var t in r){var o=r[t];typeof o!="object"||o===null?u[t]=o:o instanceof Date?u[t]=new Date(o):o instanceof Map?u[t]=new Map(e(Array.from(o),s)):o instanceof Set?u[t]=new Set(e(Array.from(o),s)):ArrayBuffer.isView(o)?u[t]=b(o):u[t]=s(o)}return u}}function X(n){var e=[],l=[];return n.proto?u:r;function s(t,o){for(var f=Object.keys(t),i=new Array(f.length),a=0;a<f.length;a++){var m=f[a],g=t[m];if(typeof g!="object"||g===null)i[m]=g;else if(g instanceof Date)i[m]=new Date(g);else if(ArrayBuffer.isView(g))i[m]=b(g);else{var w=e.indexOf(g);w!==-1?i[m]=l[w]:i[m]=o(g)}}return i}function r(t){if(typeof t!="object"||t===null)return t;if(t instanceof Date)return new Date(t);if(Array.isArray(t))return s(t,r);if(t instanceof Map)return new Map(s(Array.from(t),r));if(t instanceof Set)return new Set(s(Array.from(t),r));var o={};e.push(t),l.push(o);for(var f in t)if(Object.hasOwnProperty.call(t,f)!==!1){var i=t[f];if(typeof i!="object"||i===null)o[f]=i;else if(i instanceof Date)o[f]=new Date(i);else if(i instanceof Map)o[f]=new Map(s(Array.from(i),r));else if(i instanceof Set)o[f]=new Set(s(Array.from(i),r));else if(ArrayBuffer.isView(i))o[f]=b(i);else{var a=e.indexOf(i);a!==-1?o[f]=l[a]:o[f]=r(i)}}return e.pop(),l.pop(),o}function u(t){if(typeof t!="object"||t===null)return t;if(t instanceof Date)return new Date(t);if(Array.isArray(t))return s(t,u);if(t instanceof Map)return new Map(s(Array.from(t),u));if(t instanceof Set)return new Set(s(Array.from(t),u));var o={};e.push(t),l.push(o);for(var f in t){var i=t[f];if(typeof i!="object"||i===null)o[f]=i;else if(i instanceof Date)o[f]=new Date(i);else if(i instanceof Map)o[f]=new Map(s(Array.from(i),u));else if(i instanceof Set)o[f]=new Set(s(Array.from(i),u));else if(ArrayBuffer.isView(i))o[f]=b(i);else{var a=e.indexOf(i);a!==-1?o[f]=l[a]:o[f]=u(i)}}return e.pop(),l.pop(),o}}});var ue={};z(ue,{chompLeft:()=>ie,chompRight:()=>se,left:()=>A,leftSeq:()=>P,leftStopAtNewLines:()=>re,leftStopAtRawNbsp:()=>oe,right:()=>S,rightSeq:()=>W,rightStopAtNewLines:()=>te,rightStopAtRawNbsp:()=>le,version:()=>ee});var M=F(V(),1);var me=(0,M.default)();function $(n){if(n==null||typeof n!="object")return!1;let e=Object.getPrototypeOf(n);return e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null?!1:!(Symbol.iterator in n)&&!(Symbol.toStringTag in n)}function d(n){return typeof n=="string"}function O(n){return Number.isSafeInteger(n)&&n>=0}var B=F(V(),1);var U="6.0.13";var h=(0,B.default)(),ee=U,y="\xA0";function ne(n){let e={value:n,hungry:!1,optional:!1};return(e.value.endsWith("?*")||e.value.endsWith("*?"))&&e.value.length>2?(e.value=e.value.slice(0,e.value.length-2),e.optional=!0,e.hungry=!0):e.value.endsWith("?")&&e.value.length>1?(e.value=e.value.slice(0,~-e.value.length),e.optional=!0):e.value.endsWith("*")&&e.value.length>1&&(e.value=e.value.slice(0,~-e.value.length),e.hungry=!0),e}function N({str:n,idx:e=0,stopAtNewlines:l=!1,stopAtRawNbsp:s=!1}){if(typeof n!="string"||!n.length||((!e||typeof e!="number")&&(e=0),!n[e+1]))return null;if(n[e+1]&&(n[e+1].trim()||l&&`
11
11
  \r`.includes(n[e+1])||s&&n[e+1]===y))return e+1;if(n[e+2]&&(n[e+2].trim()||l&&`
12
12
  \r`.includes(n[e+2])||s&&n[e+2]===y))return e+2;for(let r=e+1,u=n.length;r<u;r++)if(n[r].trim()||l&&`
13
- \r`.includes(n[r])||s&&n[r]===y)return r;return null}function S(n,e=0){return O({str:n,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!1})}function ne(n,e){return O({str:n,idx:e,stopAtNewlines:!0,stopAtRawNbsp:!1})}function te(n,e){return O({str:n,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!0})}function N({str:n,idx:e,stopAtNewlines:l,stopAtRawNbsp:s}){if(typeof n!="string"||!n.length||((!e||typeof e!="number")&&(e=0),e<1))return null;if(n[~-e]&&(n[~-e].trim()||l&&`
13
+ \r`.includes(n[r])||s&&n[r]===y)return r;return null}function S(n,e=0){return N({str:n,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!1})}function te(n,e){return N({str:n,idx:e,stopAtNewlines:!0,stopAtRawNbsp:!1})}function le(n,e){return N({str:n,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!0})}function R({str:n,idx:e,stopAtNewlines:l,stopAtRawNbsp:s}){if(typeof n!="string"||!n.length||((!e||typeof e!="number")&&(e=0),e<1))return null;if(n[~-e]&&(n[~-e].trim()||l&&`
14
14
  \r`.includes(n[~-e])||s&&n[~-e]===y))return~-e;if(n[e-2]&&(n[e-2].trim()||l&&`
15
15
  \r`.includes(n[e-2])||s&&n[e-2]===y))return e-2;for(let r=e;r--;)if(n[r]&&(n[r].trim()||l&&`
16
- \r`.includes(n[r])||s&&n[r]===y))return r;return null}function A(n,e=0){return N({str:n,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!1})}function le(n,e){return N({str:n,idx:e,stopAtNewlines:!0,stopAtRawNbsp:!1})}function re(n,e){return N({str:n,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!0})}function U(n,e,l,s,r){if(typeof e!="string"||!e.length||(typeof l!="number"&&(l=0),n==="right"&&!e[l+1]||n==="left"&&!e[~-l]))return null;let u=l,t=[],i,f,o,a=0;for(;a<r.length;){if(!b(r[a])||!r[a].length){a+=1;continue}let{value:m,optional:g,hungry:w}=ee(r[a]),c=n==="right"?S(e,u):A(e,u);if(s.i&&e[c].toLowerCase()===m.toLowerCase()||!s.i&&e[c]===m){let R=n==="right"?S(e,c):A(e,c);w&&(s.i&&e[R].toLowerCase()===m.toLowerCase()||!s.i&&e[R]===m)?o=!0:a+=1,typeof c=="number"&&n==="right"&&c>u+1?t.push([u+1,c]):n==="left"&&typeof c=="number"&&c<~-u&&t.unshift([c+1,u]),u=c,n==="right"?(i===void 0&&(i=c),f=c):(f===void 0&&(f=c),i=c)}else if(g){a+=1;continue}else if(o){a+=1,o=void 0;continue}else return null}return i===void 0||f===void 0?null:{gaps:t,leftmostChar:i,rightmostChar:f}}var V={i:!1};function B(n,e,...l){if(!(l!=null&&l.length))throw new Error("string-left-right/leftSeq(): only two input arguments were passed! Did you intend to use left() method instead?");let s;return $(l[0])?s=p(p({},V),l.shift()):s=V,U("left",n,e,s,Array.from(l).reverse())}function q(n,e,...l){if(!(l!=null&&l.length))throw new Error("string-left-right/rightSeq(): only two input arguments were passed! Did you intend to use right() method instead?");let s;return $(l[0])?s=p(p({},V),l.shift()):s=V,U("right",n,e,s,l)}function E(n,e,l,s,r=[]){var f;if(typeof e!="string"||!e.length||((!l||typeof l!="number")&&(l=0),n==="right"&&!e[l+1]||n==="left"&&+l==0))return null;let u=null,t=null;do u=n==="right"?q(e,typeof t=="number"?t:l,...r):B(e,typeof t=="number"?t:l,...r),u!==null&&(t=n==="right"?u.rightmostChar:u.leftmostChar);while(u);if(t!=null&&n==="right"&&(t+=1),t===null)return null;if(n==="right"){if((f=e[t])!=null&&f.trim())return t;let o=S(e,t);if(!s||s.mode===0){if(o===t+1)return t;if(e.slice(t,o||e.length).trim()||e.slice(t,o||e.length).includes(`
17
- `)||e.slice(t,o||e.length).includes("\r")){for(let a=t,m=e.length;a<m;a++)if(`
18
- \r`.includes(e[a]))return a}else return o?~-o:e.length}else{if(s.mode===1)return t;if(s.mode===2){let a=e.slice(t);if(a.trim()||a.includes(`
16
+ \r`.includes(n[r])||s&&n[r]===y))return r;return null}function A(n,e=0){return R({str:n,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!1})}function re(n,e){return R({str:n,idx:e,stopAtNewlines:!0,stopAtRawNbsp:!1})}function oe(n,e){return R({str:n,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!0})}function q(n,e,l,s,r){if(typeof e!="string"||!e.length||(typeof l!="number"&&(l=0),n==="right"&&!e[l+1]||n==="left"&&!e[~-l]))return null;let u=l,t=[],o,f,i,a=0;for(;a<r.length;){if(!d(r[a])||!r[a].length){a+=1;continue}let{value:m,optional:g,hungry:w}=ne(r[a]),c=n==="right"?S(e,u):A(e,u);if(s.i&&e[c].toLowerCase()===m.toLowerCase()||!s.i&&e[c]===m){let T=n==="right"?S(e,c):A(e,c);w&&(s.i&&e[T].toLowerCase()===m.toLowerCase()||!s.i&&e[T]===m)?i=!0:a+=1,typeof c=="number"&&n==="right"&&c>u+1?t.push([u+1,c]):n==="left"&&typeof c=="number"&&c<~-u&&t.unshift([c+1,u]),u=c,n==="right"?(o===void 0&&(o=c),f=c):(f===void 0&&(f=c),o=c)}else if(g){a+=1;continue}else if(i){a+=1,i=void 0;continue}else return null}return o===void 0||f===void 0?null:{gaps:t,leftmostChar:o,rightmostChar:f}}var v={i:!1};function P(n,e,...l){if(!(l!=null&&l.length))throw new Error("string-left-right/leftSeq(): only two input arguments were passed! Did you intend to use left() method instead?");let s;return $(l[0])?s=p(p({},v),l.shift()):s=v,q("left",n,e,s,Array.from(l).reverse())}function W(n,e,...l){if(!(l!=null&&l.length))throw new Error("string-left-right/rightSeq(): only two input arguments were passed! Did you intend to use right() method instead?");let s;return $(l[0])?s=p(p({},v),l.shift()):s=v,q("right",n,e,s,l)}function E(n,e,l,s,r=[]){var f;if(typeof e!="string"||!e.length||((!l||typeof l!="number")&&(l=0),n==="right"&&!e[l+1]||n==="left"&&+l==0))return null;let u=null,t=null;do u=n==="right"?W(e,typeof t=="number"?t:l,...r):P(e,typeof t=="number"?t:l,...r),u!==null&&(t=n==="right"?u.rightmostChar:u.leftmostChar);while(u);if(t!=null&&n==="right"&&(t+=1),t===null)return null;if(n==="right"){if((f=e[t])!=null&&f.trim())return t;let i=S(e,t);if(!s||s.mode===0){if(i===t+1)return t;if(e.slice(t,i||e.length).trim()||e.slice(t,i||e.length).includes(`
17
+ `)||e.slice(t,i||e.length).includes("\r")){for(let a=t,m=e.length;a<m;a++)if(`
18
+ \r`.includes(e[a]))return a}else return i?~-i:e.length}else{if(s.mode===1)return t;if(s.mode===2){let a=e.slice(t);if(a.trim()||a.includes(`
19
19
  `)||a.includes("\r")){for(let m=t,g=e.length;m<g;m++)if(e[m].trim()||`
20
- \r`.includes(e[m]))return m}return e.length}}return o||e.length}if(e[t]&&e[~-t]&&e[~-t].trim())return t;let i=A(e,t);if(!s||s.mode===0){if(i===t-2)return t;if(e.slice(0,t).trim()||e.slice(0,t).includes(`
21
- `)||e.slice(0,t).includes("\r")){for(let o=t;o--;)if(`
22
- \r`.includes(e[o])||e[o].trim())return o+1+(e[o].trim()?1:0)}return 0}if(s.mode===1)return t;if(s.mode===2){let o=e.slice(0,t);if(o.trim()||o.includes(`
23
- `)||o.includes("\r")){for(let a=t;a--;)if(e[a].trim()||`
24
- \r`.includes(e[a]))return a+1}return 0}return i!==null?i+1:0}function ie(n,e,...l){if(!l.length||l.length===1&&$(l[0]))return null;let s={mode:0};if($(l[0])){let r=p(p({},s),h(l[0]));if(!r.mode)r.mode=0;else if(b(r.mode)&&r.mode.length===1&&"0123".includes(r.mode))r.mode=+r.mode;else if(!v(r.mode))throw new Error(`string-left-right/chompLeft(): [THROW_ID_01] the opts.mode is wrong! It should be 0, 1, 2 or 3. It was given as ${r.mode} (type ${typeof r.mode})`);return E("left",n,e,r,h(l).slice(1))}return b(l[0])?E("left",n,e,s,h(l)):E("left",n,e,s,h(l).slice(1))}function oe(n,e,...l){if(!l.length||l.length===1&&$(l[0]))return null;let s={mode:0};if($(l[0])){let r=p(p({},s),h(l[0]));if(!r.mode)r.mode=0;else if(b(r.mode)&&"0123".includes(r.mode))r.mode=Number.parseInt(r.mode,10);else if(!v(r.mode))throw new Error(`string-left-right/chompRight(): [THROW_ID_02] the opts.mode is wrong! It should be 0, 1, 2 or 3. It was given as ${r.mode} (type ${typeof r.mode})`);return E("right",n,e,r,h(l).slice(1))}return b(l[0])?E("right",n,e,s,h(l)):E("right",n,e,s,h(l).slice(1))}return z(se);})();
20
+ \r`.includes(e[m]))return m}return e.length}}return i||e.length}if(e[t]&&e[~-t]&&e[~-t].trim())return t;let o=A(e,t);if(!s||s.mode===0){if(o===t-2)return t;if(e.slice(0,t).trim()||e.slice(0,t).includes(`
21
+ `)||e.slice(0,t).includes("\r")){for(let i=t;i--;)if(`
22
+ \r`.includes(e[i])||e[i].trim())return i+1+(e[i].trim()?1:0)}return 0}if(s.mode===1)return t;if(s.mode===2){let i=e.slice(0,t);if(i.trim()||i.includes(`
23
+ `)||i.includes("\r")){for(let a=t;a--;)if(e[a].trim()||`
24
+ \r`.includes(e[a]))return a+1}return 0}return o!==null?o+1:0}function ie(n,e,...l){if(!l.length||l.length===1&&$(l[0]))return null;let s={mode:0};if($(l[0])){let r=p(p({},s),h(l[0]));if(!r.mode)r.mode=0;else if(d(r.mode)&&r.mode.length===1&&"0123".includes(r.mode))r.mode=+r.mode;else if(!O(r.mode))throw new Error(`string-left-right/chompLeft(): [THROW_ID_01] the opts.mode is wrong! It should be 0, 1, 2 or 3. It was given as ${r.mode} (type ${typeof r.mode})`);return E("left",n,e,r,h(l).slice(1))}return d(l[0])?E("left",n,e,s,h(l)):E("left",n,e,s,h(l).slice(1))}function se(n,e,...l){if(!l.length||l.length===1&&$(l[0]))return null;let s={mode:0};if($(l[0])){let r=p(p({},s),h(l[0]));if(!r.mode)r.mode=0;else if(d(r.mode)&&"0123".includes(r.mode))r.mode=Number.parseInt(r.mode,10);else if(!O(r.mode))throw new Error(`string-left-right/chompRight(): [THROW_ID_02] the opts.mode is wrong! It should be 0, 1, 2 or 3. It was given as ${r.mode} (type ${typeof r.mode})`);return E("right",n,e,r,h(l).slice(1))}return d(l[0])?E("right",n,e,s,h(l)):E("right",n,e,s,h(l).slice(1))}return G(ue);})();
25
25
  /**
26
26
  * @name codsen-utils
27
27
  * @fileoverview Various utility functions
28
- * @version 1.5.0
28
+ * @version 1.6.0
29
29
  * @author Roy Revelt, Codsen Ltd
30
30
  * @license MIT
31
31
  * {@link https://codsen.com/os/codsen-utils/}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "string-left-right",
3
- "version": "6.0.12",
3
+ "version": "6.0.13",
4
4
  "description": "Looks up the first non-whitespace character to the left/right of a given index",
5
5
  "keywords": [
6
6
  "check",
@@ -73,7 +73,7 @@
73
73
  }
74
74
  },
75
75
  "dependencies": {
76
- "codsen-utils": "^1.5.0",
76
+ "codsen-utils": "^1.6.0",
77
77
  "rfdc": "^1.3.0"
78
78
  }
79
79
  }