string-match-left-right 9.1.3 → 9.2.1
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 +16 -2
- package/LICENSE +1 -1
- package/README.md +4 -21
- package/dist/string-match-left-right.esm.js +5 -5
- package/dist/string-match-left-right.umd.js +4 -4
- package/package.json +22 -24
package/CHANGELOG.md
CHANGED
|
@@ -3,11 +3,25 @@
|
|
|
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.
|
|
6
|
+
## 9.2.0 (2026-08-19)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- 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))
|
|
12
|
+
- retire direct publish aliases ([f98e31e](https://github.com/codsen/codsen/commit/f98e31eb89bc185471225664e610b55f34fbf648))
|
|
13
|
+
- standardise matcher validation errs ([6f8f858](https://github.com/codsen/codsen/commit/6f8f858104ecd066189d287901f80c94b581d08b))
|
|
14
|
+
- stop case-insensitive matching crashing on a null index ([5682575](https://github.com/codsen/codsen/commit/56825755acdcb8c9f2be089bf13cb24ba032e950))
|
|
7
15
|
|
|
8
16
|
### Features
|
|
9
17
|
|
|
10
|
-
-
|
|
18
|
+
- add codsen-glob and migrate glob consumers ([5595a2b](https://github.com/codsen/codsen/commit/5595a2b267eaa6cb60072d037aef00b7a28edd42))
|
|
19
|
+
- refresh the tooling and generate with the latest dependencies ([781f802](https://github.com/codsen/codsen/commit/781f802911066a82a4533b0e5a3fcbd742d0dd83))
|
|
20
|
+
|
|
21
|
+
### Reverts
|
|
22
|
+
|
|
23
|
+
- Revert "Merge pull request #128 from codsen/release/npm-32198404552-1" ([5baeeaa](https://github.com/codsen/codsen/commit/5baeeaaa677b86f1eaa6396cadf3aea32b06416e)), closes [#128](https://github.com/codsen/codsen/issues/128)
|
|
24
|
+
- Revert "Merge pull request #127 from codsen/release/npm-32194020886-1" ([5f1e94d](https://github.com/codsen/codsen/commit/5f1e94deef910ce735266b16aeee08a76de7a862)), closes [#127](https://github.com/codsen/codsen/issues/127)
|
|
11
25
|
|
|
12
26
|
## 9.0.19 (2024-03-30)
|
|
13
27
|
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright © 2010-
|
|
3
|
+
Copyright © 2010-2026 Roy Revelt and other contributors
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
6
|
a copy of this software and associated documentation files (the
|
package/README.md
CHANGED
|
@@ -32,31 +32,14 @@ npm i string-match-left-right
|
|
|
32
32
|
## Quick Take
|
|
33
33
|
|
|
34
34
|
```js
|
|
35
|
-
import { strict as assert } from "assert";
|
|
35
|
+
import { strict as assert } from "node:assert";
|
|
36
36
|
|
|
37
|
-
import {
|
|
38
|
-
matchLeftIncl,
|
|
39
|
-
matchRightIncl,
|
|
40
|
-
matchLeft,
|
|
41
|
-
matchRight,
|
|
42
|
-
} from "string-match-left-right";
|
|
37
|
+
import { matchRight } from "string-match-left-right";
|
|
43
38
|
|
|
44
|
-
// 3rd character is "d" because indexes start from zero.
|
|
45
|
-
// We're checking the string to the left of it, "bcd", inclusive of current character ("d").
|
|
46
|
-
// This means, "bcd" has to end with existing character and the other chars to the left
|
|
47
|
-
// must match exactly:
|
|
48
|
-
assert.equal(matchLeftIncl("abcdefghi", 3, ["bcd"]), "bcd");
|
|
49
|
-
|
|
50
|
-
// neither "ab" nor "zz" are to the left of 3rd index, "d":
|
|
51
|
-
assert.equal(matchLeft("abcdefghi", 3, ["ab", "zz"]), false);
|
|
52
|
-
|
|
53
|
-
// "def" is to the right of 3rd index (including it), "d":
|
|
54
|
-
assert.equal(matchRightIncl("abcdefghi", 3, ["def", "zzz"]), "def");
|
|
55
|
-
|
|
56
|
-
// One of values, "ef" is exactly to the right of 3rd index, "d":
|
|
57
39
|
assert.equal(matchRight("abcdefghi", 3, ["ef", "zz"]), "ef");
|
|
58
40
|
```
|
|
59
41
|
|
|
42
|
+
|
|
60
43
|
## Documentation
|
|
61
44
|
|
|
62
45
|
Please [visit codsen.com](https://codsen.com/os/string-match-left-right/) for a full description of the API. If you’re looking for the **Changelog**, it’s [here](https://github.com/codsen/codsen/blob/main/packages/string-match-left-right/CHANGELOG.md).
|
|
@@ -69,6 +52,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
|
|
|
69
52
|
|
|
70
53
|
MIT License
|
|
71
54
|
|
|
72
|
-
Copyright © 2010-
|
|
55
|
+
Copyright © 2010-2026 Roy Revelt and other contributors
|
|
73
56
|
|
|
74
57
|
<p align="center"><img src="https://codsen.com/images/png-codsen-ok.png" width="98" alt="ok" align="center"> <img src="https://codsen.com/images/png-codsen-1.png" width="148" alt="codsen" align="center"> <img src="https://codsen.com/images/png-codsen-star-small.png" width="32" alt="star" align="center"></p>
|
|
@@ -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.1
|
|
4
|
+
* @version 9.2.1
|
|
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{
|
|
11
|
-
${
|
|
12
|
-
${
|
|
13
|
-
${
|
|
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};
|
|
@@ -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.1
|
|
4
|
+
* @version 9.2.1
|
|
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
|
|
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);})();
|
|
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.1
|
|
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.
|
|
22
|
+
* @version 1.8.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.1
|
|
3
|
+
"version": "9.2.1",
|
|
4
4
|
"description": "Match substrings on the left or right of a given index, ignoring whitespace",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"left",
|
|
@@ -32,45 +32,43 @@
|
|
|
32
32
|
},
|
|
33
33
|
"types": "types/index.d.ts",
|
|
34
34
|
"scripts": {
|
|
35
|
-
"build": "node
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"dev": "DEV=true node '../../ops/scripts/esbuild.js' && npm run dts",
|
|
35
|
+
"build": "node ../../ops/scripts/esbuild.js && npm run dts",
|
|
36
|
+
"coverage": "c8 uvu test",
|
|
37
|
+
"dev": "node ../../ops/scripts/esbuild.js --dev && npm run dts",
|
|
39
38
|
"devtest": "c8 npm run unit && npm run examples && npm run lint",
|
|
40
|
-
"dts": "rollup -c &&
|
|
39
|
+
"dts": "rollup -c && biome format --write --config-path=../../biome.json --vcs-enabled=false --use-editorconfig=false types/index.d.ts",
|
|
41
40
|
"examples": "node '../../ops/scripts/run-examples.js'",
|
|
42
|
-
"lect": "node '../../ops/lect/lect.js'
|
|
43
|
-
"
|
|
44
|
-
"lint": "
|
|
41
|
+
"lect": "node '../../ops/lect/lect.js'",
|
|
42
|
+
"lect:check": "node '../../ops/lect/lect.js' --check",
|
|
43
|
+
"lint": "biome lint --error-on-warnings . && npm run typecheck",
|
|
44
|
+
"lint:fix": "biome lint --write --error-on-warnings . && npm run typecheck",
|
|
45
45
|
"perf": "node perf/check.js",
|
|
46
46
|
"prep": "echo 'ready'",
|
|
47
|
-
"prettier": "
|
|
48
|
-
"prettier:format": "
|
|
49
|
-
"pretest": "npm run lect && npm run build",
|
|
47
|
+
"prettier": "biome format",
|
|
48
|
+
"prettier:format": "biome format --write .",
|
|
49
|
+
"pretest": "npm run lect:check && npm run build",
|
|
50
50
|
"test": "npm run devtest",
|
|
51
|
+
"typecheck": "tsc --noEmit --pretty false --project tsconfig.json",
|
|
51
52
|
"unit": "uvu test"
|
|
52
53
|
},
|
|
53
|
-
"engines": {
|
|
54
|
-
"node": ">=14.18.0"
|
|
55
|
-
},
|
|
56
54
|
"c8": {
|
|
55
|
+
"all": true,
|
|
57
56
|
"check-coverage": true,
|
|
58
|
-
"exclude": [
|
|
59
|
-
|
|
60
|
-
],
|
|
57
|
+
"exclude": ["**/test/**/*.*"],
|
|
58
|
+
"include": ["dist/*.esm.js"],
|
|
61
59
|
"lines": 100
|
|
62
60
|
},
|
|
63
61
|
"lect": {
|
|
64
62
|
"licence": {
|
|
65
|
-
"extras": [
|
|
66
|
-
""
|
|
67
|
-
]
|
|
63
|
+
"extras": [""]
|
|
68
64
|
}
|
|
69
65
|
},
|
|
70
66
|
"dependencies": {
|
|
71
|
-
"arrayiffy-if-string": "^5.1
|
|
72
|
-
"codsen-utils": "^1.
|
|
73
|
-
|
|
67
|
+
"arrayiffy-if-string": "^5.2.1",
|
|
68
|
+
"codsen-utils": "^1.8.0"
|
|
69
|
+
},
|
|
70
|
+
"engines": {
|
|
71
|
+
"node": ">=18.20.8"
|
|
74
72
|
},
|
|
75
73
|
"publishConfig": {
|
|
76
74
|
"registry": "https://registry.npmjs.org/"
|