string-left-right 6.1.3 → 6.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 +22 -3
- package/LICENSE +1 -1
- package/README.md +7 -6
- package/dist/string-left-right.esm.js +11 -11
- package/dist/string-left-right.umd.js +3 -3
- package/package.json +21 -23
package/CHANGELOG.md
CHANGED
|
@@ -3,11 +3,30 @@
|
|
|
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
|
-
## 6.1
|
|
6
|
+
## 6.2.1 (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
|
+
|
|
12
|
+
## 6.2.0 (2026-08-19)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- resolve various review findings ([b60e9ee](https://github.com/codsen/codsen/commit/b60e9eeb499af94685cfb87b4970fe025be1fc10))
|
|
17
|
+
- retire direct publish aliases ([f98e31e](https://github.com/codsen/codsen/commit/f98e31eb89bc185471225664e610b55f34fbf648))
|
|
18
|
+
- stop case-insensitive matching crashing on a null index ([5682575](https://github.com/codsen/codsen/commit/56825755acdcb8c9f2be089bf13cb24ba032e950))
|
|
19
|
+
- validate chomp modes and avoid argument cloning ([577224a](https://github.com/codsen/codsen/commit/577224a0d2eb95673872d5e2a5780f0ee9751dc5))
|
|
7
20
|
|
|
8
21
|
### Features
|
|
9
22
|
|
|
10
|
-
-
|
|
23
|
+
- add codsen-glob and migrate glob consumers ([5595a2b](https://github.com/codsen/codsen/commit/5595a2b267eaa6cb60072d037aef00b7a28edd42))
|
|
24
|
+
- refresh the tooling and generate with the latest dependencies ([781f802](https://github.com/codsen/codsen/commit/781f802911066a82a4533b0e5a3fcbd742d0dd83))
|
|
25
|
+
|
|
26
|
+
### Reverts
|
|
27
|
+
|
|
28
|
+
- 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)
|
|
29
|
+
- 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
30
|
|
|
12
31
|
## 6.0.0 (2022-12-01)
|
|
13
32
|
|
|
@@ -112,7 +131,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
|
|
|
112
131
|
## 1.3.0 (2018-09-20)
|
|
113
132
|
|
|
114
133
|
- Improvements to cases when `opts.ifLeftSideIncludesThisThenCropTightly`/`opts.ifRightSideIncludesThisThenCropTightly` is an array
|
|
115
|
-
- Now we tend an edge case when `opts.addSingleSpaceToPreventAccidentalConcatenation` is surrounded by characters, whitelisted by `opts.ifLeftSideIncludesThisThenCropTightly` and `opts.ifRightSideIncludesThisThenCropTightly` (or just one of them, but then the other is a
|
|
134
|
+
- Now we tend an edge case when `opts.addSingleSpaceToPreventAccidentalConcatenation` is surrounded by characters, whitelisted by `opts.ifLeftSideIncludesThisThenCropTightly` and `opts.ifRightSideIncludesThisThenCropTightly` (or just one of them, but then the other is a falsy empty string). In that case, the compensation space is not added.
|
|
116
135
|
|
|
117
136
|
## 1.2.0 (2018-09-18)
|
|
118
137
|
|
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,16 +32,16 @@ npm i string-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
37
|
import {
|
|
38
|
-
left,
|
|
39
|
-
right,
|
|
40
|
-
leftSeq,
|
|
41
|
-
rightSeq,
|
|
42
38
|
chompLeft,
|
|
43
39
|
chompRight,
|
|
40
|
+
left,
|
|
41
|
+
leftSeq,
|
|
44
42
|
leftStopAtNewLines,
|
|
43
|
+
right,
|
|
44
|
+
rightSeq,
|
|
45
45
|
rightStopAtNewLines,
|
|
46
46
|
} from "string-left-right";
|
|
47
47
|
|
|
@@ -59,6 +59,7 @@ assert.equal(
|
|
|
59
59
|
);
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
+
|
|
62
63
|
## Documentation
|
|
63
64
|
|
|
64
65
|
Please [visit codsen.com](https://codsen.com/os/string-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-left-right/CHANGELOG.md).
|
|
@@ -71,6 +72,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
|
|
|
71
72
|
|
|
72
73
|
MIT License
|
|
73
74
|
|
|
74
|
-
Copyright © 2010-
|
|
75
|
+
Copyright © 2010-2026 Roy Revelt and other contributors
|
|
75
76
|
|
|
76
77
|
<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,24 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name string-left-right
|
|
3
3
|
* @fileoverview Looks up the first non-whitespace character to the left/right of a given index
|
|
4
|
-
* @version 6.1
|
|
4
|
+
* @version 6.2.1
|
|
5
5
|
* @author Roy Revelt
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/string-left-right/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import{
|
|
11
|
-
\r`.includes(n[e+1])||o&&n[e+1]===
|
|
12
|
-
\r`.includes(n[e+2])||o&&n[e+2]===
|
|
13
|
-
\r`.includes(n[t])||o&&n[t]===
|
|
14
|
-
\r`.includes(n[~-e])||o&&n[~-e]===
|
|
15
|
-
\r`.includes(n[e-2])||o&&n[e-2]===
|
|
16
|
-
\r`.includes(n[t])||o&&n[t]===
|
|
10
|
+
import{isInt as R,isPlainObject as h,isStr as p}from"codsen-utils";var O="6.2.1";var C=O,a="\xA0";function y(n){return n===32||n>=9&&n<=13||n===160||n===5760||n>=8192&&n<=8202||n===8232||n===8233||n===8239||n===8287||n===12288||n===65279}function L(n){let e={value:n,hungry:!1,optional:!1};return(e.value.endsWith("?*")||e.value.endsWith("*?"))&&e.value.length>2?(e.value=e.value.slice(0,e.value.length-2),e.optional=!0,e.hungry=!0):e.value.endsWith("?")&&e.value.length>1?(e.value=e.value.slice(0,~-e.value.length),e.optional=!0):e.value.endsWith("*")&&e.value.length>1&&(e.value=e.value.slice(0,~-e.value.length),e.hungry=!0),e}function w({str:n,idx:e=0,stopAtNewlines:l=!1,stopAtRawNbsp:o=!1}){if(typeof n!="string"||!n.length||((!e||typeof e!="number")&&(e=0),!n[e+1]))return null;if(n[e+1]&&(n[e+1].trim()||l&&`
|
|
11
|
+
\r`.includes(n[e+1])||o&&n[e+1]===a))return e+1;if(n[e+2]&&(n[e+2].trim()||l&&`
|
|
12
|
+
\r`.includes(n[e+2])||o&&n[e+2]===a))return e+2;for(let t=e+3,m=n.length;t<m;t++)if(n[t].trim()||l&&`
|
|
13
|
+
\r`.includes(n[t])||o&&n[t]===a)return t;return null}function D(n,e=0){if(typeof n!="string"||!n.length)return null;(!e||typeof e!="number")&&(e=0);let l=n[e+1];if(!l)return null;if(!y(l.charCodeAt(0)))return e+1;if(l=n[e+2],l&&!y(l.charCodeAt(0)))return e+2;for(let o=e+3,t=n.length;o<t;o++)if(!y(n.charCodeAt(o)))return o;return null}function W(n,e){return w({str:n,idx:e,stopAtNewlines:!0,stopAtRawNbsp:!1})}function _(n,e){return w({str:n,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!0})}function N({str:n,idx:e,stopAtNewlines:l,stopAtRawNbsp:o}){if(typeof n!="string"||!n.length||((!e||typeof e!="number")&&(e=0),e<1))return null;if(n[~-e]&&(n[~-e].trim()||l&&`
|
|
14
|
+
\r`.includes(n[~-e])||o&&n[~-e]===a))return~-e;if(n[e-2]&&(n[e-2].trim()||l&&`
|
|
15
|
+
\r`.includes(n[e-2])||o&&n[e-2]===a))return e-2;for(let t=e;t--;)if(n[t]&&(n[t].trim()||l&&`
|
|
16
|
+
\r`.includes(n[t])||o&&n[t]===a))return t;return null}function V(n,e=0){return N({str:n,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!1})}function M(n,e){return N({str:n,idx:e,stopAtNewlines:!0,stopAtRawNbsp:!1})}function H(n,e){return N({str:n,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!0})}function T(n,e,l,o,t){if(typeof e!="string"||!e.length||(typeof l!="number"&&(l=0),n==="right"&&!e[l+1]||n==="left"&&!e[~-l]))return null;let m=l,u=[],f,i,s,r=0;for(;r<t.length;){if(!p(t[r])||!t[r].length){r+=1;continue}let{value:$,optional:v,hungry:I}=L(t[r]),g=n==="right"?D(e,m):V(e,m),d=e[g];if(d!==void 0&&(o.i&&d.toLowerCase()===$.toLowerCase()||!o.i&&d===$)){let J=n==="right"?D(e,g):V(e,g),S=!1;if(I){let E=e[J];S=E!==void 0&&(o.i&&E.toLowerCase()===$.toLowerCase()||!o.i&&E===$)}S?s=!0:r+=1,typeof g=="number"&&n==="right"&&g>m+1?u.push([m+1,g]):n==="left"&&typeof g=="number"&&g<~-m&&u.unshift([g+1,m]),m=g,n==="right"?(f===void 0&&(f=g),i=g):(i===void 0&&(i=g),f=g)}else if(v)r+=1;else if(s)r+=1,s=void 0;else return null}return f===void 0||i===void 0?null:{gaps:u,leftmostChar:f,rightmostChar:i}}var b={i:!1};function U(n,e,...l){if(!l?.length)throw new Error("string-left-right/leftSeq(): [THROW_ID_01] only two input arguments were passed! Did you intend to use left() method instead?");let o;return h(l[0])?o={...b,...l.shift()}:o=b,T("left",n,e,o,Array.from(l).reverse())}function F(n,e,...l){if(!l?.length)throw new Error("string-left-right/rightSeq(): [THROW_ID_02] only two input arguments were passed! Did you intend to use right() method instead?");let o;return h(l[0])?o={...b,...l.shift()}:o=b,T("right",n,e,o,l)}function c(n,e,l,o,t=[]){if(typeof e!="string"||!e.length||((!l||typeof l!="number")&&(l=0),n==="right"&&!e[l+1]||n==="left"&&+l==0))return null;let m=null,u=null;do m=n==="right"?F(e,typeof u=="number"?u:l,...t):U(e,typeof u=="number"?u:l,...t),m!==null&&(u=n==="right"?m.rightmostChar:m.leftmostChar);while(m);if(u!=null&&n==="right"&&(u+=1),u===null)return null;if(n==="right"){if(e[u]?.trim())return u;let i=D(e,u);if(!o||o.mode===0){if(i===u+1)return u;if(e.slice(u,i||e.length).trim()||e.slice(u,i||e.length).includes(`
|
|
17
17
|
`)||e.slice(u,i||e.length).includes("\r")){for(let s=u,r=e.length;s<r;s++)if(`
|
|
18
18
|
\r`.includes(e[s]))return s}else return i?~-i:e.length}else{if(o.mode===1)return u;if(o.mode===2){let s=e.slice(u);if(s.trim()||s.includes(`
|
|
19
|
-
`)||s.includes("\r")){for(let r=u
|
|
20
|
-
\r`.includes(e[r]))return r}return e.length}}return i||e.length}if(e[u]&&e[~-u]?.trim())return u;let f=
|
|
19
|
+
`)||s.includes("\r")){for(let r=u,$=e.length;r<$;r++)if(e[r].trim()||`
|
|
20
|
+
\r`.includes(e[r]))return r}return e.length}}return i||e.length}if(e[u]&&e[~-u]?.trim())return u;let f=V(e,u);if(!o||o.mode===0){if(f===u-2)return u;if(e.slice(0,u).trim()||e.slice(0,u).includes(`
|
|
21
21
|
`)||e.slice(0,u).includes("\r")){for(let i=u;i--;)if(`
|
|
22
22
|
\r`.includes(e[i])||e[i].trim())return i+1+(e[i].trim()?1:0)}return 0}if(o.mode===1)return u;if(o.mode===2){let i=e.slice(0,u);if(i.trim()||i.includes(`
|
|
23
23
|
`)||i.includes("\r")){for(let s=u;s--;)if(e[s].trim()||`
|
|
24
|
-
\r`.includes(e[s]))return s+1}return 0}return f!==null?f+1:0}function
|
|
24
|
+
\r`.includes(e[s]))return s+1}return 0}return f!==null?f+1:0}function P(n,e,...l){if(!l.length||l.length===1&&h(l[0]))return null;let o={mode:0};if(h(l[0])){let t={...o,...l[0]};if(!t.mode)t.mode=0;else if(p(t.mode)&&t.mode.length===1&&"0123".includes(t.mode))t.mode=+t.mode;else if(!R(t.mode)||t.mode<0||t.mode>3)throw new Error(`string-left-right/chompLeft(): [THROW_ID_03] the opts.mode is wrong! It should be 0, 1, 2 or 3. It was given as ${t.mode} (type ${typeof t.mode})`);return c("left",n,e,t,l.slice(1))}return p(l[0])?c("left",n,e,o,l):c("left",n,e,o,l.slice(1))}function B(n,e,...l){if(!l.length||l.length===1&&h(l[0]))return null;let o={mode:0};if(h(l[0])){let t={...o,...l[0]};if(!t.mode)t.mode=0;else if(p(t.mode)&&/^[0-3]$/.test(t.mode))t.mode=Number.parseInt(t.mode,10);else if(!R(t.mode)||t.mode<0||t.mode>3)throw new Error(`string-left-right/chompRight(): [THROW_ID_04] the opts.mode is wrong! It should be 0, 1, 2 or 3. It was given as ${t.mode} (type ${typeof t.mode})`);return c("right",n,e,t,l.slice(1))}return p(l[0])?c("right",n,e,o,l):c("right",n,e,o,l.slice(1))}export{P as chompLeft,B as chompRight,V as left,U as leftSeq,M as leftStopAtNewLines,H as leftStopAtRawNbsp,D as right,F as rightSeq,W as rightStopAtNewLines,_ as rightStopAtRawNbsp,C as version};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name string-left-right
|
|
3
3
|
* @fileoverview Looks up the first non-whitespace character to the left/right of a given index
|
|
4
|
-
* @version 6.1
|
|
4
|
+
* @version 6.2.1
|
|
5
5
|
* @author Roy Revelt
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/string-left-right/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
"use strict";var stringLeftRight=(()=>{var
|
|
10
|
+
"use strict";var stringLeftRight=(()=>{var y=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var B=Object.getOwnPropertyNames,T=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var C=(t,e,n)=>e in t?y(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,g=(t,e)=>{for(var n in e||(e={}))I.call(e,n)&&C(t,n,e[n]);if(T)for(var n of T(e))q.call(e,n)&&C(t,n,e[n]);return t};var x=(t,e)=>{for(var n in e)y(t,n,{get:e[n],enumerable:!0})},P=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let l of B(e))!I.call(t,l)&&l!==n&&y(t,l,{get:()=>e[l],enumerable:!(r=J(e,l))||r.enumerable});return t};var _=t=>P(y({},"__esModule",{value:!0}),t);var te={};x(te,{chompLeft:()=>X,chompRight:()=>ee,left:()=>v,leftSeq:()=>W,leftStopAtNewLines:()=>Z,leftStopAtRawNbsp:()=>Y,right:()=>E,rightSeq:()=>F,rightStopAtNewLines:()=>G,rightStopAtRawNbsp:()=>K,version:()=>Q});var re=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"]);function p(t){if(t==null||typeof t!="object")return!1;let e=Object.getPrototypeOf(t);return e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null?!1:!(Symbol.iterator in t)&&!(Symbol.toStringTag in t)}function d(t){return typeof t=="string"}function A(t){return Number.isSafeInteger(t)&&t>=0}var k,ie=(k=Object.getOwnPropertyDescriptor(RegExp.prototype,"source"))==null?void 0:k.get;var oe=Date.prototype.getTime;var j="6.2.1";var Q=j,b="\xA0";function R(t){return t===32||t>=9&&t<=13||t===160||t===5760||t>=8192&&t<=8202||t===8232||t===8233||t===8239||t===8287||t===12288||t===65279}function z(t){let e={value:t,hungry:!1,optional:!1};return(e.value.endsWith("?*")||e.value.endsWith("*?"))&&e.value.length>2?(e.value=e.value.slice(0,e.value.length-2),e.optional=!0,e.hungry=!0):e.value.endsWith("?")&&e.value.length>1?(e.value=e.value.slice(0,~-e.value.length),e.optional=!0):e.value.endsWith("*")&&e.value.length>1&&(e.value=e.value.slice(0,~-e.value.length),e.hungry=!0),e}function L({str:t,idx:e=0,stopAtNewlines:n=!1,stopAtRawNbsp:r=!1}){if(typeof t!="string"||!t.length||((!e||typeof e!="number")&&(e=0),!t[e+1]))return null;if(t[e+1]&&(t[e+1].trim()||n&&"\n\r".includes(t[e+1])||r&&t[e+1]===b))return e+1;if(t[e+2]&&(t[e+2].trim()||n&&"\n\r".includes(t[e+2])||r&&t[e+2]===b))return e+2;for(let l=e+3,s=t.length;l<s;l++)if(t[l].trim()||n&&"\n\r".includes(t[l])||r&&t[l]===b)return l;return null}function E(t,e=0){if(typeof t!="string"||!t.length)return null;(!e||typeof e!="number")&&(e=0);let n=t[e+1];if(!n)return null;if(!R(n.charCodeAt(0)))return e+1;if(n=t[e+2],n&&!R(n.charCodeAt(0)))return e+2;for(let r=e+3,l=t.length;r<l;r++)if(!R(t.charCodeAt(r)))return r;return null}function G(t,e){return L({str:t,idx:e,stopAtNewlines:!0,stopAtRawNbsp:!1})}function K(t,e){return L({str:t,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!0})}function V({str:t,idx:e,stopAtNewlines:n,stopAtRawNbsp:r}){if(typeof t!="string"||!t.length||((!e||typeof e!="number")&&(e=0),e<1))return null;if(t[~-e]&&(t[~-e].trim()||n&&"\n\r".includes(t[~-e])||r&&t[~-e]===b))return~-e;if(t[e-2]&&(t[e-2].trim()||n&&"\n\r".includes(t[e-2])||r&&t[e-2]===b))return e-2;for(let l=e;l--;)if(t[l]&&(t[l].trim()||n&&"\n\r".includes(t[l])||r&&t[l]===b))return l;return null}function v(t,e=0){return V({str:t,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!1})}function Z(t,e){return V({str:t,idx:e,stopAtNewlines:!0,stopAtRawNbsp:!1})}function Y(t,e){return V({str:t,idx:e,stopAtNewlines:!1,stopAtRawNbsp:!0})}function U(t,e,n,r,l){if(typeof e!="string"||!e.length||(typeof n!="number"&&(n=0),t==="right"&&!e[n+1]||t==="left"&&!e[~-n]))return null;let s=n,i=[],f,h,m,o=0;for(;o<l.length;){if(!d(l[o])||!l[o].length){o+=1;continue}let{value:u,optional:c,hungry:S}=z(l[o]),a=t==="right"?E(e,s):v(e,s),O=e[a];if(O!==void 0&&(r.i&&O.toLowerCase()===u.toLowerCase()||!r.i&&O===u)){let M=t==="right"?E(e,a):v(e,a),N=!1;if(S){let w=e[M];N=w!==void 0&&(r.i&&w.toLowerCase()===u.toLowerCase()||!r.i&&w===u)}N?m=!0:o+=1,typeof a=="number"&&t==="right"&&a>s+1?i.push([s+1,a]):t==="left"&&typeof a=="number"&&a<~-s&&i.unshift([a+1,s]),s=a,t==="right"?(f===void 0&&(f=a),h=a):(h===void 0&&(h=a),f=a)}else if(c)o+=1;else if(m)o+=1,m=void 0;else return null}return f===void 0||h===void 0?null:{gaps:i,leftmostChar:f,rightmostChar:h}}var D={i:!1};function W(t,e,...n){if(!(n!=null&&n.length))throw new Error("string-left-right/leftSeq(): [THROW_ID_01] only two input arguments were passed! Did you intend to use left() method instead?");let r;return p(n[0])?r=g(g({},D),n.shift()):r=D,U("left",t,e,r,Array.from(n).reverse())}function F(t,e,...n){if(!(n!=null&&n.length))throw new Error("string-left-right/rightSeq(): [THROW_ID_02] only two input arguments were passed! Did you intend to use right() method instead?");let r;return p(n[0])?r=g(g({},D),n.shift()):r=D,U("right",t,e,r,n)}function $(t,e,n,r,l=[]){var h,m;if(typeof e!="string"||!e.length||((!n||typeof n!="number")&&(n=0),t==="right"&&!e[n+1]||t==="left"&&+n==0))return null;let s=null,i=null;do s=t==="right"?F(e,typeof i=="number"?i:n,...l):W(e,typeof i=="number"?i:n,...l),s!==null&&(i=t==="right"?s.rightmostChar:s.leftmostChar);while(s);if(i!=null&&t==="right"&&(i+=1),i===null)return null;if(t==="right"){if((h=e[i])!=null&&h.trim())return i;let o=E(e,i);if(!r||r.mode===0){if(o===i+1)return i;if(e.slice(i,o||e.length).trim()||e.slice(i,o||e.length).includes("\n")||e.slice(i,o||e.length).includes("\r")){for(let u=i,c=e.length;u<c;u++)if("\n\r".includes(e[u]))return u}else return o?~-o:e.length}else{if(r.mode===1)return i;if(r.mode===2){let u=e.slice(i);if(u.trim()||u.includes("\n")||u.includes("\r")){for(let c=i,S=e.length;c<S;c++)if(e[c].trim()||"\n\r".includes(e[c]))return c}return e.length}}return o||e.length}if(e[i]&&((m=e[~-i])!=null&&m.trim()))return i;let f=v(e,i);if(!r||r.mode===0){if(f===i-2)return i;if(e.slice(0,i).trim()||e.slice(0,i).includes("\n")||e.slice(0,i).includes("\r")){for(let o=i;o--;)if("\n\r".includes(e[o])||e[o].trim())return o+1+(e[o].trim()?1:0)}return 0}if(r.mode===1)return i;if(r.mode===2){let o=e.slice(0,i);if(o.trim()||o.includes("\n")||o.includes("\r")){for(let u=i;u--;)if(e[u].trim()||"\n\r".includes(e[u]))return u+1}return 0}return f!==null?f+1:0}function X(t,e,...n){if(!n.length||n.length===1&&p(n[0]))return null;let r={mode:0};if(p(n[0])){let l=g(g({},r),n[0]);if(!l.mode)l.mode=0;else if(d(l.mode)&&l.mode.length===1&&"0123".includes(l.mode))l.mode=+l.mode;else if(!A(l.mode)||l.mode<0||l.mode>3)throw new Error("string-left-right/chompLeft(): [THROW_ID_03] the opts.mode is wrong! It should be 0, 1, 2 or 3. It was given as ".concat(l.mode," (type ").concat(typeof l.mode,")"));return $("left",t,e,l,n.slice(1))}return d(n[0])?$("left",t,e,r,n):$("left",t,e,r,n.slice(1))}function ee(t,e,...n){if(!n.length||n.length===1&&p(n[0]))return null;let r={mode:0};if(p(n[0])){let l=g(g({},r),n[0]);if(!l.mode)l.mode=0;else if(d(l.mode)&&/^[0-3]$/.test(l.mode))l.mode=Number.parseInt(l.mode,10);else if(!A(l.mode)||l.mode<0||l.mode>3)throw new Error("string-left-right/chompRight(): [THROW_ID_04] the opts.mode is wrong! It should be 0, 1, 2 or 3. It was given as ".concat(l.mode," (type ").concat(typeof l.mode,")"));return $("right",t,e,l,n.slice(1))}return d(n[0])?$("right",t,e,r,n):$("right",t,e,r,n.slice(1))}return _(te);})();
|
|
11
11
|
/**
|
|
12
12
|
* @name codsen-utils
|
|
13
13
|
* @fileoverview Various utility functions
|
|
14
|
-
* @version 1.
|
|
14
|
+
* @version 1.9.0
|
|
15
15
|
* @author Roy Revelt
|
|
16
16
|
* @license MIT
|
|
17
17
|
* {@link https://codsen.com/os/codsen-utils/}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "string-left-right",
|
|
3
|
-
"version": "6.1
|
|
3
|
+
"version": "6.2.1",
|
|
4
4
|
"description": "Looks up the first non-whitespace character to the left/right of a given index",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"check",
|
|
@@ -37,44 +37,42 @@
|
|
|
37
37
|
},
|
|
38
38
|
"types": "types/index.d.ts",
|
|
39
39
|
"scripts": {
|
|
40
|
-
"build": "node
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"dev": "DEV=true node '../../ops/scripts/esbuild.js' && npm run dts",
|
|
40
|
+
"build": "node ../../ops/scripts/esbuild.js && npm run dts",
|
|
41
|
+
"coverage": "c8 uvu test",
|
|
42
|
+
"dev": "node ../../ops/scripts/esbuild.js --dev && npm run dts",
|
|
44
43
|
"devtest": "c8 npm run unit && npm run examples && npm run lint",
|
|
45
|
-
"dts": "rollup -c &&
|
|
44
|
+
"dts": "rollup -c && biome format --write --config-path=../../biome.json --vcs-enabled=false --use-editorconfig=false types/index.d.ts",
|
|
46
45
|
"examples": "node '../../ops/scripts/run-examples.js'",
|
|
47
|
-
"lect": "node '../../ops/lect/lect.js'
|
|
48
|
-
"
|
|
49
|
-
"lint": "
|
|
46
|
+
"lect": "node '../../ops/lect/lect.js'",
|
|
47
|
+
"lect:check": "node '../../ops/lect/lect.js' --check",
|
|
48
|
+
"lint": "biome lint --error-on-warnings . && npm run typecheck",
|
|
49
|
+
"lint:fix": "biome lint --write --error-on-warnings . && npm run typecheck",
|
|
50
50
|
"perf": "node perf/check.js",
|
|
51
51
|
"prep": "echo 'ready'",
|
|
52
|
-
"prettier": "
|
|
53
|
-
"prettier:format": "
|
|
54
|
-
"pretest": "npm run lect && npm run build",
|
|
52
|
+
"prettier": "biome format",
|
|
53
|
+
"prettier:format": "biome format --write .",
|
|
54
|
+
"pretest": "npm run lect:check && npm run build",
|
|
55
55
|
"test": "npm run devtest",
|
|
56
|
+
"typecheck": "tsc --noEmit --pretty false --project tsconfig.json",
|
|
56
57
|
"unit": "uvu test"
|
|
57
58
|
},
|
|
58
|
-
"engines": {
|
|
59
|
-
"node": ">=14.18.0"
|
|
60
|
-
},
|
|
61
59
|
"c8": {
|
|
60
|
+
"all": true,
|
|
62
61
|
"check-coverage": true,
|
|
63
|
-
"exclude": [
|
|
64
|
-
|
|
65
|
-
],
|
|
62
|
+
"exclude": ["**/test/**/*.*"],
|
|
63
|
+
"include": ["dist/*.esm.js"],
|
|
66
64
|
"lines": 100
|
|
67
65
|
},
|
|
68
66
|
"lect": {
|
|
69
67
|
"licence": {
|
|
70
|
-
"extras": [
|
|
71
|
-
""
|
|
72
|
-
]
|
|
68
|
+
"extras": [""]
|
|
73
69
|
}
|
|
74
70
|
},
|
|
75
71
|
"dependencies": {
|
|
76
|
-
"codsen-utils": "^1.
|
|
77
|
-
|
|
72
|
+
"codsen-utils": "^1.9.0"
|
|
73
|
+
},
|
|
74
|
+
"engines": {
|
|
75
|
+
"node": ">=18.20.8"
|
|
78
76
|
},
|
|
79
77
|
"publishConfig": {
|
|
80
78
|
"registry": "https://registry.npmjs.org/"
|