string-match-left-right 9.0.10 → 9.0.12

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
@@ -48,13 +48,13 @@ import {
48
48
  assert.equal(matchLeftIncl("abcdefghi", 3, ["bcd"]), "bcd");
49
49
 
50
50
  // neither "ab" nor "zz" are to the left of 3rd index, "d":
51
- assert.equal(matchLeft("abcdefghi", 3, ["ab", `zz`]), false);
51
+ assert.equal(matchLeft("abcdefghi", 3, ["ab", "zz"]), false);
52
52
 
53
53
  // "def" is to the right of 3rd index (including it), "d":
54
- assert.equal(matchRightIncl("abcdefghi", 3, ["def", `zzz`]), "def");
54
+ assert.equal(matchRightIncl("abcdefghi", 3, ["def", "zzz"]), "def");
55
55
 
56
56
  // One of values, "ef" is exactly to the right of 3rd index, "d":
57
- assert.equal(matchRight("abcdefghi", 3, ["ef", `zz`]), "ef");
57
+ assert.equal(matchRight("abcdefghi", 3, ["ef", "zz"]), "ef");
58
58
  ```
59
59
 
60
60
  ## Documentation
@@ -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.0.10
4
+ * @version 9.0.12
5
5
  * @author Roy Revelt, Codsen Ltd
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{isPlainObject as R,isStr as d,hasOwnProp as k}from"codsen-utils";var O="9.0.10";var F=O,w={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},L=t=>t+1;function A(t,s,n,a,u=!1,o=L){let l=typeof n=="function"?n():n;if(+s<0&&u&&l==="EOL")return l;let r={...w,...a};if(s>=t.length&&!u)return!1;let c=u?1:n.length,E=0,h=!1,i=!1,g=!1,b=r.maxMismatches,e=s,m=!1,f=!1,$=!1;function p(){return E===1&&b<r.maxMismatches-1}for(;t[e];){let T=o(e);if(r.trimBeforeMatching&&t[e].trim()===""){if(!t[T]&&u&&n==="EOL")return!0;e=o(e);continue}if(r&&!r.i&&r.trimCharsBeforeMatching&&r.trimCharsBeforeMatching.includes(t[e])||r?.i&&r.trimCharsBeforeMatching&&r.trimCharsBeforeMatching.map(D=>D.toLowerCase()).includes(t[e].toLowerCase())){if(u&&n==="EOL"&&!t[T])return!0;e=o(e);continue}let y=T>e?n[n.length-c]:n[c-1];if(!r.i&&t[e]===y||r.i&&t[e].toLowerCase()===y.toLowerCase()){if(m||(m=!0),g||(g=!0),c===n.length){if(f=!0,b!==r.maxMismatches)return!1}else c===1&&($=!0);if(c-=1,E++,p())return!1;if(!c)return E!==n.length||b===r.maxMismatches||!h?e:!1}else if(!h&&!E&&(h=!0),r.maxMismatches&&b&&e){b-=1;for(let D=0;D<=b;D++){let C=T>e?n[n.length-c+1+D]:n[c-2-D],M=t[o(e)];if(C&&(!r.i&&t[e]===C||r.i&&t[e].toLowerCase()===C.toLowerCase())&&(!r.firstMustMatch||c!==n.length)){if(E++,p())return!1;c-=2,m=!0;break}else if(M&&C&&(!r.i&&M===C||r.i&&M.toLowerCase()===C.toLowerCase())&&(!r.firstMustMatch||c!==n.length)){if(!E&&!r.hungry)return!1;c-=1,m=!0;break}else if(C===void 0&&b>=0&&m&&(!r.firstMustMatch||f)&&(!r.lastMustMatch||$))return e}m||(i=e)}else return e===0&&c===1&&!r.lastMustMatch&&g?0:!1;if(i!==!1&&i!==e&&(i=!1),c<1)return e;e=o(e)}if(c>0)return u&&l==="EOL"?!0:r&&r.maxMismatches>=c&&g?i||0:!1}function V(t,s,n,a,u){if(R(u)&&k(u,"trimBeforeMatching")&&u&&typeof u.trimBeforeMatching!="boolean")throw new Error(`string-match-left-right/${t}(): [THROW_ID_09] opts.trimBeforeMatching should be boolean!${Array.isArray(u.trimBeforeMatching)?" Did you mean to use opts.trimCharsBeforeMatching?":""}`);let o={...w,...u};if(typeof o.trimCharsBeforeMatching=="string"&&(o.trimCharsBeforeMatching=N(o.trimCharsBeforeMatching)),o.trimCharsBeforeMatching=o.trimCharsBeforeMatching.map(h=>d(h)?h:String(h)),!d(s)||!s.length)return!1;if(!Number.isInteger(n)||n<0)throw new Error(`string-match-left-right/${t}(): [THROW_ID_03] 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{isPlainObject as R,isStr as d,hasOwnProp as k}from"codsen-utils";var O="9.0.12";var F=O,w={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},L=t=>t+1;function A(t,s,n,a,u=!1,o=L){let l=typeof n=="function"?n():n;if(+s<0&&u&&l==="EOL")return l;let r={...w,...a};if(s>=t.length&&!u)return!1;let c=u?1:n.length,E=0,h=!1,i=!1,g=!1,b=r.maxMismatches,e=s,m=!1,f=!1,$=!1;function p(){return E===1&&b<r.maxMismatches-1}for(;t[e];){let T=o(e);if(r.trimBeforeMatching&&t[e].trim()===""){if(!t[T]&&u&&n==="EOL")return!0;e=o(e);continue}if(r&&!r.i&&r.trimCharsBeforeMatching&&r.trimCharsBeforeMatching.includes(t[e])||r?.i&&r.trimCharsBeforeMatching&&r.trimCharsBeforeMatching.map(D=>D.toLowerCase()).includes(t[e].toLowerCase())){if(u&&n==="EOL"&&!t[T])return!0;e=o(e);continue}let y=T>e?n[n.length-c]:n[c-1];if(!r.i&&t[e]===y||r.i&&t[e].toLowerCase()===y.toLowerCase()){if(m||(m=!0),g||(g=!0),c===n.length){if(f=!0,b!==r.maxMismatches)return!1}else c===1&&($=!0);if(c-=1,E++,p())return!1;if(!c)return E!==n.length||b===r.maxMismatches||!h?e:!1}else if(!h&&!E&&(h=!0),r.maxMismatches&&b&&e){b-=1;for(let D=0;D<=b;D++){let C=T>e?n[n.length-c+1+D]:n[c-2-D],M=t[o(e)];if(C&&(!r.i&&t[e]===C||r.i&&t[e].toLowerCase()===C.toLowerCase())&&(!r.firstMustMatch||c!==n.length)){if(E++,p())return!1;c-=2,m=!0;break}else if(M&&C&&(!r.i&&M===C||r.i&&M.toLowerCase()===C.toLowerCase())&&(!r.firstMustMatch||c!==n.length)){if(!E&&!r.hungry)return!1;c-=1,m=!0;break}else if(C===void 0&&b>=0&&m&&(!r.firstMustMatch||f)&&(!r.lastMustMatch||$))return e}m||(i=e)}else return e===0&&c===1&&!r.lastMustMatch&&g?0:!1;if(i!==!1&&i!==e&&(i=!1),c<1)return e;e=o(e)}if(c>0)return u&&l==="EOL"?!0:r&&r.maxMismatches>=c&&g?i||0:!1}function V(t,s,n,a,u){if(R(u)&&k(u,"trimBeforeMatching")&&u&&typeof u.trimBeforeMatching!="boolean")throw new Error(`string-match-left-right/${t}(): [THROW_ID_09] opts.trimBeforeMatching should be boolean!${Array.isArray(u.trimBeforeMatching)?" Did you mean to use opts.trimCharsBeforeMatching?":""}`);let o={...w,...u};if(typeof o.trimCharsBeforeMatching=="string"&&(o.trimCharsBeforeMatching=N(o.trimCharsBeforeMatching)),o.trimCharsBeforeMatching=o.trimCharsBeforeMatching.map(h=>d(h)?h:String(h)),!d(s)||!s.length)return!1;if(!Number.isInteger(n)||n<0)throw new Error(`string-match-left-right/${t}(): [THROW_ID_03] the second argument should be a natural number. Currently it's of a type: ${typeof n}, equal to:
11
11
  ${JSON.stringify(n,null,4)}`);let l,r;if(d(a))l=[a];else if(Array.isArray(a))l=a;else if(!a)l=a;else if(typeof a=="function")l=[],l.push(a);else throw new Error(`string-match-left-right/${t}(): [THROW_ID_05] the third argument, whatToMatch, is neither string nor array of strings! It's ${typeof a}, equal to:
12
12
  ${JSON.stringify(a,null,4)}`);if(u&&!R(u))throw new Error(`string-match-left-right/${t}(): [THROW_ID_06] the fourth argument, options object, should be a plain object. Currently it's of a type "${typeof u}", and equal to:
13
13
  ${JSON.stringify(u,null,4)}`);let c=0,E="";if(o?.trimCharsBeforeMatching&&o.trimCharsBeforeMatching.some((h,i)=>h.length>1?(c=i,E=h,!0):!1))throw new Error(`string-match-left-right/${t}(): [THROW_ID_07] 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(!l||!Array.isArray(l)||Array.isArray(l)&&!l.length||Array.isArray(l)&&l.length===1&&d(l[0])&&!l[0].trim()){if(typeof o.cb=="function"){let i,g=n;if((t==="matchLeftIncl"||t==="matchRight")&&(g+=1),t[5]==="L")for(let f=g;f--;){let $=s[f];if((!o.trimBeforeMatching||o.trimBeforeMatching&&$!==void 0&&$.trim())&&(!o.trimCharsBeforeMatching?.length||$!==void 0&&!o.trimCharsBeforeMatching.includes($))){i=f;break}}else if(t.startsWith("matchRight"))for(let f=g;f<s.length;f++){let $=s[f];if((!o.trimBeforeMatching||o.trimBeforeMatching&&$.trim())&&(!o.trimCharsBeforeMatching?.length||!o.trimCharsBeforeMatching.includes($))){i=f;break}}if(i===void 0)return!1;let b=s[i],e=i+1,m="";return e&&e>0&&(m=s.slice(0,e)),t[5]==="L"||i&&i>0&&(m=s.slice(i)),o.cb(b,m,i)}let h="";throw u||(h=" More so, the whole options object, the fourth input argument, is missing!"),new Error(`string-match-left-right/${t}(): [THROW_ID_08] 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,i=l.length;h<i;h++){r=typeof l[h]=="function";let g=l[h],b,e,m="",f=n;t==="matchRight"?f+=1:t==="matchLeft"&&(f-=1);let $=A(s,f,g,o,r,p=>t[5]==="L"?p-1:p+1);if($&&r&&typeof g=="function"&&g()==="EOL")return g()&&(!o.cb||o.cb(b,m,e))?g():!1;if(Number.isInteger($)&&(e=t.startsWith("matchLeft")?$-1:$+1,t[5]==="L"?m=s.slice(0,$):m=s.slice(e)),e<0&&(e=void 0),s[e]&&(b=s[e]),Number.isInteger($)&&(!o.cb||o.cb(b,m,e)))return g}return!1}function H(t,s,n,a){return V("matchLeftIncl",t,s,n,a)}function P(t,s,n,a){return V("matchLeft",t,s,n,a)}function j(t,s,n,a){return V("matchRightIncl",t,s,n,a)}function U(t,s,n,a){return V("matchRight",t,s,n,a)}export{L as defaultGetNextIdx,w as defaults,P as matchLeft,H as matchLeftIncl,U as matchRight,j as matchRightIncl,F as version};
@@ -1,16 +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.0.10
4
+ * @version 9.0.12
5
5
  * @author Roy Revelt, Codsen Ltd
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 V=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames,N=Object.getOwnPropertySymbols;var L=Object.prototype.hasOwnProperty,v=Object.prototype.propertyIsEnumerable;var k=(e,t,r)=>t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,M=(e,t)=>{for(var r in t||(t={}))L.call(t,r)&&k(e,r,t[r]);if(N)for(var r of N(t))v.call(t,r)&&k(e,r,t[r]);return e};var j=(e,t)=>{for(var r in t)V(e,r,{get:t[r],enumerable:!0})},H=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of P(t))!L.call(e,a)&&a!==r&&V(e,a,{get:()=>t[a],enumerable:!(i=F(t,a))||i.enumerable});return e};var U=e=>H(V({},"__esModule",{value:!0}),e);var Z={};j(Z,{defaultGetNextIdx:()=>J,defaults:()=>A,matchLeft:()=>K,matchLeftIncl:()=>Q,matchRight:()=>G,matchRightIncl:()=>Y,version:()=>_});function B(e){return typeof e!="string"?e:e.length?[e]:[]}function O(e){if(e==null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null?!1:!(Symbol.iterator in e)&&!(Symbol.toStringTag in e)}function y(e){return typeof e=="string"}function x(e,t){return O(e)&&y(t)&&Object.prototype.hasOwnProperty.call(e,t)}var I="9.0.10";var _=I,A={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},J=e=>e+1;function q(e,t,r,i,a=!1,s=J){let u=typeof r=="function"?r():r;if(+t<0&&a&&u==="EOL")return u;let o=M(M({},A),i);if(t>=e.length&&!a)return!1;let c=a?1:r.length,C=0,D=!1,E=!1,h=!1,l=o.maxMismatches,n=t,f=!1,$=!1,b=!1;function m(){return C===1&&l<o.maxMismatches-1}for(;e[n];){let p=s(n);if(o.trimBeforeMatching&&e[n].trim()===""){if(!e[p]&&a&&r==="EOL")return!0;n=s(n);continue}if(o&&!o.i&&o.trimCharsBeforeMatching&&o.trimCharsBeforeMatching.includes(e[n])||o!=null&&o.i&&o.trimCharsBeforeMatching&&o.trimCharsBeforeMatching.map(T=>T.toLowerCase()).includes(e[n].toLowerCase())){if(a&&r==="EOL"&&!e[p])return!0;n=s(n);continue}let R=p>n?r[r.length-c]:r[c-1];if(!o.i&&e[n]===R||o.i&&e[n].toLowerCase()===R.toLowerCase()){if(f||(f=!0),h||(h=!0),c===r.length){if($=!0,l!==o.maxMismatches)return!1}else c===1&&(b=!0);if(c-=1,C++,m())return!1;if(!c)return C!==r.length||l===o.maxMismatches||!D?n:!1}else if(!D&&!C&&(D=!0),o.maxMismatches&&l&&n){l-=1;for(let T=0;T<=l;T++){let d=p>n?r[r.length-c+1+T]:r[c-2-T],S=e[s(n)];if(d&&(!o.i&&e[n]===d||o.i&&e[n].toLowerCase()===d.toLowerCase())&&(!o.firstMustMatch||c!==r.length)){if(C++,m())return!1;c-=2,f=!0;break}else if(S&&d&&(!o.i&&S===d||o.i&&S.toLowerCase()===d.toLowerCase())&&(!o.firstMustMatch||c!==r.length)){if(!C&&!o.hungry)return!1;c-=1,f=!0;break}else if(d===void 0&&l>=0&&f&&(!o.firstMustMatch||$)&&(!o.lastMustMatch||b))return n}f||(E=n)}else return n===0&&c===1&&!o.lastMustMatch&&h?0:!1;if(E!==!1&&E!==n&&(E=!1),c<1)return n;n=s(n)}if(c>0)return a&&u==="EOL"?!0:o&&o.maxMismatches>=c&&h?E||0:!1}function w(e,t,r,i,a){var D,E;if(O(a)&&x(a,"trimBeforeMatching")&&a&&typeof a.trimBeforeMatching!="boolean")throw new Error(`string-match-left-right/${e}(): [THROW_ID_09] opts.trimBeforeMatching should be boolean!${Array.isArray(a.trimBeforeMatching)?" Did you mean to use opts.trimCharsBeforeMatching?":""}`);let s=M(M({},A),a);if(typeof s.trimCharsBeforeMatching=="string"&&(s.trimCharsBeforeMatching=B(s.trimCharsBeforeMatching)),s.trimCharsBeforeMatching=s.trimCharsBeforeMatching.map(h=>y(h)?h:String(h)),!y(t)||!t.length)return!1;if(!Number.isInteger(r)||r<0)throw new Error(`string-match-left-right/${e}(): [THROW_ID_03] the second argument should be a natural number. Currently it's of a type: ${typeof r}, equal to:
10
+ "use strict";var stringMatchLeftRight=(()=>{var V=Object.defineProperty;var F=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames,N=Object.getOwnPropertySymbols;var k=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable;var L=(e,t,r)=>t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,M=(e,t)=>{for(var r in t||(t={}))k.call(t,r)&&L(e,r,t[r]);if(N)for(var r of N(t))P.call(t,r)&&L(e,r,t[r]);return e};var j=(e,t)=>{for(var r in t)V(e,r,{get:t[r],enumerable:!0})},H=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of v(t))!k.call(e,a)&&a!==r&&V(e,a,{get:()=>t[a],enumerable:!(i=F(t,a))||i.enumerable});return e};var U=e=>H(V({},"__esModule",{value:!0}),e);var Z={};j(Z,{defaultGetNextIdx:()=>J,defaults:()=>A,matchLeft:()=>Y,matchLeftIncl:()=>Q,matchRight:()=>G,matchRightIncl:()=>K,version:()=>_});function B(e){return typeof e!="string"?e:e.length?[e]:[]}function O(e){if(e==null||typeof e!="object")return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null?!1:!(Symbol.iterator in e)&&!(Symbol.toStringTag in e)}function y(e){return typeof e=="string"}function x(e,t){return O(e)&&y(t)&&t in e}var I="9.0.12";var _=I,A={cb:void 0,i:!1,trimBeforeMatching:!1,trimCharsBeforeMatching:[],maxMismatches:0,firstMustMatch:!1,lastMustMatch:!1,hungry:!1},J=e=>e+1;function q(e,t,r,i,a=!1,s=J){let u=typeof r=="function"?r():r;if(+t<0&&a&&u==="EOL")return u;let o=M(M({},A),i);if(t>=e.length&&!a)return!1;let c=a?1:r.length,C=0,D=!1,E=!1,h=!1,l=o.maxMismatches,n=t,f=!1,$=!1,b=!1;function m(){return C===1&&l<o.maxMismatches-1}for(;e[n];){let p=s(n);if(o.trimBeforeMatching&&e[n].trim()===""){if(!e[p]&&a&&r==="EOL")return!0;n=s(n);continue}if(o&&!o.i&&o.trimCharsBeforeMatching&&o.trimCharsBeforeMatching.includes(e[n])||o!=null&&o.i&&o.trimCharsBeforeMatching&&o.trimCharsBeforeMatching.map(T=>T.toLowerCase()).includes(e[n].toLowerCase())){if(a&&r==="EOL"&&!e[p])return!0;n=s(n);continue}let R=p>n?r[r.length-c]:r[c-1];if(!o.i&&e[n]===R||o.i&&e[n].toLowerCase()===R.toLowerCase()){if(f||(f=!0),h||(h=!0),c===r.length){if($=!0,l!==o.maxMismatches)return!1}else c===1&&(b=!0);if(c-=1,C++,m())return!1;if(!c)return C!==r.length||l===o.maxMismatches||!D?n:!1}else if(!D&&!C&&(D=!0),o.maxMismatches&&l&&n){l-=1;for(let T=0;T<=l;T++){let d=p>n?r[r.length-c+1+T]:r[c-2-T],S=e[s(n)];if(d&&(!o.i&&e[n]===d||o.i&&e[n].toLowerCase()===d.toLowerCase())&&(!o.firstMustMatch||c!==r.length)){if(C++,m())return!1;c-=2,f=!0;break}else if(S&&d&&(!o.i&&S===d||o.i&&S.toLowerCase()===d.toLowerCase())&&(!o.firstMustMatch||c!==r.length)){if(!C&&!o.hungry)return!1;c-=1,f=!0;break}else if(d===void 0&&l>=0&&f&&(!o.firstMustMatch||$)&&(!o.lastMustMatch||b))return n}f||(E=n)}else return n===0&&c===1&&!o.lastMustMatch&&h?0:!1;if(E!==!1&&E!==n&&(E=!1),c<1)return n;n=s(n)}if(c>0)return a&&u==="EOL"?!0:o&&o.maxMismatches>=c&&h?E||0:!1}function w(e,t,r,i,a){var D,E;if(O(a)&&x(a,"trimBeforeMatching")&&a&&typeof a.trimBeforeMatching!="boolean")throw new Error(`string-match-left-right/${e}(): [THROW_ID_09] opts.trimBeforeMatching should be boolean!${Array.isArray(a.trimBeforeMatching)?" Did you mean to use opts.trimCharsBeforeMatching?":""}`);let s=M(M({},A),a);if(typeof s.trimCharsBeforeMatching=="string"&&(s.trimCharsBeforeMatching=B(s.trimCharsBeforeMatching)),s.trimCharsBeforeMatching=s.trimCharsBeforeMatching.map(h=>y(h)?h:String(h)),!y(t)||!t.length)return!1;if(!Number.isInteger(r)||r<0)throw new Error(`string-match-left-right/${e}(): [THROW_ID_03] the second argument should be a natural number. Currently it's of a type: ${typeof r}, equal to:
11
11
  ${JSON.stringify(r,null,4)}`);let u,o;if(y(i))u=[i];else if(Array.isArray(i))u=i;else if(!i)u=i;else if(typeof i=="function")u=[],u.push(i);else throw new Error(`string-match-left-right/${e}(): [THROW_ID_05] the third argument, whatToMatch, is neither string nor array of strings! It's ${typeof i}, equal to:
12
12
  ${JSON.stringify(i,null,4)}`);if(a&&!O(a))throw new Error(`string-match-left-right/${e}(): [THROW_ID_06] the fourth argument, options object, should be a plain object. Currently it's of a type "${typeof a}", and equal to:
13
- ${JSON.stringify(a,null,4)}`);let c=0,C="";if(s!=null&&s.trimCharsBeforeMatching&&s.trimCharsBeforeMatching.some((h,l)=>h.length>1?(c=l,C=h,!0):!1))throw new Error(`string-match-left-right/${e}(): [THROW_ID_07] 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, ${C.length} (equals to ${C}). Please split it into separate characters and put into array as separate elements.`);if(!u||!Array.isArray(u)||Array.isArray(u)&&!u.length||Array.isArray(u)&&u.length===1&&y(u[0])&&!u[0].trim()){if(typeof s.cb=="function"){let l,n=r;if((e==="matchLeftIncl"||e==="matchRight")&&(n+=1),e[5]==="L")for(let m=n;m--;){let g=t[m];if((!s.trimBeforeMatching||s.trimBeforeMatching&&g!==void 0&&g.trim())&&(!((D=s.trimCharsBeforeMatching)!=null&&D.length)||g!==void 0&&!s.trimCharsBeforeMatching.includes(g))){l=m;break}}else if(e.startsWith("matchRight"))for(let m=n;m<t.length;m++){let g=t[m];if((!s.trimBeforeMatching||s.trimBeforeMatching&&g.trim())&&(!((E=s.trimCharsBeforeMatching)!=null&&E.length)||!s.trimCharsBeforeMatching.includes(g))){l=m;break}}if(l===void 0)return!1;let f=t[l],$=l+1,b="";return $&&$>0&&(b=t.slice(0,$)),e[5]==="L"||l&&l>0&&(b=t.slice(l)),s.cb(f,b,l)}let h="";throw a||(h=" More so, the whole options object, the fourth input argument, is missing!"),new Error(`string-match-left-right/${e}(): [THROW_ID_08] 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=u.length;h<l;h++){o=typeof u[h]=="function";let n=u[h],f,$,b="",m=r;e==="matchRight"?m+=1:e==="matchLeft"&&(m-=1);let g=q(t,m,n,s,o,p=>e[5]==="L"?p-1:p+1);if(g&&o&&typeof n=="function"&&n()==="EOL")return n()&&(!s.cb||s.cb(f,b,$))?n():!1;if(Number.isInteger(g)&&($=e.startsWith("matchLeft")?g-1:g+1,e[5]==="L"?b=t.slice(0,g):b=t.slice($)),$<0&&($=void 0),t[$]&&(f=t[$]),Number.isInteger(g)&&(!s.cb||s.cb(f,b,$)))return n}return!1}function Q(e,t,r,i){return w("matchLeftIncl",e,t,r,i)}function K(e,t,r,i){return w("matchLeft",e,t,r,i)}function Y(e,t,r,i){return w("matchRightIncl",e,t,r,i)}function G(e,t,r,i){return w("matchRight",e,t,r,i)}return U(Z);})();
13
+ ${JSON.stringify(a,null,4)}`);let c=0,C="";if(s!=null&&s.trimCharsBeforeMatching&&s.trimCharsBeforeMatching.some((h,l)=>h.length>1?(c=l,C=h,!0):!1))throw new Error(`string-match-left-right/${e}(): [THROW_ID_07] 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, ${C.length} (equals to ${C}). Please split it into separate characters and put into array as separate elements.`);if(!u||!Array.isArray(u)||Array.isArray(u)&&!u.length||Array.isArray(u)&&u.length===1&&y(u[0])&&!u[0].trim()){if(typeof s.cb=="function"){let l,n=r;if((e==="matchLeftIncl"||e==="matchRight")&&(n+=1),e[5]==="L")for(let m=n;m--;){let g=t[m];if((!s.trimBeforeMatching||s.trimBeforeMatching&&g!==void 0&&g.trim())&&(!((D=s.trimCharsBeforeMatching)!=null&&D.length)||g!==void 0&&!s.trimCharsBeforeMatching.includes(g))){l=m;break}}else if(e.startsWith("matchRight"))for(let m=n;m<t.length;m++){let g=t[m];if((!s.trimBeforeMatching||s.trimBeforeMatching&&g.trim())&&(!((E=s.trimCharsBeforeMatching)!=null&&E.length)||!s.trimCharsBeforeMatching.includes(g))){l=m;break}}if(l===void 0)return!1;let f=t[l],$=l+1,b="";return $&&$>0&&(b=t.slice(0,$)),e[5]==="L"||l&&l>0&&(b=t.slice(l)),s.cb(f,b,l)}let h="";throw a||(h=" More so, the whole options object, the fourth input argument, is missing!"),new Error(`string-match-left-right/${e}(): [THROW_ID_08] 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=u.length;h<l;h++){o=typeof u[h]=="function";let n=u[h],f,$,b="",m=r;e==="matchRight"?m+=1:e==="matchLeft"&&(m-=1);let g=q(t,m,n,s,o,p=>e[5]==="L"?p-1:p+1);if(g&&o&&typeof n=="function"&&n()==="EOL")return n()&&(!s.cb||s.cb(f,b,$))?n():!1;if(Number.isInteger(g)&&($=e.startsWith("matchLeft")?g-1:g+1,e[5]==="L"?b=t.slice(0,g):b=t.slice($)),$<0&&($=void 0),t[$]&&(f=t[$]),Number.isInteger(g)&&(!s.cb||s.cb(f,b,$)))return n}return!1}function Q(e,t,r,i){return w("matchLeftIncl",e,t,r,i)}function Y(e,t,r,i){return w("matchLeft",e,t,r,i)}function K(e,t,r,i){return w("matchRightIncl",e,t,r,i)}function G(e,t,r,i){return w("matchRight",e,t,r,i)}return U(Z);})();
14
14
  /**
15
15
  * @name arrayiffy-if-string
16
16
  * @fileoverview Put non-empty strings into arrays, turn empty-ones into empty arrays. Bypass everything else.
@@ -22,7 +22,7 @@ ${JSON.stringify(a,null,4)}`);let c=0,C="";if(s!=null&&s.trimCharsBeforeMatching
22
22
  /**
23
23
  * @name codsen-utils
24
24
  * @fileoverview Various utility functions
25
- * @version 1.3.1
25
+ * @version 1.5.0
26
26
  * @author Roy Revelt, Codsen Ltd
27
27
  * @license MIT
28
28
  * {@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.0.10",
3
+ "version": "9.0.12",
4
4
  "description": "Match substrings on the left or right of a given index, ignoring whitespace",
5
5
  "keywords": [
6
6
  "left",
@@ -69,7 +69,7 @@
69
69
  },
70
70
  "dependencies": {
71
71
  "arrayiffy-if-string": "^5.0.5",
72
- "codsen-utils": "^1.3.1",
72
+ "codsen-utils": "^1.5.0",
73
73
  "string-character-is-astral-surrogate": "^3.0.7"
74
74
  }
75
75
  }