string-left-right 6.0.12 → 6.0.14

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/README.md CHANGED
@@ -55,7 +55,7 @@ assert.equal(
55
55
  `next non-whitespace character to the left of ${str[6]} (index 6) is ${
56
56
  str[left(str, 6)]
57
57
  } (index ${left(str, 6)})`,
58
- "next non-whitespace character to the left of d (index 6) is c (index 2)"
58
+ "next non-whitespace character to the left of d (index 6) is c (index 2)",
59
59
  );
60
60
  ```
61
61
 
@@ -1,24 +1,24 @@
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.14
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&&`
11
- \r`.includes(n[e+1])||u&&n[e+1]===c))return e+1;if(n[e+2]&&(n[e+2].trim()||l&&`
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
- \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&&`
14
- \r`.includes(n[~-e])||u&&n[~-e]===c))return~-e;if(n[e-2]&&(n[e-2].trim()||l&&`
15
- \r`.includes(n[e-2])||u&&n[e-2]===c))return e-2;for(let t=e;t--;)if(n[t]&&(n[t].trim()||l&&`
16
- \r`.includes(n[t])||u&&n[t]===c))return t;return null}function y(n,e=0){return V({str:n,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!1})}function W(n,e){return V({str:n,idx:e,stopAtNewlines:!0,stopAtRawNbsp:!1})}function _(n,e){return V({str:n,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!0})}function O(n,e,l,u,t){if(typeof e!="string"||!e.length||(typeof l!="number"&&(l=0),n==="right"&&!e[l+1]||n==="left"&&!e[~-l]))return null;let m=l,o=[],f,i,s,r=0;for(;r<t.length;){if(!b(t[r])||!t[r].length){r+=1;continue}let{value:a,optional:w,hungry:T}=J(t[r]),g=n==="right"?E(e,m):y(e,m);if(u.i&&e[g].toLowerCase()===a.toLowerCase()||!u.i&&e[g]===a){let N=n==="right"?E(e,g):y(e,g);T&&(u.i&&e[N].toLowerCase()===a.toLowerCase()||!u.i&&e[N]===a)?s=!0:r+=1,typeof g=="number"&&n==="right"&&g>m+1?o.push([m+1,g]):n==="left"&&typeof g=="number"&&g<~-m&&o.unshift([g+1,m]),m=g,n==="right"?(f===void 0&&(f=g),i=g):(i===void 0&&(i=g),f=g)}else if(w){r+=1;continue}else if(s){r+=1,s=void 0;continue}else return null}return f===void 0||i===void 0?null:{gaps:o,leftmostChar:f,rightmostChar:i}}var d={i:!1};function L(n,e,...l){if(!l?.length)throw new Error("string-left-right/leftSeq(): only two input arguments were passed! Did you intend to use left() method instead?");let u;return p(l[0])?u={...d,...l.shift()}:u=d,O("left",n,e,u,Array.from(l).reverse())}function A(n,e,...l){if(!l?.length)throw new Error("string-left-right/rightSeq(): only two input arguments were passed! Did you intend to use right() method instead?");let u;return p(l[0])?u={...d,...l.shift()}:u=d,O("right",n,e,u,l)}function h(n,e,l,u,t=[]){if(typeof e!="string"||!e.length||((!l||typeof l!="number")&&(l=0),n==="right"&&!e[l+1]||n==="left"&&+l==0))return null;let m=null,o=null;do m=n==="right"?A(e,typeof o=="number"?o:l,...t):L(e,typeof o=="number"?o:l,...t),m!==null&&(o=n==="right"?m.rightmostChar:m.leftmostChar);while(m);if(o!=null&&n==="right"&&(o+=1),o===null)return null;if(n==="right"){if(e[o]?.trim())return o;let i=E(e,o);if(!u||u.mode===0){if(i===o+1)return o;if(e.slice(o,i||e.length).trim()||e.slice(o,i||e.length).includes(`
17
- `)||e.slice(o,i||e.length).includes("\r")){for(let s=o,r=e.length;s<r;s++)if(`
18
- \r`.includes(e[s]))return s}else return i?~-i:e.length}else{if(u.mode===1)return o;if(u.mode===2){let s=e.slice(o);if(s.trim()||s.includes(`
19
- `)||s.includes("\r")){for(let r=o,a=e.length;r<a;r++)if(e[r].trim()||`
20
- \r`.includes(e[r]))return r}return e.length}}return i||e.length}if(e[o]&&e[~-o]&&e[~-o].trim())return o;let f=y(e,o);if(!u||u.mode===0){if(f===o-2)return o;if(e.slice(0,o).trim()||e.slice(0,o).includes(`
21
- `)||e.slice(0,o).includes("\r")){for(let i=o;i--;)if(`
22
- \r`.includes(e[i])||e[i].trim())return i+1+(e[i].trim()?1:0)}return 0}if(u.mode===1)return o;if(u.mode===2){let i=e.slice(0,o);if(i.trim()||i.includes(`
23
- `)||i.includes("\r")){for(let s=o;s--;)if(e[s].trim()||`
24
- \r`.includes(e[s]))return s+1}return 0}return f!==null?f+1:0}function H(n,e,...l){if(!l.length||l.length===1&&p(l[0]))return null;let u={mode:0};if(p(l[0])){let t={...u,...$(l[0])};if(!t.mode)t.mode=0;else if(b(t.mode)&&t.mode.length===1&&"0123".includes(t.mode))t.mode=+t.mode;else if(!R(t.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 ${t.mode} (type ${typeof t.mode})`);return h("left",n,e,t,$(l).slice(1))}return b(l[0])?h("left",n,e,u,$(l)):h("left",n,e,u,$(l).slice(1))}function P(n,e,...l){if(!l.length||l.length===1&&p(l[0]))return null;let u={mode:0};if(p(l[0])){let t={...u,...$(l[0])};if(!t.mode)t.mode=0;else if(b(t.mode)&&"0123".includes(t.mode))t.mode=Number.parseInt(t.mode,10);else if(!R(t.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 ${t.mode} (type ${typeof t.mode})`);return h("right",n,e,t,$(l).slice(1))}return b(l[0])?h("right",n,e,u,$(l)):h("right",n,e,u,$(l).slice(1))}export{H as chompLeft,P as chompRight,y as left,L as leftSeq,W as leftStopAtNewLines,_ as leftStopAtRawNbsp,E as right,A as rightSeq,k as rightStopAtNewLines,M as rightStopAtRawNbsp,j as version};
10
+ import{isPlainObject as p,isStr as b,isInt as R}from"codsen-utils";import I from"rfdc";var S="6.0.14";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:o=!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
+ \r`.includes(n[e+1])||o&&n[e+1]===c))return e+1;if(n[e+2]&&(n[e+2].trim()||l&&`
12
+ \r`.includes(n[e+2])||o&&n[e+2]===c))return e+2;for(let t=e+1,m=n.length;t<m;t++)if(n[t].trim()||l&&`
13
+ \r`.includes(n[t])||o&&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:o}){if(typeof n!="string"||!n.length||((!e||typeof e!="number")&&(e=0),e<1))return null;if(n[~-e]&&(n[~-e].trim()||l&&`
14
+ \r`.includes(n[~-e])||o&&n[~-e]===c))return~-e;if(n[e-2]&&(n[e-2].trim()||l&&`
15
+ \r`.includes(n[e-2])||o&&n[e-2]===c))return e-2;for(let t=e;t--;)if(n[t]&&(n[t].trim()||l&&`
16
+ \r`.includes(n[t])||o&&n[t]===c))return t;return null}function y(n,e=0){return V({str:n,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!1})}function W(n,e){return V({str:n,idx:e,stopAtNewlines:!0,stopAtRawNbsp:!1})}function _(n,e){return V({str:n,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!0})}function O(n,e,l,o,t){if(typeof e!="string"||!e.length||(typeof l!="number"&&(l=0),n==="right"&&!e[l+1]||n==="left"&&!e[~-l]))return null;let m=l,u=[],f,i,s,r=0;for(;r<t.length;){if(!b(t[r])||!t[r].length){r+=1;continue}let{value:a,optional:w,hungry:T}=J(t[r]),g=n==="right"?E(e,m):y(e,m);if(o.i&&e[g].toLowerCase()===a.toLowerCase()||!o.i&&e[g]===a){let N=n==="right"?E(e,g):y(e,g);T&&(o.i&&e[N].toLowerCase()===a.toLowerCase()||!o.i&&e[N]===a)?s=!0:r+=1,typeof g=="number"&&n==="right"&&g>m+1?u.push([m+1,g]):n==="left"&&typeof g=="number"&&g<~-m&&u.unshift([g+1,m]),m=g,n==="right"?(f===void 0&&(f=g),i=g):(i===void 0&&(i=g),f=g)}else if(w){r+=1;continue}else if(s){r+=1,s=void 0;continue}else return null}return f===void 0||i===void 0?null:{gaps:u,leftmostChar:f,rightmostChar:i}}var d={i:!1};function L(n,e,...l){if(!l?.length)throw new Error("string-left-right/leftSeq(): only two input arguments were passed! Did you intend to use left() method instead?");let o;return p(l[0])?o={...d,...l.shift()}:o=d,O("left",n,e,o,Array.from(l).reverse())}function A(n,e,...l){if(!l?.length)throw new Error("string-left-right/rightSeq(): only two input arguments were passed! Did you intend to use right() method instead?");let o;return p(l[0])?o={...d,...l.shift()}:o=d,O("right",n,e,o,l)}function h(n,e,l,o,t=[]){if(typeof e!="string"||!e.length||((!l||typeof l!="number")&&(l=0),n==="right"&&!e[l+1]||n==="left"&&+l==0))return null;let m=null,u=null;do m=n==="right"?A(e,typeof u=="number"?u:l,...t):L(e,typeof u=="number"?u:l,...t),m!==null&&(u=n==="right"?m.rightmostChar:m.leftmostChar);while(m);if(u!=null&&n==="right"&&(u+=1),u===null)return null;if(n==="right"){if(e[u]?.trim())return u;let i=E(e,u);if(!o||o.mode===0){if(i===u+1)return u;if(e.slice(u,i||e.length).trim()||e.slice(u,i||e.length).includes(`
17
+ `)||e.slice(u,i||e.length).includes("\r")){for(let s=u,r=e.length;s<r;s++)if(`
18
+ \r`.includes(e[s]))return s}else return i?~-i:e.length}else{if(o.mode===1)return u;if(o.mode===2){let s=e.slice(u);if(s.trim()||s.includes(`
19
+ `)||s.includes("\r")){for(let r=u,a=e.length;r<a;r++)if(e[r].trim()||`
20
+ \r`.includes(e[r]))return r}return e.length}}return i||e.length}if(e[u]&&e[~-u]?.trim())return u;let f=y(e,u);if(!o||o.mode===0){if(f===u-2)return u;if(e.slice(0,u).trim()||e.slice(0,u).includes(`
21
+ `)||e.slice(0,u).includes("\r")){for(let i=u;i--;)if(`
22
+ \r`.includes(e[i])||e[i].trim())return i+1+(e[i].trim()?1:0)}return 0}if(o.mode===1)return u;if(o.mode===2){let i=e.slice(0,u);if(i.trim()||i.includes(`
23
+ `)||i.includes("\r")){for(let s=u;s--;)if(e[s].trim()||`
24
+ \r`.includes(e[s]))return s+1}return 0}return f!==null?f+1:0}function H(n,e,...l){if(!l.length||l.length===1&&p(l[0]))return null;let o={mode:0};if(p(l[0])){let t={...o,...$(l[0])};if(!t.mode)t.mode=0;else if(b(t.mode)&&t.mode.length===1&&"0123".includes(t.mode))t.mode=+t.mode;else if(!R(t.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 ${t.mode} (type ${typeof t.mode})`);return h("left",n,e,t,$(l).slice(1))}return b(l[0])?h("left",n,e,o,$(l)):h("left",n,e,o,$(l).slice(1))}function P(n,e,...l){if(!l.length||l.length===1&&p(l[0]))return null;let o={mode:0};if(p(l[0])){let t={...o,...$(l[0])};if(!t.mode)t.mode=0;else if(b(t.mode)&&"0123".includes(t.mode))t.mode=Number.parseInt(t.mode,10);else if(!R(t.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 ${t.mode} (type ${typeof t.mode})`);return h("right",n,e,t,$(l).slice(1))}return b(l[0])?h("right",n,e,o,$(l)):h("right",n,e,o,$(l).slice(1))}export{H as chompLeft,P as chompRight,y as left,L as leftSeq,W as leftStopAtNewLines,_ as leftStopAtRawNbsp,E as right,A as rightSeq,k as rightStopAtNewLines,M as rightStopAtRawNbsp,j as version};
@@ -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.14
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&&`
11
- \r`.includes(n[e+1])||s&&n[e+1]===y))return e+1;if(n[e+2]&&(n[e+2].trim()||l&&`
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&&`
14
- \r`.includes(n[~-e])||s&&n[~-e]===y))return~-e;if(n[e-2]&&(n[e-2].trim()||l&&`
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(`
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);})();
10
+ "use strict";var stringLeftRight=(()=>{var x=Object.create;var w=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?w(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)w(n,l,{get:e[l],enumerable:!0})},j=(n,e,l,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of _(e))!L.call(n,r)&&r!==l&&w(n,r,{get:()=>e[r],enumerable:!(i=Q(e,r))||i.enumerable});return n};var F=(n,e,l)=>(l=n!=null?x(H(n)):{},j(e||!n||!n.__esModule?w(l,"default",{value:n,enumerable:!0}):l,n)),G=n=>j(w({},"__esModule",{value:!0}),n);var V=Z((fe,J)=>{"use strict";J.exports=Y;function d(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?i:l;function e(r,a){for(var t=Object.keys(r),o=new Array(t.length),f=0;f<t.length;f++){var s=t[f],u=r[s];typeof u!="object"||u===null?o[s]=u:u instanceof Date?o[s]=new Date(u):ArrayBuffer.isView(u)?o[s]=d(u):o[s]=a(u)}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 a={};for(var t in r)if(Object.hasOwnProperty.call(r,t)!==!1){var o=r[t];typeof o!="object"||o===null?a[t]=o:o instanceof Date?a[t]=new Date(o):o instanceof Map?a[t]=new Map(e(Array.from(o),l)):o instanceof Set?a[t]=new Set(e(Array.from(o),l)):ArrayBuffer.isView(o)?a[t]=d(o):a[t]=l(o)}return a}function i(r){if(typeof r!="object"||r===null)return r;if(r instanceof Date)return new Date(r);if(Array.isArray(r))return e(r,i);if(r instanceof Map)return new Map(e(Array.from(r),i));if(r instanceof Set)return new Set(e(Array.from(r),i));var a={};for(var t in r){var o=r[t];typeof o!="object"||o===null?a[t]=o:o instanceof Date?a[t]=new Date(o):o instanceof Map?a[t]=new Map(e(Array.from(o),i)):o instanceof Set?a[t]=new Set(e(Array.from(o),i)):ArrayBuffer.isView(o)?a[t]=d(o):a[t]=i(o)}return a}}function X(n){var e=[],l=[];return n.proto?a:r;function i(t,o){for(var f=Object.keys(t),s=new Array(f.length),u=0;u<f.length;u++){var m=f[u],c=t[m];if(typeof c!="object"||c===null)s[m]=c;else if(c instanceof Date)s[m]=new Date(c);else if(ArrayBuffer.isView(c))s[m]=d(c);else{var b=e.indexOf(c);b!==-1?s[m]=l[b]:s[m]=o(c)}}return s}function r(t){if(typeof t!="object"||t===null)return t;if(t instanceof Date)return new Date(t);if(Array.isArray(t))return i(t,r);if(t instanceof Map)return new Map(i(Array.from(t),r));if(t instanceof Set)return new Set(i(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 s=t[f];if(typeof s!="object"||s===null)o[f]=s;else if(s instanceof Date)o[f]=new Date(s);else if(s instanceof Map)o[f]=new Map(i(Array.from(s),r));else if(s instanceof Set)o[f]=new Set(i(Array.from(s),r));else if(ArrayBuffer.isView(s))o[f]=d(s);else{var u=e.indexOf(s);u!==-1?o[f]=l[u]:o[f]=r(s)}}return e.pop(),l.pop(),o}function a(t){if(typeof t!="object"||t===null)return t;if(t instanceof Date)return new Date(t);if(Array.isArray(t))return i(t,a);if(t instanceof Map)return new Map(i(Array.from(t),a));if(t instanceof Set)return new Set(i(Array.from(t),a));var o={};e.push(t),l.push(o);for(var f in t){var s=t[f];if(typeof s!="object"||s===null)o[f]=s;else if(s instanceof Date)o[f]=new Date(s);else if(s instanceof Map)o[f]=new Map(i(Array.from(s),a));else if(s instanceof Set)o[f]=new Set(i(Array.from(s),a));else if(ArrayBuffer.isView(s))o[f]=d(s);else{var u=e.indexOf(s);u!==-1?o[f]=l[u]:o[f]=a(s)}}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 y(n){return typeof n=="string"}function O(n){return Number.isSafeInteger(n)&&n>=0}var B=F(V(),1);var U="6.0.14";var h=(0,B.default)(),ee=U,E="\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:i=!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
+ \r`.includes(n[e+1])||i&&n[e+1]===E))return e+1;if(n[e+2]&&(n[e+2].trim()||l&&`
12
+ \r`.includes(n[e+2])||i&&n[e+2]===E))return e+2;for(let r=e+1,a=n.length;r<a;r++)if(n[r].trim()||l&&`
13
+ \r`.includes(n[r])||i&&n[r]===E)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:i}){if(typeof n!="string"||!n.length||((!e||typeof e!="number")&&(e=0),e<1))return null;if(n[~-e]&&(n[~-e].trim()||l&&`
14
+ \r`.includes(n[~-e])||i&&n[~-e]===E))return~-e;if(n[e-2]&&(n[e-2].trim()||l&&`
15
+ \r`.includes(n[e-2])||i&&n[e-2]===E))return e-2;for(let r=e;r--;)if(n[r]&&(n[r].trim()||l&&`
16
+ \r`.includes(n[r])||i&&n[r]===E))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,i,r){if(typeof e!="string"||!e.length||(typeof l!="number"&&(l=0),n==="right"&&!e[l+1]||n==="left"&&!e[~-l]))return null;let a=l,t=[],o,f,s,u=0;for(;u<r.length;){if(!y(r[u])||!r[u].length){u+=1;continue}let{value:m,optional:c,hungry:b}=ne(r[u]),g=n==="right"?S(e,a):A(e,a);if(i.i&&e[g].toLowerCase()===m.toLowerCase()||!i.i&&e[g]===m){let T=n==="right"?S(e,g):A(e,g);b&&(i.i&&e[T].toLowerCase()===m.toLowerCase()||!i.i&&e[T]===m)?s=!0:u+=1,typeof g=="number"&&n==="right"&&g>a+1?t.push([a+1,g]):n==="left"&&typeof g=="number"&&g<~-a&&t.unshift([g+1,a]),a=g,n==="right"?(o===void 0&&(o=g),f=g):(f===void 0&&(f=g),o=g)}else if(c){u+=1;continue}else if(s){u+=1,s=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 i;return $(l[0])?i=p(p({},v),l.shift()):i=v,q("left",n,e,i,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 i;return $(l[0])?i=p(p({},v),l.shift()):i=v,q("right",n,e,i,l)}function D(n,e,l,i,r=[]){var f,s;if(typeof e!="string"||!e.length||((!l||typeof l!="number")&&(l=0),n==="right"&&!e[l+1]||n==="left"&&+l==0))return null;let a=null,t=null;do a=n==="right"?W(e,typeof t=="number"?t:l,...r):P(e,typeof t=="number"?t:l,...r),a!==null&&(t=n==="right"?a.rightmostChar:a.leftmostChar);while(a);if(t!=null&&n==="right"&&(t+=1),t===null)return null;if(n==="right"){if((f=e[t])!=null&&f.trim())return t;let u=S(e,t);if(!i||i.mode===0){if(u===t+1)return t;if(e.slice(t,u||e.length).trim()||e.slice(t,u||e.length).includes(`
17
+ `)||e.slice(t,u||e.length).includes("\r")){for(let m=t,c=e.length;m<c;m++)if(`
18
+ \r`.includes(e[m]))return m}else return u?~-u:e.length}else{if(i.mode===1)return t;if(i.mode===2){let m=e.slice(t);if(m.trim()||m.includes(`
19
+ `)||m.includes("\r")){for(let c=t,b=e.length;c<b;c++)if(e[c].trim()||`
20
+ \r`.includes(e[c]))return c}return e.length}}return u||e.length}if(e[t]&&((s=e[~-t])!=null&&s.trim()))return t;let o=A(e,t);if(!i||i.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 u=t;u--;)if(`
22
+ \r`.includes(e[u])||e[u].trim())return u+1+(e[u].trim()?1:0)}return 0}if(i.mode===1)return t;if(i.mode===2){let u=e.slice(0,t);if(u.trim()||u.includes(`
23
+ `)||u.includes("\r")){for(let m=t;m--;)if(e[m].trim()||`
24
+ \r`.includes(e[m]))return m+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 i={mode:0};if($(l[0])){let r=p(p({},i),h(l[0]));if(!r.mode)r.mode=0;else if(y(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 D("left",n,e,r,h(l).slice(1))}return y(l[0])?D("left",n,e,i,h(l)):D("left",n,e,i,h(l).slice(1))}function se(n,e,...l){if(!l.length||l.length===1&&$(l[0]))return null;let i={mode:0};if($(l[0])){let r=p(p({},i),h(l[0]));if(!r.mode)r.mode=0;else if(y(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 D("right",n,e,r,h(l).slice(1))}return y(l[0])?D("right",n,e,i,h(l)):D("right",n,e,i,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.1
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.14",
4
4
  "description": "Looks up the first non-whitespace character to the left/right of a given index",
5
5
  "keywords": [
6
6
  "check",
@@ -42,7 +42,7 @@
42
42
  "cjs-on": "exit 0",
43
43
  "dev": "DEV=true node '../../ops/scripts/esbuild.js' && npm run dts",
44
44
  "devtest": "c8 npm run unit && npm run examples && npm run lint",
45
- "dts": "rollup -c && npm run prettier -- 'types/index.d.ts' --write --loglevel 'silent'",
45
+ "dts": "rollup -c && npm run prettier -- 'types/index.d.ts' --write --log-level 'silent'",
46
46
  "examples": "node '../../ops/scripts/run-examples.js'",
47
47
  "lect": "node '../../ops/lect/lect.js' && npm run prettier -- 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
48
48
  "letspublish": "npm publish || :",
@@ -50,7 +50,7 @@
50
50
  "perf": "node perf/check.js",
51
51
  "prep": "echo 'ready'",
52
52
  "prettier": "prettier",
53
- "prettier:format": "npm run prettier -- --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern --loglevel 'silent'",
53
+ "prettier:format": "npm run prettier -- --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern --log-level 'silent'",
54
54
  "pretest": "npm run lect && npm run build",
55
55
  "test": "npm run devtest",
56
56
  "unit": "uvu test"
@@ -73,7 +73,7 @@
73
73
  }
74
74
  },
75
75
  "dependencies": {
76
- "codsen-utils": "^1.5.0",
76
+ "codsen-utils": "^1.6.1",
77
77
  "rfdc": "^1.3.0"
78
78
  }
79
79
  }