string-match-left-right 9.2.1 → 9.2.3

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/CHANGELOG.md CHANGED
@@ -3,12 +3,34 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## 9.2.3 (2026-09-01)
7
+
8
+ ### Bug Fixes
9
+
10
+ - align callback trim matching ([c87aca2](https://github.com/codsen/codsen/commit/c87aca20dc168bd90242c65b33d041b2e0671f50))
11
+ - align matcher alternative types ([b82ef30](https://github.com/codsen/codsen/commit/b82ef302d374babb22b32250e3c2867f4a51093e))
12
+ - bound matcher mismatch work ([5b92249](https://github.com/codsen/codsen/commit/5b92249a7116ca87cd1f79eca15637e7e924cbe7))
13
+ - enforce left match boundaries ([d81d631](https://github.com/codsen/codsen/commit/d81d631c0b2cc2f5391efbb97b4dea486b70be16))
14
+ - reject out-of-range match positions ([dc889f9](https://github.com/codsen/codsen/commit/dc889f9f80a746f81701474fae81d96edf2d16a4))
15
+ - return complete matcher callback context ([76bfcdb](https://github.com/codsen/codsen/commit/76bfcdbc6d424d424086a6e12e9b804a8f0de725))
16
+ - stabilize end-of-line matchers ([e5f4df9](https://github.com/codsen/codsen/commit/e5f4df9fbb51133a36d8286c2e2a9240706a5be4))
17
+
18
+ ### Performance Improvements
19
+
20
+ - streamline strict string matching ([3c3beca](https://github.com/codsen/codsen/commit/3c3beca31fb5b19a5ba5136a10d02966a56c68a2))
21
+
22
+ ## 9.2.2 (2026-08-22)
23
+
24
+ ### Performance Improvements
25
+
26
+ - optimise package hot paths and JSON editing ([f3112bd](https://github.com/codsen/codsen/commit/f3112bd7fc0d7c9bc09312d3744c950691d72ca5))
27
+
6
28
  ## 9.2.0 (2026-08-19)
7
29
 
8
30
  ### Bug Fixes
9
31
 
10
32
  - make validation diagnostics safe ([7b01074](https://github.com/codsen/codsen/commit/7b0107476f12734aeb8e82852ba980b187280110))
11
- - resolve review findings REV-004 through REV-007 ([b60e9ee](https://github.com/codsen/codsen/commit/b60e9eeb499af94685cfb87b4970fe025be1fc10))
33
+ - resolve various review findings ([b60e9ee](https://github.com/codsen/codsen/commit/b60e9eeb499af94685cfb87b4970fe025be1fc10))
12
34
  - retire direct publish aliases ([f98e31e](https://github.com/codsen/codsen/commit/f98e31eb89bc185471225664e610b55f34fbf648))
13
35
  - standardise matcher validation errs ([6f8f858](https://github.com/codsen/codsen/commit/6f8f858104ecd066189d287901f80c94b581d08b))
14
36
  - stop case-insensitive matching crashing on a null index ([5682575](https://github.com/codsen/codsen/commit/56825755acdcb8c9f2be089bf13cb24ba032e950))
@@ -1,13 +1,16 @@
1
1
  /**
2
2
  * @name string-match-left-right
3
3
  * @fileoverview Match substrings on the left or right of a given index, ignoring whitespace
4
- * @version 9.2.1
4
+ * @version 9.2.3
5
5
  * @author Roy Revelt
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/string-match-left-right/}
8
8
  */
9
9
 
10
- import{arrayiffy as N}from"arrayiffy-if-string";import{formatDiagnosticValue as O,hasOwnProp as L,isPlainObject as R,isStr as T}from"codsen-utils";var w="9.2.1";var H=w,S={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},A=e=>e+1;function I(e,s,n,a,u=!1,r=A){let i=typeof n=="function"?n():n;if(+s<0&&u&&i==="EOL")return i;let o={...S,...a};if(s>=e.length&&!u)return!1;let c=u?1:n.length,E=0,h=!1,l=!1,g=!1,b=o.maxMismatches,t=s,$=!1,f=!1,m=!1;function D(){return E===1&&b<o.maxMismatches-1}for(;e[t];){let p=r(t);if(o.trimBeforeMatching&&e[t].trim()===""){if(!e[p]&&u&&n==="EOL")return!0;t=r(t);continue}if(o&&!o.i&&o?.trimCharsBeforeMatching?.includes(e[t])||o?.i&&o.trimCharsBeforeMatching&&o.trimCharsBeforeMatching.map(d=>d.toLowerCase()).includes(e[t].toLowerCase())){if(u&&n==="EOL"&&!e[p])return!0;t=r(t);continue}let M=p>t?n[n.length-c]:n[c-1];if(!o.i&&e[t]===M||o.i&&M!==void 0&&e[t].toLowerCase()===M.toLowerCase()){if($||($=!0),g||(g=!0),c===n.length){if(f=!0,b!==o.maxMismatches)return!1}else c===1&&(m=!0);if(c-=1,E++,D())return!1;if(!c)return E!==n.length||b===o.maxMismatches||!h?t:!1}else if(!h&&!E&&(h=!0),o.maxMismatches&&b&&t){b-=1;for(let d=0;d<=b;d++){let C=p>t?n[n.length-c+1+d]:n[c-2-d],y=e[r(t)];if(C&&(!o.i&&e[t]===C||o.i&&e[t].toLowerCase()===C.toLowerCase())&&(!o.firstMustMatch||c!==n.length)){if(E++,D())return!1;c-=2,$=!0;break}else if(y&&C&&(!o.i&&y===C||o.i&&y.toLowerCase()===C.toLowerCase())&&(!o.firstMustMatch||c!==n.length)){if(!E&&!o.hungry)return!1;c-=1,$=!0;break}else if(C===void 0&&b>=0&&$&&(!o.firstMustMatch||f)&&(!o.lastMustMatch||m))return t}$||(l=t)}else return t===0&&c===1&&!o.lastMustMatch&&g?0:!1;if(l!==!1&&l!==t&&(l=!1),c<1)return t;t=r(t)}if(c>0)return u&&i==="EOL"?!0:o&&o.maxMismatches>=c&&g?l||0:!1}function V(e,s,n,a,u){if(R(u)&&L(u,"trimBeforeMatching")&&u&&typeof u.trimBeforeMatching!="boolean")throw new Error(`string-match-left-right/${e}(): [THROW_ID_01] opts.trimBeforeMatching should be boolean!${Array.isArray(u.trimBeforeMatching)?" Did you mean to use opts.trimCharsBeforeMatching?":""}`);let r={...S,...u};if(typeof r.trimCharsBeforeMatching=="string"&&(r.trimCharsBeforeMatching=N(r.trimCharsBeforeMatching)),r.trimCharsBeforeMatching=r.trimCharsBeforeMatching.map(h=>T(h)?h:String(h)),!T(s)||!s.length)return!1;if(!Number.isInteger(n)||n<0)throw new Error(`string-match-left-right/${e}(): [THROW_ID_02] the second argument should be a natural number. Currently it's of a type: ${typeof n}, equal to:
11
- ${O(n,4)}`);let i,o;if(T(a))i=[a];else if(Array.isArray(a))i=a;else if(!a)i=a;else if(typeof a=="function")i=[],i.push(a);else throw new Error(`string-match-left-right/${e}(): [THROW_ID_03] the third argument, whatToMatch, is neither string nor array of strings! It's ${typeof a}, equal to:
12
- ${O(a,4)}`);if(u&&!R(u))throw new Error(`string-match-left-right/${e}(): [THROW_ID_04] the fourth argument, options object, should be a plain object. Currently it's of a type "${typeof u}", and equal to:
13
- ${O(u,4)}`);let c=0,E="";if(r?.trimCharsBeforeMatching?.some((h,l)=>h.length>1?(c=l,E=h,!0):!1))throw new Error(`string-match-left-right/${e}(): [THROW_ID_05] the fourth argument, options object contains trimCharsBeforeMatching. It was meant to list the single characters but one of the entries at index ${c} is longer than 1 character, ${E.length} (equals to ${E}). Please split it into separate characters and put into array as separate elements.`);if(!i||!Array.isArray(i)||Array.isArray(i)&&!i.length||Array.isArray(i)&&i.length===1&&T(i[0])&&!i[0].trim()){if(typeof r.cb=="function"){let l,g=n;if((e==="matchLeftIncl"||e==="matchRight")&&(g+=1),e[5]==="L")for(let f=g;f--;){let m=s[f];if((!r.trimBeforeMatching||r.trimBeforeMatching&&m?.trim())&&(!r.trimCharsBeforeMatching?.length||m!==void 0&&!r.trimCharsBeforeMatching.includes(m))){l=f;break}}else if(e.startsWith("matchRight"))for(let f=g;f<s.length;f++){let m=s[f];if((!r.trimBeforeMatching||r.trimBeforeMatching&&m.trim())&&(!r.trimCharsBeforeMatching?.length||!r.trimCharsBeforeMatching.includes(m))){l=f;break}}if(l===void 0)return!1;let b=s[l],t=l+1,$="";return t&&t>0&&($=s.slice(0,t)),e[5]==="L"||l&&l>0&&($=s.slice(l)),r.cb(b,$,l)}let h="";throw u||(h=" More so, the whole options object, the fourth input argument, is missing!"),new Error(`string-match-left-right/${e}(): [THROW_ID_06] the third argument, "whatToMatch", was given as an empty string. This means, you intend to match purely by a callback. The callback was not set though, the opts key "cb" is not set!${h}`)}for(let h=0,l=i.length;h<l;h++){o=typeof i[h]=="function";let g=i[h],b,t,$="",f=n;e==="matchRight"?f+=1:e==="matchLeft"&&(f-=1);let m=I(s,f,g,r,o,D=>e[5]==="L"?D-1:D+1);if(m&&o&&typeof g=="function"&&g()==="EOL")return g()&&(!r.cb||r.cb(b,$,t))?g():!1;if(Number.isInteger(m)&&(t=e.startsWith("matchLeft")?m-1:m+1,e[5]==="L"?$=s.slice(0,m):$=s.slice(t)),t<0&&(t=void 0),s[t]&&(b=s[t]),Number.isInteger(m)&&(!r.cb||r.cb(b,$,t)))return g}return!1}function j(e,s,n,a){return V("matchLeftIncl",e,s,n,a)}function P(e,s,n,a){return V("matchLeft",e,s,n,a)}function v(e,s,n,a){return V("matchRightIncl",e,s,n,a)}function U(e,s,n,a){return V("matchRight",e,s,n,a)}export{A as defaultGetNextIdx,S as defaults,P as matchLeft,j as matchLeftIncl,U as matchRight,v as matchRightIncl,H as version};
10
+ import{arrayiffy as I}from"arrayiffy-if-string";import{formatDiagnosticValue as V,hasOwnProp as N,isPlainObject as O,isStr as p}from"codsen-utils";var w="9.2.3";var P=w,L={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},S=e=>e+1,A=e=>e-1;function x(e,s,o,r,u=()=>!1,n=!1,a=S){if(+s<0&&n&&o==="EOL")return o;if(s>=e.length&&!n)return!1;let l=n?1:o.length,E=0,D=!1,d=!1,M=!1,$=Math.min(r.maxMismatches,e.length+o.length),b=$,t=s,i=!1,m=!1,g=!1;function C(){return E===1&&b<$-1}for(;e[t];){let c=a(t);if(r.trimBeforeMatching&&e[t].trim()===""){if(!e[c]&&n&&o==="EOL")return!0;t=a(t);continue}if(u(e[t])){if(n&&o==="EOL"&&!e[c])return!0;t=a(t);continue}if(n)return!1;let h=c>t?o[o.length-l]:o[l-1];if(!r.i&&e[t]===h||r.i&&h!==void 0&&e[t].toLowerCase()===h.toLowerCase()){if(i||(i=!0),M||(M=!0),l===o.length){if(m=!0,b!==$)return!1}else l===1&&(g=!0);if(l-=1,E++,C())return!1;if(!l)return E!==o.length||b===$||!D?t:!1}else if(!D&&!E&&(D=!0),$&&b&&t){b-=1;for(let f=0;f<=b;f++){let T=c>t?o[o.length-l+1+f]:o[l-2-f],R=e[a(t)];if(T&&(!r.i&&e[t]===T||r.i&&e[t].toLowerCase()===T.toLowerCase())&&(!r.firstMustMatch||l!==o.length)){if(E++,C())return!1;l-=2,i=!0;break}else if(R&&T&&(!r.i&&R===T||r.i&&R.toLowerCase()===T.toLowerCase())&&(!r.firstMustMatch||l!==o.length)){if(!E&&!r.hungry)return!1;l-=1,i=!0;break}else if(T===void 0&&b>=0&&i&&(!r.firstMustMatch||m)&&(!r.lastMustMatch||g))return t}i||(d=t)}else return t===0&&l===1&&$>0&&b>0&&(!r.firstMustMatch||m)&&!r.lastMustMatch&&M?0:!1;if(d!==!1&&d!==t&&(d=!1),l<1)return t;t=a(t)}if(l>0)return n&&o==="EOL"?!0:r&&$>=l&&M?d||0:!1}function y(e,s,o,r,u){if(O(u)&&N(u,"trimBeforeMatching")&&u&&typeof u.trimBeforeMatching!="boolean")throw new Error(`string-match-left-right/${e}(): [THROW_ID_01] opts.trimBeforeMatching should be boolean!${Array.isArray(u.trimBeforeMatching)?" Did you mean to use opts.trimCharsBeforeMatching?":""}`);let n={...L,...u};if(n.maxMismatches=u?.maxMismatches??L.maxMismatches,B(n.maxMismatches,e),typeof n.trimCharsBeforeMatching=="string"&&(n.trimCharsBeforeMatching=I(n.trimCharsBeforeMatching)),n.trimCharsBeforeMatching=n.trimCharsBeforeMatching.map(t=>p(t)?t:String(t)),!p(s)||!s.length)return!1;if(!Number.isInteger(o)||o<0)throw new Error(`string-match-left-right/${e}(): [THROW_ID_02] the second argument should be a natural number. Currently it's of a type: ${typeof o}, equal to:
11
+ ${V(o,4)}`);let a,l;if(p(r))a=[r];else if(Array.isArray(r))a=r;else if(!r)a=r;else if(typeof r=="function")a=[],a.push(r);else throw new Error(`string-match-left-right/${e}(): [THROW_ID_03] the third argument, whatToMatch, is neither string nor array of strings! It's ${typeof r}, equal to:
12
+ ${V(r,4)}`);if(J(a,e),u&&!O(u))throw new Error(`string-match-left-right/${e}(): [THROW_ID_04] the fourth argument, options object, should be a plain object. Currently it's of a type "${typeof u}", and equal to:
13
+ ${V(u,4)}`);let E=0,D="";if(n?.trimCharsBeforeMatching?.some((t,i)=>t.length>1?(E=i,D=t,!0):!1))throw new Error(`string-match-left-right/${e}(): [THROW_ID_05] the fourth argument, options object contains trimCharsBeforeMatching. It was meant to list the single characters but one of the entries at index ${E} is longer than 1 character, ${D.length} (equals to ${D}). Please split it into separate characters and put into array as separate elements.`);if(o>=s.length)return!1;let d=n.i?n.trimCharsBeforeMatching.map(t=>t.toLowerCase()):n.trimCharsBeforeMatching,M=n.i?t=>d.includes(t.toLowerCase()):t=>d.includes(t);if(!a||!Array.isArray(a)||Array.isArray(a)&&!a.length||Array.isArray(a)&&a.length===1&&p(a[0])&&!a[0].trim()){if(typeof n.cb=="function"){let i,m=o;if((e==="matchLeftIncl"||e==="matchRight")&&(m+=1),e[5]==="L")for(let c=m;c--;){let h=s[c];if((!n.trimBeforeMatching||n.trimBeforeMatching&&h?.trim())&&(!n.trimCharsBeforeMatching?.length||h!==void 0&&!M(h))){i=c;break}}else if(e.startsWith("matchRight"))for(let c=m;c<s.length;c++){let h=s[c];if((!n.trimBeforeMatching||n.trimBeforeMatching&&h.trim())&&(!n.trimCharsBeforeMatching?.length||!M(h))){i=c;break}}if(i===void 0)return!1;let g=s[i],C=e[5]==="L"?s.slice(0,i+1):s.slice(i);return e[5]==="L",n.cb(g,C,i)}let t="";throw u||(t=" More so, the whole options object, the fourth input argument, is missing!"),new Error(`string-match-left-right/${e}(): [THROW_ID_06] the third argument, "whatToMatch", was given as an empty string. This means, you intend to match purely by a callback. The callback was not set though, the opts key "cb" is not set!${t}`)}if(!n.cb&&!n.i&&!n.trimBeforeMatching&&!n.trimCharsBeforeMatching.length&&n.maxMismatches===0&&!n.firstMustMatch&&!n.lastMustMatch&&!n.hungry&&a.every(p)){for(let t of a){if(!t.length)continue;let i=o;if(e==="matchRight"?i+=1:e==="matchLeft"?i-=t.length:e==="matchLeftIncl"&&(i-=t.length-1),i>=0&&s.startsWith(t,i))return t}return!1}let $=o;e==="matchRight"?$+=1:e==="matchLeft"&&($-=1);let b=e[5]==="L"?A:S;for(let t=0,i=a.length;t<i;t++){l=typeof a[t]=="function";let m=a[t],g=typeof m=="function"?m():m;if(l&&g!=="EOL")throw new Error(`string-match-left-right/${e}(): [THROW_ID_09] EOL marker functions must return "EOL". The function at index ${t} returned:
14
+ ${V(g,4)}`);if(l&&e.endsWith("Incl"))continue;let C,c,h="",f=x(s,$,g,n,M,l,b);if(f&&l)return!n.cb||n.cb(C,h,c)?g:!1;if(Number.isInteger(f)&&(c=e.startsWith("matchLeft")?f-1:f+1,e[5]==="L"?h=s.slice(0,f):h=s.slice(c)),c<0&&(c=void 0),s[c]&&(C=s[c]),Number.isInteger(f)&&(!n.cb||n.cb(C,h,c)))return g}return!1}function B(e,s){if(!Number.isSafeInteger(e)||e<0)throw new Error(`string-match-left-right/${s}(): [THROW_ID_07] opts.maxMismatches must be a non-negative safe integer. Currently it's of a type: ${typeof e}, equal to:
15
+ ${V(e,4)}`)}function J(e,s){if(e)for(let o=0;o<e.length;o+=1){let r=e[o];if(typeof r!="string"&&typeof r!="function")throw new Error(`string-match-left-right/${s}(): [THROW_ID_08] matcher alternatives must be strings or EOL marker functions. The value at index ${o} is of a type: ${typeof r}, equal to:
16
+ ${V(r,4)}`)}}function W(e,s,o,r){return y("matchLeftIncl",e,s,o,r)}function _(e,s,o,r){return y("matchLeft",e,s,o,r)}function U(e,s,o,r){return y("matchRightIncl",e,s,o,r)}function q(e,s,o,r){return y("matchRight",e,s,o,r)}export{S as defaultGetNextIdx,L as defaults,_ as matchLeft,W as matchLeftIncl,q as matchRight,U as matchRightIncl,P as version};
@@ -1,25 +1,33 @@
1
1
  /**
2
2
  * @name string-match-left-right
3
3
  * @fileoverview Match substrings on the left or right of a given index, ignoring whitespace
4
- * @version 9.2.1
4
+ * @version 9.2.3
5
5
  * @author Roy Revelt
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/string-match-left-right/}
8
8
  */
9
9
 
10
- "use strict";var stringMatchLeftRight=(()=>{var w=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames,L=Object.getOwnPropertySymbols;var B=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable;var N=(e,r,t)=>r in e?w(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,V=(e,r)=>{for(var t in r||(r={}))B.call(r,t)&&N(e,t,r[t]);if(L)for(var t of L(r))_.call(r,t)&&N(e,t,r[t]);return e};var q=(e,r)=>{for(var t in r)w(e,t,{get:r[t],enumerable:!0})},Q=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let a of H(r))!B.call(e,a)&&a!==t&&w(e,a,{get:()=>r[a],enumerable:!(o=J(r,a))||o.enumerable});return e};var Y=e=>Q(w({},"__esModule",{value:!0}),e);var ie={};q(ie,{defaultGetNextIdx:()=>U,defaults:()=>x,matchLeft:()=>re,matchLeftIncl:()=>ne,matchRight:()=>se,matchRightIncl:()=>oe,version:()=>ee});function I(e){return typeof e!="string"?e:e.length?[e]:[]}function G(){let e=[],r=0,t=!1;return{append(o){return t?!1:r+o.length>1999?(e.push("\u2026"),r+=1,t=!0,!1):(e.push(o),r+=o.length,!0)},result(){return e.join("")},stopped(){return t}}}function K(e){return"\\u".concat(e.toString(16).padStart(4,"0"))}function A(e,r){if(e.append('"')){for(let t=0;t<r.length&&!e.stopped();t+=1){let o=r.charCodeAt(t);o===34?e.append('\\"'):o===92?e.append("\\\\"):o===8?e.append("\\b"):o===9?e.append("\\t"):o===10?e.append("\\n"):o===12?e.append("\\f"):o===13?e.append("\\r"):o<32||o===8232||o===8233||o>=55296&&o<=57343?e.append(K(o)):e.append(r[t])}e.append('"')}}function z(e){return e.get&&e.set?"[Getter/Setter]":e.get?"[Getter]":e.set?"[Setter]":"[Accessor]"}function W(e,r){e.append("Symbol(");let t=String(r);t.length>8&&A(e,t.slice(7,-1)),e.append(")")}function j(e,r){typeof r=="symbol"?W(e,r):A(e,String(r))}function O(e,r=0){let t=G(),o=r===4?4:0,a=new WeakSet,l=0;function h(n){o&&t.append(" ".repeat(n*o))}function s(n,i){n&&t.append(","),o&&(t.append("\n"),h(i+1))}function m(n,i,$){o&&i&&(t.append("\n"),h($)),t.append(n)}function b(n,i){Object.prototype.hasOwnProperty.call(n,"value")?c(n.value,i):t.append(z(n))}function C(n,i){let $;try{$=Reflect.getOwnPropertyDescriptor(n,"length")}catch(g){t.append("[Uninspectable]");return}let u=$==null?void 0:$.value;if(!Number.isSafeInteger(u)||u<0){t.append("[Uninspectable]");return}t.append("[");let p=!1;for(let g=0;g<u&&!t.stopped();g+=1){if(s(p,i),p=!0,l>=50){t.append("[MaxEntries]");break}l+=1;let f;try{f=Reflect.getOwnPropertyDescriptor(n,String(g))}catch(E){t.append("[Uninspectable]");continue}f!=null&&f.enumerable?b(f,i+1):t.append("[Empty]")}m("]",p,i)}function d(n,i){let $;try{$=Reflect.ownKeys(n)}catch(p){t.append("[Uninspectable]");return}t.append("{");let u=!1;for(let p of $){if(t.stopped())break;if(l>=50){s(u,i),u=!0,A(t,"\u2026"),t.append(o?": ":":"),t.append("[MaxEntries]");break}l+=1;let g;try{g=Reflect.getOwnPropertyDescriptor(n,p)}catch(f){s(u,i),u=!0,j(t,p),t.append(o?": ":":"),t.append("[Uninspectable]");continue}g!=null&&g.enumerable&&(s(u,i),u=!0,j(t,p),t.append(o?": ":":"),b(g,i+1))}m("}",u,i)}function y(n,i){if(a.has(n)){t.append("[Circular]");return}if(i>=5){t.append("[MaxDepth]");return}let $;try{$=Array.isArray(n)}catch(u){t.append("[Uninspectable]");return}a.add(n);try{$?C(n,i):d(n,i)}finally{a.delete(n)}}function c(n,i){n===null?t.append("null"):typeof n=="string"?A(t,n):typeof n=="number"?t.append(Object.is(n,-0)?"-0":String(n)):typeof n=="boolean"?t.append(n?"true":"false"):typeof n>"u"?t.append("undefined"):typeof n=="bigint"?t.append("".concat(n,"n")):typeof n=="symbol"?W(t,n):typeof n=="function"?t.append("[Function]"):y(n,i)}try{return c(e,0),t.result()}catch(n){return"[Uninspectable]"}}var ce=new Set([..."\u060B$\u20BC\u17DB\xA5\u20A1\u20B1\xA3\u20AC\xA2\u20B9\uFDFC\u20AA\u20A9\u20AD\u20A8\u20AE\u20A6\u20BD\u20AB\u0E3F\u20A9\u20BA\u20B4","$U","$b","B/.","BZ$","Br","Bs","C$","CHF","Ft","Gs","J$","KM","K\u010D","L","MT","NT$","P","Q","R","R$","RD$","RM","Rp","S","S/.","TT$","Z$","kn","kr","lei","z\u0142","\u0192","\u0414\u0438\u043D.","\u0434\u0435\u043D","\u043B\u0432","\u062F.\u0625","Lek"]),Z=Object.prototype.hasOwnProperty;function S(e){if(e==null||typeof e!="object")return!1;let r=Object.getPrototypeOf(e);return r!==null&&r!==Object.prototype&&Object.getPrototypeOf(r)!==null?!1:!(Symbol.iterator in e)&&!(Symbol.toStringTag in e)}function T(e){return typeof e=="string"}function F(e,r){return S(e)&&T(r)&&Z.call(e,r)}var P="9.2.1";var ee=P,x={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},U=e=>e+1;function te(e,r,t,o,a=!1,l=U){var f;let h=typeof t=="function"?t():t;if(+r<0&&a&&h==="EOL")return h;let s=V(V({},x),o);if(r>=e.length&&!a)return!1;let m=a?1:t.length,b=0,C=!1,d=!1,y=!1,c=s.maxMismatches,n=r,i=!1,$=!1,u=!1;function p(){return b===1&&c<s.maxMismatches-1}for(;e[n];){let E=l(n);if(s.trimBeforeMatching&&e[n].trim()===""){if(!e[E]&&a&&t==="EOL")return!0;n=l(n);continue}if(s&&!s.i&&((f=s==null?void 0:s.trimCharsBeforeMatching)!=null&&f.includes(e[n]))||s!=null&&s.i&&s.trimCharsBeforeMatching&&s.trimCharsBeforeMatching.map(M=>M.toLowerCase()).includes(e[n].toLowerCase())){if(a&&t==="EOL"&&!e[E])return!0;n=l(n);continue}let R=E>n?t[t.length-m]:t[m-1];if(!s.i&&e[n]===R||s.i&&R!==void 0&&e[n].toLowerCase()===R.toLowerCase()){if(i||(i=!0),y||(y=!0),m===t.length){if($=!0,c!==s.maxMismatches)return!1}else m===1&&(u=!0);if(m-=1,b++,p())return!1;if(!m)return b!==t.length||c===s.maxMismatches||!C?n:!1}else if(!C&&!b&&(C=!0),s.maxMismatches&&c&&n){c-=1;for(let M=0;M<=c;M++){let D=E>n?t[t.length-m+1+M]:t[m-2-M],v=e[l(n)];if(D&&(!s.i&&e[n]===D||s.i&&e[n].toLowerCase()===D.toLowerCase())&&(!s.firstMustMatch||m!==t.length)){if(b++,p())return!1;m-=2,i=!0;break}else if(v&&D&&(!s.i&&v===D||s.i&&v.toLowerCase()===D.toLowerCase())&&(!s.firstMustMatch||m!==t.length)){if(!b&&!s.hungry)return!1;m-=1,i=!0;break}else if(D===void 0&&c>=0&&i&&(!s.firstMustMatch||$)&&(!s.lastMustMatch||u))return n}i||(d=n)}else return n===0&&m===1&&!s.lastMustMatch&&y?0:!1;if(d!==!1&&d!==n&&(d=!1),m<1)return n;n=l(n)}if(m>0)return a&&h==="EOL"?!0:s&&s.maxMismatches>=m&&y?d||0:!1}function k(e,r,t,o,a){var C,d,y;if(S(a)&&F(a,"trimBeforeMatching")&&a&&typeof a.trimBeforeMatching!="boolean")throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_01] opts.trimBeforeMatching should be boolean!").concat(Array.isArray(a.trimBeforeMatching)?" Did you mean to use opts.trimCharsBeforeMatching?":""));let l=V(V({},x),a);if(typeof l.trimCharsBeforeMatching=="string"&&(l.trimCharsBeforeMatching=I(l.trimCharsBeforeMatching)),l.trimCharsBeforeMatching=l.trimCharsBeforeMatching.map(c=>T(c)?c:String(c)),!T(r)||!r.length)return!1;if(!Number.isInteger(t)||t<0)throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_02] the second argument should be a natural number. Currently it's of a type: ").concat(typeof t,", equal to:\n").concat(O(t,4)));let h,s;if(T(o))h=[o];else if(Array.isArray(o))h=o;else if(!o)h=o;else if(typeof o=="function")h=[],h.push(o);else throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_03] the third argument, whatToMatch, is neither string nor array of strings! It's ").concat(typeof o,", equal to:\n").concat(O(o,4)));if(a&&!S(a))throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_04] the fourth argument, options object, should be a plain object. Currently it's of a type \"").concat(typeof a,'", and equal to:\n').concat(O(a,4)));let m=0,b="";if((C=l==null?void 0:l.trimCharsBeforeMatching)!=null&&C.some((c,n)=>c.length>1?(m=n,b=c,!0):!1))throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_05] the fourth argument, options object contains trimCharsBeforeMatching. It was meant to list the single characters but one of the entries at index ").concat(m," is longer than 1 character, ").concat(b.length," (equals to ").concat(b,"). Please split it into separate characters and put into array as separate elements."));if(!h||!Array.isArray(h)||Array.isArray(h)&&!h.length||Array.isArray(h)&&h.length===1&&T(h[0])&&!h[0].trim()){if(typeof l.cb=="function"){let n,i=t;if((e==="matchLeftIncl"||e==="matchRight")&&(i+=1),e[5]==="L")for(let g=i;g--;){let f=r[g];if((!l.trimBeforeMatching||l.trimBeforeMatching&&(f!=null&&f.trim()))&&(!((d=l.trimCharsBeforeMatching)!=null&&d.length)||f!==void 0&&!l.trimCharsBeforeMatching.includes(f))){n=g;break}}else if(e.startsWith("matchRight"))for(let g=i;g<r.length;g++){let f=r[g];if((!l.trimBeforeMatching||l.trimBeforeMatching&&f.trim())&&(!((y=l.trimCharsBeforeMatching)!=null&&y.length)||!l.trimCharsBeforeMatching.includes(f))){n=g;break}}if(n===void 0)return!1;let $=r[n],u=n+1,p="";return u&&u>0&&(p=r.slice(0,u)),e[5]==="L"||n&&n>0&&(p=r.slice(n)),l.cb($,p,n)}let c="";throw a||(c=" More so, the whole options object, the fourth input argument, is missing!"),new Error("string-match-left-right/".concat(e,'(): [THROW_ID_06] the third argument, "whatToMatch", was given as an empty string. This means, you intend to match purely by a callback. The callback was not set though, the opts key "cb" is not set!').concat(c))}for(let c=0,n=h.length;c<n;c++){s=typeof h[c]=="function";let i=h[c],$,u,p="",g=t;e==="matchRight"?g+=1:e==="matchLeft"&&(g-=1);let f=te(r,g,i,l,s,E=>e[5]==="L"?E-1:E+1);if(f&&s&&typeof i=="function"&&i()==="EOL")return i()&&(!l.cb||l.cb($,p,u))?i():!1;if(Number.isInteger(f)&&(u=e.startsWith("matchLeft")?f-1:f+1,e[5]==="L"?p=r.slice(0,f):p=r.slice(u)),u<0&&(u=void 0),r[u]&&($=r[u]),Number.isInteger(f)&&(!l.cb||l.cb($,p,u)))return i}return!1}function ne(e,r,t,o){return k("matchLeftIncl",e,r,t,o)}function re(e,r,t,o){return k("matchLeft",e,r,t,o)}function oe(e,r,t,o){return k("matchRightIncl",e,r,t,o)}function se(e,r,t,o){return k("matchRight",e,r,t,o)}return Y(ie);})();
10
+ "use strict";var stringMatchLeftRight=(()=>{var V=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var Y=Object.getOwnPropertyNames,L=Object.getOwnPropertySymbols;var N=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable;var I=(e,r,t)=>r in e?V(e,r,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[r]=t,k=(e,r)=>{for(var t in r||(r={}))N.call(r,t)&&I(e,t,r[t]);if(L)for(var t of L(r))Z.call(r,t)&&I(e,t,r[t]);return e};var X=(e,r)=>{for(var t in r)V(e,t,{get:r[t],enumerable:!0})},ee=(e,r,t,n)=>{if(r&&typeof r=="object"||typeof r=="function")for(let c of Y(r))!N.call(e,c)&&c!==t&&V(e,c,{get:()=>r[c],enumerable:!(n=Q(r,c))||n.enumerable});return e};var te=e=>ee(V({},"__esModule",{value:!0}),e);var de={};X(de,{defaultGetNextIdx:()=>j,defaults:()=>x,matchLeft:()=>pe,matchLeftIncl:()=>me,matchRight:()=>be,matchRightIncl:()=>$e,version:()=>ue});function B(e){return typeof e!="string"?e:e.length?[e]:[]}function re(){let e=[],r=0,t=!1;return{append(n){return t?!1:r+n.length>1999?(e.push("\u2026"),r+=1,t=!0,!1):(e.push(n),r+=n.length,!0)},result(){return e.join("")},stopped(){return t}}}function ne(e){return"\\u".concat(e.toString(16).padStart(4,"0"))}function A(e,r){if(e.append('"')){for(let t=0;t<r.length&&!e.stopped();t+=1){let n=r.charCodeAt(t);n===34?e.append('\\"'):n===92?e.append("\\\\"):n===8?e.append("\\b"):n===9?e.append("\\t"):n===10?e.append("\\n"):n===12?e.append("\\f"):n===13?e.append("\\r"):n<32||n===8232||n===8233||n>=55296&&n<=57343?e.append(ne(n)):e.append(r[t])}e.append('"')}}function _e(e){return e.get&&e.set?"[Getter/Setter]":e.get?"[Getter]":e.set?"[Setter]":"[Accessor]"}function W(e,r){e.append("Symbol(");let t=String(r);t.length>8&&A(e,t.slice(7,-1)),e.append(")")}function P(e,r){typeof r=="symbol"?W(e,r):A(e,String(r))}function w(e,r=0){let t=re(),n=r===4?4:0,c=new WeakSet,o=0;function a(_){n&&t.append(" ".repeat(_*n))}function u(_,l){_&&t.append(","),n&&(t.append("\n"),a(l+1))}function y(_,l,h){n&&l&&(t.append("\n"),a(h)),t.append(_)}function E(_,l){Object.prototype.hasOwnProperty.call(_,"value")?b(_.value,l):t.append(_e(_))}function D(_,l){let h;try{h=Reflect.getOwnPropertyDescriptor(_,"length")}catch(s){t.append("[Uninspectable]");return}let m=h==null?void 0:h.value;if(!Number.isSafeInteger(m)||m<0){t.append("[Uninspectable]");return}t.append("[");let i=!1;for(let s=0;s<m&&!t.stopped();s+=1){if(u(i,l),i=!0,o>=50){t.append("[MaxEntries]");break}o+=1;let g;try{g=Reflect.getOwnPropertyDescriptor(_,String(s))}catch(d){t.append("[Uninspectable]");continue}g!=null&&g.enumerable?E(g,l+1):t.append("[Empty]")}y("]",i,l)}function M(_,l){let h;try{h=Reflect.ownKeys(_)}catch(i){t.append("[Uninspectable]");return}t.append("{");let m=!1;for(let i of h){if(t.stopped())break;if(o>=50){u(m,l),m=!0,A(t,"\u2026"),t.append(n?": ":":"),t.append("[MaxEntries]");break}o+=1;let s;try{s=Reflect.getOwnPropertyDescriptor(_,i)}catch(g){u(m,l),m=!0,P(t,i),t.append(n?": ":":"),t.append("[Uninspectable]");continue}s!=null&&s.enumerable&&(u(m,l),m=!0,P(t,i),t.append(n?": ":":"),E(s,l+1))}y("}",m,l)}function $(_,l){if(c.has(_)){t.append("[Circular]");return}if(l>=5){t.append("[MaxDepth]");return}let h;try{h=Array.isArray(_)}catch(m){t.append("[Uninspectable]");return}c.add(_);try{h?D(_,l):M(_,l)}finally{c.delete(_)}}function b(_,l){_===null?t.append("null"):typeof _=="string"?A(t,_):typeof _=="number"?t.append(Object.is(_,-0)?"-0":String(_)):typeof _=="boolean"?t.append(_?"true":"false"):typeof _>"u"?t.append("undefined"):typeof _=="bigint"?t.append("".concat(_,"n")):typeof _=="symbol"?W(t,_):typeof _=="function"?t.append("[Function]"):$(_,l)}try{return b(e,0),t.result()}catch(_){return"[Uninspectable]"}}var oe=["_16_0_a_0_4_0_5_m_1_u_1_cp_4_b_e_4_7_0_1_0_3l_4_1_1_2_3_1_0_6_0_1_2_1_0_1_j_1_2a_1_3u_8_4l_1_11_2_0_","6_14_1z_q_4_3_19_16_z_1_1_2q_1_0_f_1_7_1_a_2_2_0_g_0_1_t_t_2g_b_0_o_w_9_1_4_0_5_l_4_0_9_0_3_0_n_o_7_","a_5_n_1_6_g_15_1m_1h_3_0_i_0_7_9_f_f_4_7_2_1_2_l_1_6_1_0_3_3_3_0_g_0_d_1_1_2_e_1_a_0_8_5_4_1_2_l_1_6","_1_1_1_1_1_1_v_3_1_0_j_2_g_8_1_2_1_l_1_6_1_1_1_4_3_0_i_0_f_1_n_0_b_7_2_1_2_l_1_6_1_1_1_4_3_0_u_1_1_2","_f_0_h_0_1_5_3_2_1_3_3_1_1_0_1_1_3_1_3_2_3_b_m_0_1g_7_1_2_1_m_1_f_3_0_q_2_1_1_2_1_u_0_4_7_1_2_1_m_1_","9_1_4_3_0_u_2_1_1_f_1_h_8_1_2_1_14_2_0_g_0_5_2_8_2_o_5_5_h_3_n_1_8_1_0_2_6_1m_1b_1_1_c_6_1m_1_1_0_1_","4_1_n_1_0_1_9_1_1_9_0_2_4_1_0_l_3_w_0_1r_7_1_z_r_4_37_16_k_0_g_5_4_3_3_0_3_1_7_2_4_c_c_0_h_11_1_0_5_","0_2_16_1_98_1_3_2_6_1_0_1_3_2_14_1_3_2_w_1_3_2_6_1_0_1_3_2_e_1_1k_1_3_2_1u_11_f_g_2d_2_5_3_h7_2_g_1_","p_5_22_6_7_7_h_d_i_e_h_e_c_1_2_f_1f_z_0_4_0_1v_2g_7_4_2_x_1_0_5_1x_a_u_1d_t_2_4_b_17_4_p_1i_m_9_1g_2","a_0_2l_1a_h_7_1i_t_d_1_a_17_q_z_15_2_a_z_2_a_5_16_2_2_15_3_1_5_1_1_3_0_5_5b_1s_7p_2_5_2_11_2_5_2_7_1","_0_1_0_1_0_1_u_2_1g_1_6_1_0_3_2_1_6_3_3_2_5_4_c_5_2_1_6_38_0_d_0_g_c_2t_0_4_0_2_9_1_0_3_4_6_0_1_0_1_","0_1_3_1_a_2_3_5_4_4_0_1g_1_22j_6c_6_3_3_1_c_11_1_0_5_0_2_1j_7_0_g_m_9_6_1_6_1_6_1_6_1_6_1_6_1_6_1_6_","28_0_d1_1_16_4_5_1_4_2d_6_2_1_2h_1_3_5_16_1_2l_h_v_1c_f_e8_533_1s_h3g_1v_19_2_7g_3_f_a_1_k_1a_g_u_2_","1x_1d_8_2_2u_2_29_k_g_1_2_1_3_1_m_t_1f_e_1d_1q_5_3_0_1_1_b_r_a_m_p_s_7_1a_s_0_g_4_1_9_a_4_1_14_n_2_1","_7_k_m_3_0_3_1d_1_0_3_1_2_4_2_0_1_0_o_2_2_a_7_2_c_5_2_5_2_5_9_6_1_6_1_16_1_d_6_36_t_8mb_c_m_4_1c_6is","_a5_2_2x_12_6_c_4_5_0_1_9_1_c_1_4_1_0_1_1_1_1_1_2z_x_a2_i_1r_2_1h_14_b_38_4_1_3q_10_p_6_p_b_2g_3_5_2","_5_2_5_2_2_z_b_1_p_1_i_1_1_1_e_2_d_y_3e_at_s_3_1c_1b_v_d_j_1_7_6_11_a_t_2_z_4_7_1c_4d_i_z_4_z_4_13_8","_1f_c_a_1_e_1_6_1_1_1_a_1_e_1_6_1_1_3_1f_c_8m_9_l_a_7_o_5_1_15_1_8_1x_5_2_0_1_17_1_1_3_0_2_m_a_m_9_u","_1t_i_1_1_a_l_a_p_6_p_12_1j_6_1_1s_0_f_3_1_2_1_s_16_s_3_s_z_7_1_r_r_1h_a_l_a_i_d_h_32_20_1j_1e_d_1e_","d_z_12_r_9_m_6y_15_6_1_g_5_1k_s_a_0_8_l_16_h_1a_k_r_m_c_1g_1l_1_2_0_d_18_w_o_q_z_t_0_2_0_8_y_3_0_c_1","b_e_3_l_0_1_0_z_h_1_o_j_1_1r_6_1_0_1_3_1_e_1_9_7_1a_12_7_2_1_2_l_1_6_1_1_1_4_3_0_i_0_c_4_u_9_1_0_2_0","_1_11_1_0_p_0_1_0_18_1g_i_3_k_2_u_1b_k_1_1_0_54_1a_15_3_10_1b_k_0_1n_16_d_0_1z_q_11_6_55_17_38_1r_v_","7_2_0_2_7_1_1_1_n_f_0_1_0_2m_7_2_12_g_0_1_0_s_0_a_13_7_0_l_0_b_19_j_0_i_20_5j_w_v_8_1_10_h_0_1d_t_34","_6_1_1_1_11_l_0_p_5_1_1_1_v_e_0_n_17_78_i_f_0_1_c_1_x_3g_0_27_pl_6e_5f_218_2o_f_tr_h_5_p_32y_5_g6_5a","1_t_1cy_fs_7_u_h_26_h_t_i_1b_g_3_v_k_5_i_c0_18_5v_1r_w_o_2_o_18_22_5_0_1u_c_1s_1_1_0_e_1_c_5p1_15_v_","2p_36_6pp_3_1_6_1_1_1_82_f_0_t_2_2_0_e_3_8_az_1s4_2y_5_c_3_8_7_9_4me_2c_1_1y_1_1_2_0_2_1_2_3_1_b_1_0","_1_6_1_1s_1_3_2_7_1_6_1_r_1_3_1_4_1_0_3_6_1_9f_2_o_1_o_1_u_1_o_1_u_1_o_1_u_1_o_1_u_1_o_1_7_1f8_u_6_5","_79_1p_42_18_a_6_g_0_8x_t_i_17_dg_r_6c_t_2_0_5r_u_1_2_1_1_1_6_2_4_9_1_68_6_1_3_1_1_1_e_1_5g_1n_1v_7_","0_xg_3_1_q_1_1_1_0_2_0_1_9_1_3_1_0_1_0_6_0_4_0_1_0_1_0_1_2_1_1_1_0_2_0_1_0_1_0_1_0_1_0_1_1_1_0_2_3_1","_6_1_3_1_3_1_0_1_9_1_g_5_2_1_4_1_g_3es_wyn_w_3dp_2_4gd_2_5rk_f_h9_1wi_f1_15u_3t6_5_6jt"].join(""),R=oe.slice(1).split("_"),ie=[],F=127;for(let e=0;e<R.length;e+=2){let r=F+1+Number.parseInt(R[e],36),t=r+Number.parseInt(R[e+1],36);ie.push([r,t]),F=t}var we=new Set([..."\u060B$\u20BC\u17DB\xA5\u20A1\u20B1\xA3\u20AC\xA2\u20B9\uFDFC\u20AA\u20A9\u20AD\u20A8\u20AE\u20A6\u20BD\u20AB\u0E3F\u20A9\u20BA\u20B4","$U","$b","B/.","BZ$","Br","Bs","C$","CHF","Ft","Gs","J$","KM","K\u010D","L","MT","NT$","P","Q","R","R$","RD$","RM","Rp","S","S/.","TT$","Z$","kn","kr","lei","z\u0142","\u0192","\u0414\u0438\u043D.","\u0434\u0435\u043D","\u043B\u0432","\u062F.\u0625","Lek"]),le=Object.prototype.hasOwnProperty,q=Function.prototype.toString,se=q.call(Object);var Oe=Map.prototype.entries,Te=Set.prototype.values;var U,Ve=(U=Object.getOwnPropertyDescriptor(ArrayBuffer.prototype,"byteLength"))==null?void 0:U.get,J,Ae=(J=Object.getOwnPropertyDescriptor(RegExp.prototype,"flags"))==null?void 0:J.get,H,ve=(H=Object.getOwnPropertyDescriptor(RegExp.prototype,"global"))==null?void 0:H.get,z,ke=(z=Object.getOwnPropertyDescriptor(RegExp.prototype,"source"))==null?void 0:z.get,Re=RegExp.prototype.test;function S(e){var n;if(e==null||typeof e!="object")return!1;let r=Object.getPrototypeOf(e);if(r===null||r===Object.prototype)return!0;let t=Object.getOwnPropertyDescriptor(r,"constructor");return!t||!("value"in t)||typeof t.value!="function"?!1:((n=Object.getOwnPropertyDescriptor(t.value,"prototype"))==null?void 0:n.value)===r&&q.call(t.value)===se}function T(e){return typeof e=="string"}var Se=Date.prototype.getTime;function K(e,r){return e!=null&&le.call(e,r)}var G="9.2.3";var ue=G,x={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},j=e=>e+1,ce=e=>e-1;function fe(e,r,t,n,c=()=>!1,o=!1,a=j){if(+r<0&&o&&t==="EOL")return t;if(r>=e.length&&!o)return!1;let u=o?1:t.length,y=0,E=!1,D=!1,M=!1,$=Math.min(n.maxMismatches,e.length+t.length),b=$,_=r,l=!1,h=!1,m=!1;function i(){return y===1&&b<$-1}for(;e[_];){let g=a(_);if(n.trimBeforeMatching&&e[_].trim()===""){if(!e[g]&&o&&t==="EOL")return!0;_=a(_);continue}if(c(e[_])){if(o&&t==="EOL"&&!e[g])return!0;_=a(_);continue}if(o)return!1;let d=g>_?t[t.length-u]:t[u-1];if(!n.i&&e[_]===d||n.i&&d!==void 0&&e[_].toLowerCase()===d.toLowerCase()){if(l||(l=!0),M||(M=!0),u===t.length){if(h=!0,b!==$)return!1}else u===1&&(m=!0);if(u-=1,y++,i())return!1;if(!u)return y!==t.length||b===$||!E?_:!1}else if(!E&&!y&&(E=!0),$&&b&&_){b-=1;for(let C=0;C<=b;C++){let f=g>_?t[t.length-u+1+C]:t[u-2-C],p=e[a(_)];if(f&&(!n.i&&e[_]===f||n.i&&e[_].toLowerCase()===f.toLowerCase())&&(!n.firstMustMatch||u!==t.length)){if(y++,i())return!1;u-=2,l=!0;break}else if(p&&f&&(!n.i&&p===f||n.i&&p.toLowerCase()===f.toLowerCase())&&(!n.firstMustMatch||u!==t.length)){if(!y&&!n.hungry)return!1;u-=1,l=!0;break}else if(f===void 0&&b>=0&&l&&(!n.firstMustMatch||h)&&(!n.lastMustMatch||m))return _}l||(D=_)}else return _===0&&u===1&&$>0&&b>0&&(!n.firstMustMatch||h)&&!n.lastMustMatch&&M?0:!1;if(D!==!1&&D!==_&&(D=!1),u<1)return _;_=a(_)}if(u>0)return o&&t==="EOL"?!0:n&&$>=u&&M?D||0:!1}function v(e,r,t,n,c){var _,l,h,m;if(S(c)&&K(c,"trimBeforeMatching")&&c&&typeof c.trimBeforeMatching!="boolean")throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_01] opts.trimBeforeMatching should be boolean!").concat(Array.isArray(c.trimBeforeMatching)?" Did you mean to use opts.trimCharsBeforeMatching?":""));let o=k(k({},x),c);if(o.maxMismatches=(_=c==null?void 0:c.maxMismatches)!=null?_:x.maxMismatches,he(o.maxMismatches,e),typeof o.trimCharsBeforeMatching=="string"&&(o.trimCharsBeforeMatching=B(o.trimCharsBeforeMatching)),o.trimCharsBeforeMatching=o.trimCharsBeforeMatching.map(i=>T(i)?i:String(i)),!T(r)||!r.length)return!1;if(!Number.isInteger(t)||t<0)throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_02] the second argument should be a natural number. Currently it's of a type: ").concat(typeof t,", equal to:\n").concat(w(t,4)));let a,u;if(T(n))a=[n];else if(Array.isArray(n))a=n;else if(!n)a=n;else if(typeof n=="function")a=[],a.push(n);else throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_03] the third argument, whatToMatch, is neither string nor array of strings! It's ").concat(typeof n,", equal to:\n").concat(w(n,4)));if(ge(a,e),c&&!S(c))throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_04] the fourth argument, options object, should be a plain object. Currently it's of a type \"").concat(typeof c,'", and equal to:\n').concat(w(c,4)));let y=0,E="";if((l=o==null?void 0:o.trimCharsBeforeMatching)!=null&&l.some((i,s)=>i.length>1?(y=s,E=i,!0):!1))throw new Error("string-match-left-right/".concat(e,"(): [THROW_ID_05] the fourth argument, options object contains trimCharsBeforeMatching. It was meant to list the single characters but one of the entries at index ").concat(y," is longer than 1 character, ").concat(E.length," (equals to ").concat(E,"). Please split it into separate characters and put into array as separate elements."));if(t>=r.length)return!1;let D=o.i?o.trimCharsBeforeMatching.map(i=>i.toLowerCase()):o.trimCharsBeforeMatching,M=o.i?i=>D.includes(i.toLowerCase()):i=>D.includes(i);if(!a||!Array.isArray(a)||Array.isArray(a)&&!a.length||Array.isArray(a)&&a.length===1&&T(a[0])&&!a[0].trim()){if(typeof o.cb=="function"){let s,g=t;if((e==="matchLeftIncl"||e==="matchRight")&&(g+=1),e[5]==="L")for(let f=g;f--;){let p=r[f];if((!o.trimBeforeMatching||o.trimBeforeMatching&&(p!=null&&p.trim()))&&(!((h=o.trimCharsBeforeMatching)!=null&&h.length)||p!==void 0&&!M(p))){s=f;break}}else if(e.startsWith("matchRight"))for(let f=g;f<r.length;f++){let p=r[f];if((!o.trimBeforeMatching||o.trimBeforeMatching&&p.trim())&&(!((m=o.trimCharsBeforeMatching)!=null&&m.length)||!M(p))){s=f;break}}if(s===void 0)return!1;let d=r[s],C=e[5]==="L"?r.slice(0,s+1):r.slice(s);return e[5]==="L",o.cb(d,C,s)}let i="";throw c||(i=" More so, the whole options object, the fourth input argument, is missing!"),new Error("string-match-left-right/".concat(e,'(): [THROW_ID_06] the third argument, "whatToMatch", was given as an empty string. This means, you intend to match purely by a callback. The callback was not set though, the opts key "cb" is not set!').concat(i))}if(!o.cb&&!o.i&&!o.trimBeforeMatching&&!o.trimCharsBeforeMatching.length&&o.maxMismatches===0&&!o.firstMustMatch&&!o.lastMustMatch&&!o.hungry&&a.every(T)){for(let i of a){if(!i.length)continue;let s=t;if(e==="matchRight"?s+=1:e==="matchLeft"?s-=i.length:e==="matchLeftIncl"&&(s-=i.length-1),s>=0&&r.startsWith(i,s))return i}return!1}let $=t;e==="matchRight"?$+=1:e==="matchLeft"&&($-=1);let b=e[5]==="L"?ce:j;for(let i=0,s=a.length;i<s;i++){u=typeof a[i]=="function";let g=a[i],d=typeof g=="function"?g():g;if(u&&d!=="EOL")throw new Error("string-match-left-right/".concat(e,'(): [THROW_ID_09] EOL marker functions must return "EOL". The function at index ').concat(i," returned:\n").concat(w(d,4)));if(u&&e.endsWith("Incl"))continue;let C,f,p="",O=fe(r,$,d,o,M,u,b);if(O&&u)return!o.cb||o.cb(C,p,f)?d:!1;if(Number.isInteger(O)&&(f=e.startsWith("matchLeft")?O-1:O+1,e[5]==="L"?p=r.slice(0,O):p=r.slice(f)),f<0&&(f=void 0),r[f]&&(C=r[f]),Number.isInteger(O)&&(!o.cb||o.cb(C,p,f)))return d}return!1}function he(e,r){if(!Number.isSafeInteger(e)||e<0)throw new Error("string-match-left-right/".concat(r,"(): [THROW_ID_07] opts.maxMismatches must be a non-negative safe integer. Currently it's of a type: ").concat(typeof e,", equal to:\n").concat(w(e,4)))}function ge(e,r){if(e)for(let t=0;t<e.length;t+=1){let n=e[t];if(typeof n!="string"&&typeof n!="function")throw new Error("string-match-left-right/".concat(r,"(): [THROW_ID_08] matcher alternatives must be strings or EOL marker functions. The value at index ").concat(t," is of a type: ").concat(typeof n,", equal to:\n").concat(w(n,4)))}}function me(e,r,t,n){return v("matchLeftIncl",e,r,t,n)}function pe(e,r,t,n){return v("matchLeft",e,r,t,n)}function $e(e,r,t,n){return v("matchRightIncl",e,r,t,n)}function be(e,r,t,n){return v("matchRight",e,r,t,n)}return te(de);})();
11
11
  /**
12
12
  * @name arrayiffy-if-string
13
13
  * @fileoverview Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else.
14
- * @version 5.2.1
14
+ * @version 5.2.2
15
15
  * @author Roy Revelt
16
16
  * @license MIT
17
17
  * {@link https://codsen.com/os/arrayiffy-if-string/}
18
18
  */
19
+ /**
20
+ * @name codsen-format-diagnostic-value
21
+ * @fileoverview Safely format untrusted JavaScript values for diagnostics
22
+ * @version 1.1.0
23
+ * @author Roy Revelt
24
+ * @license MIT
25
+ * {@link https://codsen.com/os/codsen-format-diagnostic-value/}
26
+ */
19
27
  /**
20
28
  * @name codsen-utils
21
29
  * @fileoverview Various utility functions
22
- * @version 1.8.0
30
+ * @version 1.10.0
23
31
  * @author Roy Revelt
24
32
  * @license MIT
25
33
  * {@link https://codsen.com/os/codsen-utils/}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "string-match-left-right",
3
- "version": "9.2.1",
3
+ "version": "9.2.3",
4
4
  "description": "Match substrings on the left or right of a given index, ignoring whitespace",
5
5
  "keywords": [
6
6
  "left",
@@ -64,8 +64,8 @@
64
64
  }
65
65
  },
66
66
  "dependencies": {
67
- "arrayiffy-if-string": "^5.2.1",
68
- "codsen-utils": "^1.8.0"
67
+ "arrayiffy-if-string": "^5.2.2",
68
+ "codsen-utils": "^1.10.0"
69
69
  },
70
70
  "engines": {
71
71
  "node": ">=18.20.8"
package/types/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  declare const version: string;
2
+ type Matcher = string | (() => string);
2
3
  interface Opts {
3
4
  cb:
4
5
  | undefined
@@ -21,25 +22,25 @@ declare const defaultGetNextIdx: (index: number) => number;
21
22
  declare function matchLeftIncl(
22
23
  str: string,
23
24
  position: number,
24
- whatToMatch: (() => string) | string | string[],
25
+ whatToMatch: Matcher | Matcher[],
25
26
  opts?: Partial<Opts>,
26
27
  ): boolean | string;
27
28
  declare function matchLeft(
28
29
  str: string,
29
30
  position: number,
30
- whatToMatch: (() => string) | string | string[],
31
+ whatToMatch: Matcher | Matcher[],
31
32
  opts?: Partial<Opts>,
32
33
  ): boolean | string;
33
34
  declare function matchRightIncl(
34
35
  str: string,
35
36
  position: number,
36
- whatToMatch: (() => string) | string | string[],
37
+ whatToMatch: Matcher | Matcher[],
37
38
  opts?: Partial<Opts>,
38
39
  ): boolean | string;
39
40
  declare function matchRight(
40
41
  str: string,
41
42
  position: number,
42
- whatToMatch: (() => string) | string | string[],
43
+ whatToMatch: Matcher | Matcher[],
43
44
  opts?: Partial<Opts>,
44
45
  ): boolean | string;
45
46
 
@@ -52,4 +53,4 @@ export {
52
53
  matchRightIncl,
53
54
  version,
54
55
  };
55
- export type { Opts };
56
+ export type { Matcher, Opts };