string-match-left-right 9.2.0 → 9.2.2

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,18 @@
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.2 (2026-08-22)
7
+
8
+ ### Performance Improvements
9
+
10
+ - optimise package hot paths and JSON editing ([f3112bd](https://github.com/codsen/codsen/commit/f3112bd7fc0d7c9bc09312d3744c950691d72ca5))
11
+
6
12
  ## 9.2.0 (2026-08-19)
7
13
 
8
14
  ### Bug Fixes
9
15
 
10
16
  - 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))
17
+ - resolve various review findings ([b60e9ee](https://github.com/codsen/codsen/commit/b60e9eeb499af94685cfb87b4970fe025be1fc10))
12
18
  - retire direct publish aliases ([f98e31e](https://github.com/codsen/codsen/commit/f98e31eb89bc185471225664e610b55f34fbf648))
13
19
  - standardise matcher validation errs ([6f8f858](https://github.com/codsen/codsen/commit/6f8f858104ecd066189d287901f80c94b581d08b))
14
20
  - stop case-insensitive matching crashing on a null index ([5682575](https://github.com/codsen/codsen/commit/56825755acdcb8c9f2be089bf13cb24ba032e950))
@@ -1,13 +1,13 @@
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.0
4
+ * @version 9.2.2
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.0";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:
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.2";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
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
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
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};
@@ -1,17 +1,17 @@
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.0
4
+ * @version 9.2.2
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.0";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 w=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames,L=Object.getOwnPropertySymbols;var B=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var I=(e,n,t)=>n in e?w(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,V=(e,n)=>{for(var t in n||(n={}))B.call(n,t)&&I(e,t,n[t]);if(L)for(var t of L(n))q.call(n,t)&&I(e,t,n[t]);return e};var Q=(e,n)=>{for(var t in n)w(e,t,{get:n[t],enumerable:!0})},Y=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of _(n))!B.call(e,a)&&a!==t&&w(e,a,{get:()=>n[a],enumerable:!(o=H(n,a))||o.enumerable});return e};var G=e=>Y(w({},"__esModule",{value:!0}),e);var le={};Q(le,{defaultGetNextIdx:()=>J,defaults:()=>x,matchLeft:()=>oe,matchLeftIncl:()=>ne,matchRight:()=>ie,matchRightIncl:()=>se,version:()=>te});function N(e){return typeof e!="string"?e:e.length?[e]:[]}function K(){let e=[],n=0,t=!1;return{append(o){return t?!1:n+o.length>1999?(e.push("\u2026"),n+=1,t=!0,!1):(e.push(o),n+=o.length,!0)},result(){return e.join("")},stopped(){return t}}}function z(e){return"\\u".concat(e.toString(16).padStart(4,"0"))}function A(e,n){if(e.append('"')){for(let t=0;t<n.length&&!e.stopped();t+=1){let o=n.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(z(o)):e.append(n[t])}e.append('"')}}function Z(e){return e.get&&e.set?"[Getter/Setter]":e.get?"[Getter]":e.set?"[Setter]":"[Accessor]"}function F(e,n){e.append("Symbol(");let t=String(n);t.length>8&&A(e,t.slice(7,-1)),e.append(")")}function j(e,n){typeof n=="symbol"?F(e,n):A(e,String(n))}function O(e,n=0){let t=K(),o=n===4?4:0,a=new WeakSet,l=0;function h(r){o&&t.append(" ".repeat(r*o))}function s(r,i){r&&t.append(","),o&&(t.append("\n"),h(i+1))}function m(r,i,$){o&&i&&(t.append("\n"),h($)),t.append(r)}function b(r,i){Object.prototype.hasOwnProperty.call(r,"value")?c(r.value,i):t.append(Z(r))}function C(r,i){let $;try{$=Reflect.getOwnPropertyDescriptor(r,"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(r,String(g))}catch(E){t.append("[Uninspectable]");continue}f!=null&&f.enumerable?b(f,i+1):t.append("[Empty]")}m("]",p,i)}function d(r,i){let $;try{$=Reflect.ownKeys(r)}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(r,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(r,i){if(a.has(r)){t.append("[Circular]");return}if(i>=5){t.append("[MaxDepth]");return}let $;try{$=Array.isArray(r)}catch(u){t.append("[Uninspectable]");return}a.add(r);try{$?C(r,i):d(r,i)}finally{a.delete(r)}}function c(r,i){r===null?t.append("null"):typeof r=="string"?A(t,r):typeof r=="number"?t.append(Object.is(r,-0)?"-0":String(r)):typeof r=="boolean"?t.append(r?"true":"false"):typeof r>"u"?t.append("undefined"):typeof r=="bigint"?t.append("".concat(r,"n")):typeof r=="symbol"?F(t,r):typeof r=="function"?t.append("[Function]"):y(r,i)}try{return c(e,0),t.result()}catch(r){return"[Uninspectable]"}}var fe=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"]),X=Object.prototype.hasOwnProperty;function S(e){if(e==null||typeof e!="object")return!1;let n=Object.getPrototypeOf(e);return n!==null&&n!==Object.prototype&&Object.getPrototypeOf(n)!==null?!1:!(Symbol.iterator in e)&&!(Symbol.toStringTag in e)}function M(e){return typeof e=="string"}var W,he=(W=Object.getOwnPropertyDescriptor(RegExp.prototype,"source"))==null?void 0:W.get;var ge=Date.prototype.getTime;function P(e,n){return S(e)&&M(n)&&X.call(e,n)}var U="9.2.2";var te=U,x={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},J=e=>e+1;function re(e,n,t,o,a=!1,l=J){var f;let h=typeof t=="function"?t():t;if(+n<0&&a&&h==="EOL")return h;let s=V(V({},x),o);if(n>=e.length&&!a)return!1;let m=a?1:t.length,b=0,C=!1,d=!1,y=!1,c=s.maxMismatches,r=n,i=!1,$=!1,u=!1;function p(){return b===1&&c<s.maxMismatches-1}for(;e[r];){let E=l(r);if(s.trimBeforeMatching&&e[r].trim()===""){if(!e[E]&&a&&t==="EOL")return!0;r=l(r);continue}if(s&&!s.i&&((f=s==null?void 0:s.trimCharsBeforeMatching)!=null&&f.includes(e[r]))||s!=null&&s.i&&s.trimCharsBeforeMatching&&s.trimCharsBeforeMatching.map(T=>T.toLowerCase()).includes(e[r].toLowerCase())){if(a&&t==="EOL"&&!e[E])return!0;r=l(r);continue}let R=E>r?t[t.length-m]:t[m-1];if(!s.i&&e[r]===R||s.i&&R!==void 0&&e[r].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?r:!1}else if(!C&&!b&&(C=!0),s.maxMismatches&&c&&r){c-=1;for(let T=0;T<=c;T++){let D=E>r?t[t.length-m+1+T]:t[m-2-T],v=e[l(r)];if(D&&(!s.i&&e[r]===D||s.i&&e[r].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 r}i||(d=r)}else return r===0&&m===1&&!s.lastMustMatch&&y?0:!1;if(d!==!1&&d!==r&&(d=!1),m<1)return r;r=l(r)}if(m>0)return a&&h==="EOL"?!0:s&&s.maxMismatches>=m&&y?d||0:!1}function k(e,n,t,o,a){var C,d,y;if(S(a)&&P(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=N(l.trimCharsBeforeMatching)),l.trimCharsBeforeMatching=l.trimCharsBeforeMatching.map(c=>M(c)?c:String(c)),!M(n)||!n.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(M(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,r)=>c.length>1?(m=r,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&&M(h[0])&&!h[0].trim()){if(typeof l.cb=="function"){let r,i=t;if((e==="matchLeftIncl"||e==="matchRight")&&(i+=1),e[5]==="L")for(let g=i;g--;){let f=n[g];if((!l.trimBeforeMatching||l.trimBeforeMatching&&(f!=null&&f.trim()))&&(!((d=l.trimCharsBeforeMatching)!=null&&d.length)||f!==void 0&&!l.trimCharsBeforeMatching.includes(f))){r=g;break}}else if(e.startsWith("matchRight"))for(let g=i;g<n.length;g++){let f=n[g];if((!l.trimBeforeMatching||l.trimBeforeMatching&&f.trim())&&(!((y=l.trimCharsBeforeMatching)!=null&&y.length)||!l.trimCharsBeforeMatching.includes(f))){r=g;break}}if(r===void 0)return!1;let $=n[r],u=r+1,p="";return u&&u>0&&(p=n.slice(0,u)),e[5]==="L"||r&&r>0&&(p=n.slice(r)),l.cb($,p,r)}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,r=h.length;c<r;c++){s=typeof h[c]=="function";let i=h[c],$,u,p="",g=t;e==="matchRight"?g+=1:e==="matchLeft"&&(g-=1);let f=re(n,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=n.slice(0,f):p=n.slice(u)),u<0&&(u=void 0),n[u]&&($=n[u]),Number.isInteger(f)&&(!l.cb||l.cb($,p,u)))return i}return!1}function ne(e,n,t,o){return k("matchLeftIncl",e,n,t,o)}function oe(e,n,t,o){return k("matchLeft",e,n,t,o)}function se(e,n,t,o){return k("matchRightIncl",e,n,t,o)}function ie(e,n,t,o){return k("matchRight",e,n,t,o)}return G(le);})();
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.0
14
+ * @version 5.2.1
15
15
  * @author Roy Revelt
16
16
  * @license MIT
17
17
  * {@link https://codsen.com/os/arrayiffy-if-string/}
@@ -19,7 +19,7 @@
19
19
  /**
20
20
  * @name codsen-utils
21
21
  * @fileoverview Various utility functions
22
- * @version 1.8.0
22
+ * @version 1.9.0
23
23
  * @author Roy Revelt
24
24
  * @license MIT
25
25
  * {@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.0",
3
+ "version": "9.2.2",
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.0",
68
- "codsen-utils": "^1.8.0"
67
+ "arrayiffy-if-string": "^5.2.1",
68
+ "codsen-utils": "^1.9.0"
69
69
  },
70
70
  "engines": {
71
71
  "node": ">=18.20.8"