@tolki/str 1.2.0 ā 1.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/README.md +22 -5
- package/dist/str.d.ts +16 -0
- package/dist/str.d.ts.map +1 -1
- package/dist/str.js +356 -330
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -463,7 +463,7 @@ import { excerpt } from "@tolki/str";
|
|
|
463
463
|
|
|
464
464
|
const result = excerpt("This is my name", "my", { radius: 3 });
|
|
465
465
|
|
|
466
|
-
// result is "...
|
|
466
|
+
// result is "...is my na..."
|
|
467
467
|
```
|
|
468
468
|
|
|
469
469
|
The radius option, which defaults to 100, allows you to define the number of characters that should appear on each side of the truncated string.
|
|
@@ -610,7 +610,7 @@ const result = is("*.jpg", "photo.JPG", true);
|
|
|
610
610
|
|
|
611
611
|
#### isAscii
|
|
612
612
|
|
|
613
|
-
Determine if a given string is 7
|
|
613
|
+
Determine if a given string is 7-bit ASCII.
|
|
614
614
|
|
|
615
615
|
```javascript
|
|
616
616
|
import { isAscii } from "@tolki/str";
|
|
@@ -860,7 +860,7 @@ const result = mask("taylor@example.com", "*", 3);
|
|
|
860
860
|
// result is "tay***************"
|
|
861
861
|
```
|
|
862
862
|
|
|
863
|
-
If needed, you provide a negative value for the third argument, which instructs the function to begin masking from the end of the string. A fourth argument may also provided to specify the number of masked characters.
|
|
863
|
+
If needed, you may provide a negative value for the third argument, which instructs the function to begin masking from the end of the string. A fourth argument may also be provided to specify the number of masked characters.
|
|
864
864
|
|
|
865
865
|
```javascript
|
|
866
866
|
import { mask } from "@tolki/str";
|
|
@@ -1012,6 +1012,8 @@ const result = pluralPascal("HelloWorld");
|
|
|
1012
1012
|
|
|
1013
1013
|
#### password
|
|
1014
1014
|
|
|
1015
|
+
`password`, `random`, `ulid`, `uuid`, and `uuid7` (along with their `createXUsing`/`createXNormally` testing helpers) generate a new value on every call, so a live playground would just show a different, unverifiable result each time you touch it ā there's no live example for these.
|
|
1016
|
+
|
|
1015
1017
|
Generate a random, secure password.
|
|
1016
1018
|
|
|
1017
1019
|
```javascript
|
|
@@ -1343,7 +1345,7 @@ const result2 = singular("children");
|
|
|
1343
1345
|
|
|
1344
1346
|
#### slug
|
|
1345
1347
|
|
|
1346
|
-
Generate a URL
|
|
1348
|
+
Generate a URL-friendly "slug" from a given string.
|
|
1347
1349
|
|
|
1348
1350
|
```javascript
|
|
1349
1351
|
import { slug } from "@tolki/str";
|
|
@@ -1501,7 +1503,7 @@ const result = swap(
|
|
|
1501
1503
|
"Tacos are great!",
|
|
1502
1504
|
);
|
|
1503
1505
|
|
|
1504
|
-
// result is "Burritos are fantastic"
|
|
1506
|
+
// result is "Burritos are fantastic!"
|
|
1505
1507
|
```
|
|
1506
1508
|
|
|
1507
1509
|
#### take
|
|
@@ -1786,6 +1788,10 @@ const result = wordCount("Hello, world!");
|
|
|
1786
1788
|
|
|
1787
1789
|
Wrap a string to a given number of characters.
|
|
1788
1790
|
|
|
1791
|
+
The width is counted in characters rather than in UTF-16 code units, so
|
|
1792
|
+
characters outside the Basic Multilingual Plane such as emoji each count as a
|
|
1793
|
+
single character.
|
|
1794
|
+
|
|
1789
1795
|
```javascript
|
|
1790
1796
|
import { wordWrap } from "@tolki/str";
|
|
1791
1797
|
|
|
@@ -1801,8 +1807,17 @@ The quick brown fox<br />
|
|
|
1801
1807
|
jumped over the lazy<br />
|
|
1802
1808
|
dog.
|
|
1803
1809
|
*/
|
|
1810
|
+
|
|
1811
|
+
const result2 = wordWrap("šššš", 2, "\n", true);
|
|
1812
|
+
|
|
1813
|
+
// result2 is "šš\nšš"
|
|
1804
1814
|
```
|
|
1805
1815
|
|
|
1816
|
+
' },
|
|
1817
|
+
{ name: 'cutLongWords', type: 'boolean', default: false },
|
|
1818
|
+
]"
|
|
1819
|
+
/>
|
|
1820
|
+
|
|
1806
1821
|
#### words
|
|
1807
1822
|
|
|
1808
1823
|
Limit the number of words in a string.
|
|
@@ -1837,6 +1852,8 @@ Using the `str` or `of` functions is discouraged for frontend projects because i
|
|
|
1837
1852
|
|
|
1838
1853
|
For frontend projects, it is recommended to use the individual string functions instead for better tree-shaking and smaller bundle sizes.
|
|
1839
1854
|
|
|
1855
|
+
Also unlike the standalone functions on this page, `str`/`of` return a `Stringable` class instance rather than a plain value, so there's no live playground for them here ā try the fluent methods it exposes (like `.append()` or `.snake()`) directly in your own code instead.
|
|
1856
|
+
|
|
1840
1857
|
Get a new Stringable object from the given string.
|
|
1841
1858
|
|
|
1842
1859
|
```javascript
|
package/dist/str.d.ts
CHANGED
|
@@ -766,6 +766,22 @@ export declare function wordCount(value: string, characters?: string | null): nu
|
|
|
766
766
|
/**
|
|
767
767
|
* Wrap a string to a given number of characters.
|
|
768
768
|
*
|
|
769
|
+
* The width is measured in Unicode characters rather than UTF-16 code units,
|
|
770
|
+
* so characters outside the Basic Multilingual Plane such as emoji count as a
|
|
771
|
+
* single character.
|
|
772
|
+
*
|
|
773
|
+
* Three long standing differences from Laravel's `Str::wordWrap()` are
|
|
774
|
+
* deliberate and are pinned by the "known differences from PHP" tests:
|
|
775
|
+
*
|
|
776
|
+
* - `cutLongWords` breaks strictly every `characters` characters here, while
|
|
777
|
+
* PHP breaks at word boundaries first and only splits words that are longer
|
|
778
|
+
* than the width on their own.
|
|
779
|
+
* - Leading whitespace on a line is dropped here, while PHP keeps it and emits
|
|
780
|
+
* it as its own line.
|
|
781
|
+
* - Line breaks already present in the string are replaced with `breakStr`
|
|
782
|
+
* here, while PHP leaves them as they are and only inserts `breakStr` where
|
|
783
|
+
* it wraps.
|
|
784
|
+
*
|
|
769
785
|
* @param value - The string to wrap
|
|
770
786
|
* @param characters - The maximum number of characters per line (default: 75)
|
|
771
787
|
* @param breakStr - The string to insert as a line break (default: "\n")
|
package/dist/str.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"str.d.ts","sourceRoot":"","sources":["../src/str.ts"],"names":[],"mappings":"AA6BA;;;;;;;;GA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;;;;;GAQG;AACH,wBAAgB,SAAS,CACrB,KAAK,EAAE,MAAM,EACb,UAAU,GAAE,MAAM,GAAG,IAAW,GACjC,MAAM,CAcR;AAwDD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,QAAQ,CACpB,KAAK,EAAE,MAAM,EACb,UAAU,GAAE,MAAW,EACvB,QAAQ,GAAE,MAAa,EACvB,YAAY,GAAE,OAAe,GAC9B,MAAM,CAuGR;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED;;;;;;;;GAQG;AACH,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;;;GAIG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAIjC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,IAAI,CAIxC"}
|
package/dist/str.js
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import { isArray as S, toLower as
|
|
2
|
-
import { title as
|
|
3
|
-
import { randomInt as
|
|
1
|
+
import { isArray as S, toLower as M, isString as O, isFunction as D, isNumber as Q } from "@tolki/utils";
|
|
2
|
+
import { title as q, upper as B } from "./convertcase/index.js";
|
|
3
|
+
import { randomInt as W, randomString as V } from "./random/index.js";
|
|
4
4
|
import { substr as x } from "./replacer/index.js";
|
|
5
|
-
import { ltrim as
|
|
6
|
-
import { createUlidsNormally as
|
|
7
|
-
import { createUuidsNormally as
|
|
5
|
+
import { ltrim as j, rtrim as G, trim as X } from "./trimmer/index.js";
|
|
6
|
+
import { createUlidsNormally as Y } from "./ulid/index.js";
|
|
7
|
+
import { createUuidsNormally as v } from "./uuid/index.js";
|
|
8
8
|
const R = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map(), F = /* @__PURE__ */ new Map();
|
|
9
|
-
let
|
|
10
|
-
function
|
|
9
|
+
let L = null;
|
|
10
|
+
function H(t, e) {
|
|
11
11
|
if (e === "")
|
|
12
12
|
return t;
|
|
13
13
|
const n = String(e), r = t.indexOf(n);
|
|
14
14
|
return r === -1 ? t : t.slice(r + n.length);
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function $t(t, e) {
|
|
17
17
|
if (e === "")
|
|
18
18
|
return t;
|
|
19
19
|
const n = t.lastIndexOf(String(e));
|
|
20
20
|
return n === -1 ? t : t.slice(n + String(e).length);
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function tt(t, e) {
|
|
23
23
|
if (e === "")
|
|
24
24
|
return t;
|
|
25
25
|
const n = t.indexOf(String(e));
|
|
26
26
|
return n === -1 ? t : t.slice(0, n);
|
|
27
27
|
}
|
|
28
|
-
function
|
|
28
|
+
function et(t, e) {
|
|
29
29
|
if (e === "")
|
|
30
30
|
return t;
|
|
31
31
|
const n = t.lastIndexOf(String(e));
|
|
32
32
|
return n === -1 ? t : x(t, 0, n);
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
return e === "" || n === "" ? t :
|
|
34
|
+
function kt(t, e, n) {
|
|
35
|
+
return e === "" || n === "" ? t : et(H(t, e), n);
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
return e === "" || n === "" ? t :
|
|
37
|
+
function At(t, e, n) {
|
|
38
|
+
return e === "" || n === "" ? t : tt(H(t, e), n);
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function bt(t) {
|
|
41
41
|
if (C.has(t))
|
|
42
42
|
return C.get(t);
|
|
43
|
-
const e =
|
|
43
|
+
const e = ft(K(t));
|
|
44
44
|
return C.set(t, e), e;
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function Et(t, e) {
|
|
47
47
|
const n = t.length;
|
|
48
48
|
return (e < 0 ? e < -n : e > n - 1) ? !1 : (e < 0 && (e += n), t.charAt(e));
|
|
49
49
|
}
|
|
50
|
-
function
|
|
50
|
+
function Lt(t, e) {
|
|
51
51
|
for (const n of S(e) ? e : [e])
|
|
52
52
|
if (n !== "" && t.startsWith(n)) {
|
|
53
53
|
const r = [...t], s = [...n];
|
|
@@ -55,7 +55,7 @@ function kt(t, e) {
|
|
|
55
55
|
}
|
|
56
56
|
return t;
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function Rt(t, e) {
|
|
59
59
|
for (const n of S(e) ? e : [e])
|
|
60
60
|
if (n !== "" && t.endsWith(n)) {
|
|
61
61
|
const r = [...t], s = [...n];
|
|
@@ -63,7 +63,7 @@ function bt(t, e) {
|
|
|
63
63
|
}
|
|
64
64
|
return t;
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function J(t, e, n = !1) {
|
|
67
67
|
n && (t = t.toLowerCase());
|
|
68
68
|
let r;
|
|
69
69
|
typeof e == "string" ? r = [e] : r = Array.from(e);
|
|
@@ -72,32 +72,33 @@ function H(t, e, n = !1) {
|
|
|
72
72
|
return !0;
|
|
73
73
|
return !1;
|
|
74
74
|
}
|
|
75
|
-
function
|
|
76
|
-
const { radius: r = 100, omission: s = "..." } = n, o = String(t ?? ""), c = e ?? "",
|
|
77
|
-
if (!
|
|
75
|
+
function Ct(t, e = "", n = {}) {
|
|
76
|
+
const { radius: r = 100, omission: s = "..." } = n, o = String(t ?? ""), c = e ?? "", l = ($) => $.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), i = new RegExp(`^(.*?)(${l(c)})(.*)$`, "iu").exec(o);
|
|
77
|
+
if (!i)
|
|
78
78
|
return null;
|
|
79
|
-
const
|
|
80
|
-
let w =
|
|
81
|
-
w !==
|
|
79
|
+
const m = String(i[1]), p = String(i[2]), g = String(i[3]), u = j(m), a = Array.from(u).length, y = x(u, Math.max(a - r, 0), r);
|
|
80
|
+
let w = j(y);
|
|
81
|
+
w !== u && (w = s + w);
|
|
82
82
|
const h = G(g), d = x(h, 0, r);
|
|
83
|
-
let
|
|
84
|
-
return
|
|
83
|
+
let k = G(d);
|
|
84
|
+
return k !== h && (k = k + s), w + p + k;
|
|
85
85
|
}
|
|
86
|
-
function
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
function Ft(t, e, n = !1) {
|
|
87
|
+
let r = !1;
|
|
88
|
+
for (const s of e)
|
|
89
|
+
if (r = !0, !J(t, s, n))
|
|
89
90
|
return !1;
|
|
90
|
-
return
|
|
91
|
+
return r;
|
|
91
92
|
}
|
|
92
|
-
function
|
|
93
|
-
return !
|
|
93
|
+
function _t(t, e, n = !1) {
|
|
94
|
+
return !J(t, e, n);
|
|
94
95
|
}
|
|
95
|
-
function
|
|
96
|
+
function Nt(t, e = " ") {
|
|
96
97
|
return S(e) ? (e.forEach((n) => {
|
|
97
98
|
t = t.replace(new RegExp(`${n}+`, "g"), n);
|
|
98
99
|
}), t) : t.replace(new RegExp(`${e}+`, "g"), e);
|
|
99
100
|
}
|
|
100
|
-
function
|
|
101
|
+
function U(t, e) {
|
|
101
102
|
if (t === null)
|
|
102
103
|
return !1;
|
|
103
104
|
t = String(t), S(e) ? e = Array.from(e) : e = [String(e)];
|
|
@@ -106,25 +107,25 @@ function W(t, e) {
|
|
|
106
107
|
return !0;
|
|
107
108
|
return !1;
|
|
108
109
|
}
|
|
109
|
-
function
|
|
110
|
-
return !
|
|
110
|
+
function zt(t, e) {
|
|
111
|
+
return !U(t, e);
|
|
111
112
|
}
|
|
112
|
-
function
|
|
113
|
+
function Ot(t, e) {
|
|
113
114
|
const n = e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
114
115
|
return t.replace(new RegExp(`(?:${n})+$`, "u"), "") + e;
|
|
115
116
|
}
|
|
116
|
-
function
|
|
117
|
+
function Wt(t, e, n = null) {
|
|
117
118
|
return e + t + (n ?? e);
|
|
118
119
|
}
|
|
119
|
-
function
|
|
120
|
-
return
|
|
120
|
+
function Mt(t, e, n = null) {
|
|
121
|
+
return P(t, e) && (t = x(t, _(e))), U(t, n ??= e) && (t = x(t, 0, -_(n))), t;
|
|
121
122
|
}
|
|
122
|
-
function
|
|
123
|
+
function Ut(t, e, n = !1) {
|
|
123
124
|
e = String(e);
|
|
124
125
|
let r;
|
|
125
126
|
typeof t == "string" ? r = [t] : r = Array.from(t);
|
|
126
127
|
for (let s of r) {
|
|
127
|
-
if (s = String(s), s === e || n &&
|
|
128
|
+
if (s = String(s), s === e || n && M(s) === M(e))
|
|
128
129
|
return !0;
|
|
129
130
|
s = s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), s = s.replace(/\\\*/g, ".*");
|
|
130
131
|
const o = n ? "iu" : "u";
|
|
@@ -133,14 +134,14 @@ function Ot(t, e, n = !1) {
|
|
|
133
134
|
}
|
|
134
135
|
return !1;
|
|
135
136
|
}
|
|
136
|
-
function
|
|
137
|
+
function Pt(t) {
|
|
137
138
|
for (let e = 0; e < t.length; e++)
|
|
138
139
|
if (t.charCodeAt(e) > 127)
|
|
139
140
|
return !1;
|
|
140
141
|
return !0;
|
|
141
142
|
}
|
|
142
|
-
function
|
|
143
|
-
if (!
|
|
143
|
+
function It(t) {
|
|
144
|
+
if (!O(t))
|
|
144
145
|
return !1;
|
|
145
146
|
try {
|
|
146
147
|
JSON.parse(t);
|
|
@@ -149,13 +150,13 @@ function Wt(t) {
|
|
|
149
150
|
}
|
|
150
151
|
return !0;
|
|
151
152
|
}
|
|
152
|
-
function
|
|
153
|
-
if (!
|
|
153
|
+
function qt(t, e = []) {
|
|
154
|
+
if (!O(t))
|
|
154
155
|
return !1;
|
|
155
156
|
const r = (e.length === 0 ? "aaa|aaas|about|acap|acct|acd|acr|adiumxtra|adt|afp|afs|aim|amss|android|appdata|apt|ark|attachment|aw|barion|beshare|bitcoin|bitcoincash|blob|bolo|browserext|calculator|callto|cap|cast|casts|chrome|chrome-extension|cid|coap|coap+tcp|coap+ws|coaps|coaps+tcp|coaps+ws|com-eventbrite-attendee|content|conti|crid|cvs|dab|data|dav|diaspora|dict|did|dis|dlna-playcontainer|dlna-playsingle|dns|dntp|dpp|drm|drop|dtn|dvb|ed2k|elsi|example|facetime|fax|feed|feedready|file|filesystem|finger|first-run-pen-experience|fish|fm|ftp|fuchsia-pkg|geo|gg|git|gizmoproject|go|gopher|graph|gtalk|h323|ham|hcap|hcp|http|https|hxxp|hxxps|hydrazone|iax|icap|icon|im|imap|info|iotdisco|ipn|ipp|ipps|irc|irc6|ircs|iris|iris.beep|iris.lwz|iris.xpc|iris.xpcs|isostore|itms|jabber|jar|jms|keyparc|lastfm|ldap|ldaps|leaptofrogans|lorawan|lvlt|magnet|mailserver|mailto|maps|market|message|mid|mms|modem|mongodb|moz|ms-access|ms-browser-extension|ms-calculator|ms-drive-to|ms-enrollment|ms-excel|ms-eyecontrolspeech|ms-gamebarservices|ms-gamingoverlay|ms-getoffice|ms-help|ms-infopath|ms-inputapp|ms-lockscreencomponent-config|ms-media-stream-id|ms-mixedrealitycapture|ms-mobileplans|ms-officeapp|ms-people|ms-project|ms-powerpoint|ms-publisher|ms-restoretabcompanion|ms-screenclip|ms-screensketch|ms-search|ms-search-repair|ms-secondary-screen-controller|ms-secondary-screen-setup|ms-settings|ms-settings-airplanemode|ms-settings-bluetooth|ms-settings-camera|ms-settings-cellular|ms-settings-cloudstorage|ms-settings-connectabledevices|ms-settings-displays-topology|ms-settings-emailandaccounts|ms-settings-language|ms-settings-location|ms-settings-lock|ms-settings-nfctransactions|ms-settings-notifications|ms-settings-power|ms-settings-privacy|ms-settings-proximity|ms-settings-screenrotation|ms-settings-wifi|ms-settings-workplace|ms-spd|ms-sttoverlay|ms-transit-to|ms-useractivityset|ms-virtualtouchpad|ms-visio|ms-walk-to|ms-whiteboard|ms-whiteboard-cmd|ms-word|msnim|msrp|msrps|mss|mtqp|mumble|mupdate|mvn|news|nfs|ni|nih|nntp|notes|ocf|oid|onenote|onenote-cmd|opaquelocktoken|openpgp4fpr|pack|palm|paparazzi|payto|pkcs11|platform|pop|pres|prospero|proxy|pwid|psyc|pttp|qb|query|redis|rediss|reload|res|resource|rmi|rsync|rtmfp|rtmp|rtsp|rtsps|rtspu|s3|secondlife|service|session|sftp|sgn|shttp|sieve|simpleledger|sip|sips|skype|smb|sms|smtp|snews|snmp|soap.beep|soap.beeps|soldat|spiffe|spotify|ssh|steam|stun|stuns|submit|svn|tag|teamspeak|tel|teliaeid|telnet|tftp|tg|things|thismessage|tip|tn3270|tool|ts3server|turn|turns|tv|udp|unreal|urn|ut2004|v-event|vemmi|ventrilo|videotex|vnc|view-source|wais|webcal|wpid|ws|wss|wtai|wyciwyg|xcon|xcon-userid|xfire|xmlrpc.beep|xmlrpc.beeps|xmpp|xri|ymsgr|z39.50|z39.50r|z39.50s" : e.join("|")).split("|").map((o) => o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|");
|
|
156
157
|
try {
|
|
157
|
-
const o = new URL(t), c = o.protocol.replace(":", ""),
|
|
158
|
-
if (r.split("|").includes(c) && (
|
|
158
|
+
const o = new URL(t), c = o.protocol.replace(":", ""), l = o.hostname, i = t.slice(t.indexOf("://") + 3).startsWith("/"), m = l.length > 0 && !/^\.+$/.test(l) && !i, p = c === "file" && i;
|
|
159
|
+
if (r.split("|").includes(c) && (m || p))
|
|
159
160
|
return !0;
|
|
160
161
|
} catch {
|
|
161
162
|
}
|
|
@@ -179,31 +180,31 @@ function Mt(t, e = []) {
|
|
|
179
180
|
].join("");
|
|
180
181
|
return new RegExp(s, "iu").test(t);
|
|
181
182
|
}
|
|
182
|
-
function
|
|
183
|
-
return
|
|
183
|
+
function jt(t) {
|
|
184
|
+
return lt(t, "-");
|
|
184
185
|
}
|
|
185
186
|
function _(t) {
|
|
186
187
|
return t.length;
|
|
187
188
|
}
|
|
188
|
-
function
|
|
189
|
+
function Gt(t, e = 100, n = "...", r = !1) {
|
|
189
190
|
if (t.length <= e)
|
|
190
191
|
return t;
|
|
191
192
|
if (!r)
|
|
192
193
|
return t.slice(0, e).replace(/\s+$/, "") + n;
|
|
193
|
-
t =
|
|
194
|
+
t = ct(t).replace(/[\n\r]+/g, " ").trim();
|
|
194
195
|
const s = t.slice(0, e).replace(/\s+$/, "");
|
|
195
196
|
return t.substring(e, e + 1) === " " ? s + n : s.replace(/(.*)\s.*/, "$1") + n;
|
|
196
197
|
}
|
|
197
|
-
function
|
|
198
|
-
return
|
|
198
|
+
function Z(t) {
|
|
199
|
+
return M(t);
|
|
199
200
|
}
|
|
200
|
-
function
|
|
201
|
+
function Tt(t, e = 100, n = "...") {
|
|
201
202
|
if (e <= 0)
|
|
202
203
|
return t;
|
|
203
204
|
const r = e, s = new RegExp(`^\\s*(?:\\S+\\s*){1,${r}}`, "u"), o = t.match(s);
|
|
204
205
|
return !o || _(t) === _(o[0]) ? t : o[0].trimEnd() + n;
|
|
205
206
|
}
|
|
206
|
-
function
|
|
207
|
+
function Bt(t, e, n, r = null) {
|
|
207
208
|
if (e === "")
|
|
208
209
|
return t;
|
|
209
210
|
const s = t.length;
|
|
@@ -215,17 +216,17 @@ function Gt(t, e, n, r = null) {
|
|
|
215
216
|
);
|
|
216
217
|
if (c === "")
|
|
217
218
|
return t;
|
|
218
|
-
const
|
|
219
|
-
return
|
|
219
|
+
const l = t.slice(0, o), f = c.length, i = t.slice(o + f);
|
|
220
|
+
return l + e.slice(0, 1).repeat(f) + i;
|
|
220
221
|
}
|
|
221
|
-
function
|
|
222
|
+
function Ht(t, e) {
|
|
222
223
|
let n = "u", r = t;
|
|
223
224
|
if (t.length >= 2 && t[0] === "/") {
|
|
224
225
|
let s = -1;
|
|
225
226
|
for (let o = t.length - 1; o > 0; o--)
|
|
226
227
|
if (t[o] === "/") {
|
|
227
228
|
let c = 0;
|
|
228
|
-
for (let
|
|
229
|
+
for (let l = o - 1; l >= 0 && t[l] === "\\"; l--)
|
|
229
230
|
c++;
|
|
230
231
|
if (c % 2 === 0) {
|
|
231
232
|
s = o;
|
|
@@ -247,7 +248,7 @@ function Tt(t, e) {
|
|
|
247
248
|
return "";
|
|
248
249
|
}
|
|
249
250
|
}
|
|
250
|
-
function
|
|
251
|
+
function Jt(t, e) {
|
|
251
252
|
e = String(e);
|
|
252
253
|
const n = typeof t == "string" ? [t] : Array.from(t);
|
|
253
254
|
for (const r of n) {
|
|
@@ -255,21 +256,21 @@ function Bt(t, e) {
|
|
|
255
256
|
let s = "u", o = r;
|
|
256
257
|
if (r.length >= 2 && r[0] === "/") {
|
|
257
258
|
let c = -1;
|
|
258
|
-
for (let
|
|
259
|
-
if (r[
|
|
259
|
+
for (let l = r.length - 1; l > 0; l--)
|
|
260
|
+
if (r[l] === "/") {
|
|
260
261
|
let f = 0;
|
|
261
|
-
for (let
|
|
262
|
+
for (let i = l - 1; i >= 0 && r[i] === "\\"; i--)
|
|
262
263
|
f++;
|
|
263
264
|
if (f % 2 === 0) {
|
|
264
|
-
c =
|
|
265
|
+
c = l;
|
|
265
266
|
break;
|
|
266
267
|
}
|
|
267
268
|
}
|
|
268
269
|
if (c > 0) {
|
|
269
270
|
o = r.slice(1, c);
|
|
270
|
-
const
|
|
271
|
-
if (
|
|
272
|
-
for (const f of
|
|
271
|
+
const l = r.slice(c + 1);
|
|
272
|
+
if (l)
|
|
273
|
+
for (const f of l)
|
|
273
274
|
/[imsuy]/.test(f) && !s.includes(f) && (s += f);
|
|
274
275
|
}
|
|
275
276
|
}
|
|
@@ -281,16 +282,16 @@ function Bt(t, e) {
|
|
|
281
282
|
}
|
|
282
283
|
return !1;
|
|
283
284
|
}
|
|
284
|
-
function
|
|
285
|
+
function Zt(t, e) {
|
|
285
286
|
let n = "u", r = t;
|
|
286
287
|
if (t.length >= 2 && t[0] === "/") {
|
|
287
288
|
let o = -1;
|
|
288
289
|
for (let c = t.length - 1; c > 0; c--)
|
|
289
290
|
if (t[c] === "/") {
|
|
290
|
-
let
|
|
291
|
+
let l = 0;
|
|
291
292
|
for (let f = c - 1; f >= 0 && t[f] === "\\"; f--)
|
|
292
|
-
|
|
293
|
-
if (
|
|
293
|
+
l++;
|
|
294
|
+
if (l % 2 === 0) {
|
|
294
295
|
o = c;
|
|
295
296
|
break;
|
|
296
297
|
}
|
|
@@ -299,8 +300,8 @@ function Ht(t, e) {
|
|
|
299
300
|
r = t.slice(1, o);
|
|
300
301
|
const c = t.slice(o + 1);
|
|
301
302
|
if (c)
|
|
302
|
-
for (const
|
|
303
|
-
/[gimsuy]/.test(
|
|
303
|
+
for (const l of c)
|
|
304
|
+
/[gimsuy]/.test(l) && !n.includes(l) && (n += l);
|
|
304
305
|
}
|
|
305
306
|
}
|
|
306
307
|
n.includes("g") || (n += "g");
|
|
@@ -315,24 +316,24 @@ function Ht(t, e) {
|
|
|
315
316
|
}
|
|
316
317
|
return s;
|
|
317
318
|
}
|
|
318
|
-
function
|
|
319
|
+
function Kt(t) {
|
|
319
320
|
return S(t) ? t.map((e) => e.replace(/[^0-9]/g, "")) : t.replace(/[^0-9]/g, "");
|
|
320
321
|
}
|
|
321
|
-
function
|
|
322
|
+
function Dt(t, e, n = " ") {
|
|
322
323
|
const r = t.length;
|
|
323
324
|
if (e <= r || n === "")
|
|
324
325
|
return t;
|
|
325
326
|
const s = e - r, o = Math.floor(s / 2), c = s - o;
|
|
326
327
|
return N(n, o) + t + N(n, c);
|
|
327
328
|
}
|
|
328
|
-
function
|
|
329
|
+
function Qt(t, e, n = " ") {
|
|
329
330
|
const r = t.length;
|
|
330
331
|
if (e <= r || n === "")
|
|
331
332
|
return t;
|
|
332
333
|
const o = e - r;
|
|
333
334
|
return N(n, o) + t;
|
|
334
335
|
}
|
|
335
|
-
function
|
|
336
|
+
function Vt(t, e, n = " ") {
|
|
336
337
|
const r = t.length;
|
|
337
338
|
if (e <= r || n === "")
|
|
338
339
|
return t;
|
|
@@ -345,8 +346,8 @@ function N(t, e) {
|
|
|
345
346
|
const n = Math.ceil(e / t.length);
|
|
346
347
|
return t.repeat(n).slice(0, e);
|
|
347
348
|
}
|
|
348
|
-
function
|
|
349
|
-
const
|
|
349
|
+
function Xt(t = 32, e = !0, n = !0, r = !0, s = !1) {
|
|
350
|
+
const i = [
|
|
350
351
|
e ? [
|
|
351
352
|
"a",
|
|
352
353
|
"b",
|
|
@@ -431,26 +432,26 @@ function Dt(t = 32, e = !0, n = !0, r = !0, s = !1) {
|
|
|
431
432
|
";"
|
|
432
433
|
] : null,
|
|
433
434
|
s ? [" "] : null
|
|
434
|
-
].filter((
|
|
435
|
-
if (
|
|
435
|
+
].filter((u) => S(u));
|
|
436
|
+
if (i.length === 0 || t <= 0)
|
|
436
437
|
return "";
|
|
437
|
-
const
|
|
438
|
-
for (const
|
|
439
|
-
const
|
|
440
|
-
|
|
438
|
+
const m = [];
|
|
439
|
+
for (const u of i) {
|
|
440
|
+
const a = W(0, u.length - 1);
|
|
441
|
+
m.push(u[a]);
|
|
441
442
|
}
|
|
442
|
-
const
|
|
443
|
-
for (let
|
|
444
|
-
const
|
|
445
|
-
|
|
443
|
+
const p = Math.max(0, t - m.length), g = i.flat();
|
|
444
|
+
for (let u = 0; u < p; u++) {
|
|
445
|
+
const a = W(0, g.length - 1);
|
|
446
|
+
m.push(g[a]);
|
|
446
447
|
}
|
|
447
|
-
for (let
|
|
448
|
-
const
|
|
449
|
-
u
|
|
448
|
+
for (let u = m.length - 1; u > 0; u--) {
|
|
449
|
+
const a = W(0, u), y = m[u];
|
|
450
|
+
m[u] = m[a], m[a] = y;
|
|
450
451
|
}
|
|
451
|
-
return
|
|
452
|
+
return m.join("");
|
|
452
453
|
}
|
|
453
|
-
function
|
|
454
|
+
function Yt(t, e, n = 0) {
|
|
454
455
|
if (e === "")
|
|
455
456
|
return !1;
|
|
456
457
|
const r = Array.from(t), s = Array.from(e);
|
|
@@ -458,41 +459,41 @@ function Qt(t, e, n = 0) {
|
|
|
458
459
|
if (o < 0 && (o = 0), o >= r.length)
|
|
459
460
|
return !1;
|
|
460
461
|
const c = r.length - s.length;
|
|
461
|
-
for (let
|
|
462
|
+
for (let l = o; l <= c; l++) {
|
|
462
463
|
let f = !0;
|
|
463
|
-
for (let
|
|
464
|
-
if (r[
|
|
464
|
+
for (let i = 0; i < s.length; i++)
|
|
465
|
+
if (r[l + i] !== s[i]) {
|
|
465
466
|
f = !1;
|
|
466
467
|
break;
|
|
467
468
|
}
|
|
468
469
|
if (f)
|
|
469
|
-
return
|
|
470
|
+
return l;
|
|
470
471
|
}
|
|
471
472
|
return !1;
|
|
472
473
|
}
|
|
473
|
-
function
|
|
474
|
-
return (
|
|
474
|
+
function nt(t = 16) {
|
|
475
|
+
return (L ?? ((n) => V(n)))(t);
|
|
475
476
|
}
|
|
476
|
-
function
|
|
477
|
-
|
|
477
|
+
function rt(t) {
|
|
478
|
+
L = t;
|
|
478
479
|
}
|
|
479
|
-
function
|
|
480
|
+
function vt(t, e) {
|
|
480
481
|
let n = 0;
|
|
481
482
|
const r = e ?? function(s) {
|
|
482
|
-
const o =
|
|
483
|
-
|
|
484
|
-
const c =
|
|
485
|
-
return
|
|
483
|
+
const o = L;
|
|
484
|
+
L = null;
|
|
485
|
+
const c = nt(s);
|
|
486
|
+
return L = o, n++, c;
|
|
486
487
|
};
|
|
487
|
-
|
|
488
|
+
rt((s) => n < t.length ? String(t[n++]) : r(s));
|
|
488
489
|
}
|
|
489
|
-
function
|
|
490
|
-
|
|
490
|
+
function st() {
|
|
491
|
+
L = null;
|
|
491
492
|
}
|
|
492
|
-
function
|
|
493
|
+
function te(t, e) {
|
|
493
494
|
return e <= 0 ? "" : t.repeat(e);
|
|
494
495
|
}
|
|
495
|
-
function
|
|
496
|
+
function ee(t, e, n) {
|
|
496
497
|
let r;
|
|
497
498
|
typeof e == "object" && !S(e) ? r = Object.values(e) : r = S(e) ? [...e] : Array.from(e);
|
|
498
499
|
const s = n.split(t);
|
|
@@ -500,12 +501,12 @@ function Yt(t, e, n) {
|
|
|
500
501
|
return n;
|
|
501
502
|
let o = s[0];
|
|
502
503
|
for (let c = 1; c < s.length; c++) {
|
|
503
|
-
const
|
|
504
|
-
o +=
|
|
504
|
+
const l = r.length ? r.shift() : t;
|
|
505
|
+
o += l + s[c];
|
|
505
506
|
}
|
|
506
507
|
return String(o);
|
|
507
508
|
}
|
|
508
|
-
function
|
|
509
|
+
function ne(t, e) {
|
|
509
510
|
try {
|
|
510
511
|
const n = String(t);
|
|
511
512
|
if (n.length)
|
|
@@ -515,116 +516,116 @@ function vt(t, e) {
|
|
|
515
516
|
return e;
|
|
516
517
|
}
|
|
517
518
|
}
|
|
518
|
-
function
|
|
519
|
-
const s = (
|
|
520
|
-
if (
|
|
521
|
-
const
|
|
519
|
+
function re(t, e, n, r = !0) {
|
|
520
|
+
const s = (i) => typeof i == "string" ? [i] : Array.from(i), o = s(t), c = s(e), l = (i) => i.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = (i) => o.reduce((m, p, g) => {
|
|
521
|
+
if (p === "") return m;
|
|
522
|
+
const u = c[g] ?? "";
|
|
522
523
|
if (!r)
|
|
523
|
-
return
|
|
524
|
-
const
|
|
525
|
-
return
|
|
526
|
-
},
|
|
527
|
-
return
|
|
524
|
+
return m.split(p).join(u);
|
|
525
|
+
const a = new RegExp(l(p), "gi");
|
|
526
|
+
return m.replace(a, () => u);
|
|
527
|
+
}, i);
|
|
528
|
+
return O(n) ? f(n) : Array.from(n).map(f);
|
|
528
529
|
}
|
|
529
|
-
function
|
|
530
|
+
function ot(t, e, n) {
|
|
530
531
|
if (t = String(t), t === "")
|
|
531
532
|
return n;
|
|
532
533
|
const r = n.indexOf(t);
|
|
533
534
|
return r !== -1 ? n.slice(0, r) + e + n.slice(r + t.length) : n;
|
|
534
535
|
}
|
|
535
|
-
function
|
|
536
|
-
return t = String(t), t === "" ? n :
|
|
536
|
+
function se(t, e, n) {
|
|
537
|
+
return t = String(t), t === "" ? n : P(n, t) ? ot(t, e, n) : n;
|
|
537
538
|
}
|
|
538
|
-
function
|
|
539
|
+
function it(t, e, n) {
|
|
539
540
|
if (t = String(t), t === "")
|
|
540
541
|
return n;
|
|
541
542
|
const r = n.lastIndexOf(t);
|
|
542
543
|
return r !== -1 ? n.slice(0, r) + e + n.slice(r + t.length) : n;
|
|
543
544
|
}
|
|
544
|
-
function
|
|
545
|
-
return t = String(t), t === "" ? n :
|
|
545
|
+
function oe(t, e, n) {
|
|
546
|
+
return t = String(t), t === "" ? n : U(n, t) ? it(t, e, n) : n;
|
|
546
547
|
}
|
|
547
|
-
function
|
|
548
|
-
const s = (
|
|
549
|
-
function c(
|
|
548
|
+
function ie(t, e, n, r = -1) {
|
|
549
|
+
const s = (p) => S(p) ? p : [p], o = s(t);
|
|
550
|
+
function c(p) {
|
|
550
551
|
try {
|
|
551
|
-
if (
|
|
552
|
-
let
|
|
553
|
-
return
|
|
552
|
+
if (p instanceof RegExp) {
|
|
553
|
+
let a = p.flags;
|
|
554
|
+
return a.includes("g") || (a += "g"), a.includes("u") || (a += "u"), new RegExp(p.source, a);
|
|
554
555
|
}
|
|
555
|
-
let g =
|
|
556
|
-
if (
|
|
557
|
-
let
|
|
558
|
-
for (let y =
|
|
559
|
-
if (
|
|
556
|
+
let g = p, u = "gu";
|
|
557
|
+
if (p.length >= 2 && p[0] === "/") {
|
|
558
|
+
let a = -1;
|
|
559
|
+
for (let y = p.length - 1; y > 0; y--)
|
|
560
|
+
if (p[y] === "/") {
|
|
560
561
|
let w = 0;
|
|
561
|
-
for (let h = y - 1; h >= 0 &&
|
|
562
|
+
for (let h = y - 1; h >= 0 && p[h] === "\\"; h--)
|
|
562
563
|
w++;
|
|
563
564
|
if (w % 2 === 0) {
|
|
564
|
-
|
|
565
|
+
a = y;
|
|
565
566
|
break;
|
|
566
567
|
}
|
|
567
568
|
}
|
|
568
|
-
if (
|
|
569
|
-
g =
|
|
570
|
-
const y =
|
|
569
|
+
if (a > 1) {
|
|
570
|
+
g = p.slice(1, a);
|
|
571
|
+
const y = p.slice(a + 1);
|
|
571
572
|
if (y)
|
|
572
573
|
for (const w of y)
|
|
573
|
-
/[imsuy]/.test(w) && !
|
|
574
|
+
/[imsuy]/.test(w) && !u.includes(w) && (u += w);
|
|
574
575
|
}
|
|
575
576
|
}
|
|
576
577
|
return new RegExp(
|
|
577
578
|
g,
|
|
578
|
-
Array.from(new Set(
|
|
579
|
+
Array.from(new Set(u.split(""))).join("")
|
|
579
580
|
);
|
|
580
581
|
} catch {
|
|
581
582
|
return null;
|
|
582
583
|
}
|
|
583
584
|
}
|
|
584
|
-
const
|
|
585
|
-
for (const
|
|
586
|
-
const g = c(
|
|
585
|
+
const l = [];
|
|
586
|
+
for (const p of o) {
|
|
587
|
+
const g = c(p);
|
|
587
588
|
if (!g) return null;
|
|
588
|
-
|
|
589
|
+
l.push(g);
|
|
589
590
|
}
|
|
590
|
-
const f =
|
|
591
|
-
let g =
|
|
592
|
-
for (let
|
|
593
|
-
const
|
|
591
|
+
const f = D(e), i = f ? [] : s(e), m = (p) => {
|
|
592
|
+
let g = p;
|
|
593
|
+
for (let u = 0; u < l.length; u++) {
|
|
594
|
+
const a = l[u];
|
|
594
595
|
if (f) {
|
|
595
596
|
let y = 0;
|
|
596
597
|
const w = e;
|
|
597
598
|
g = g.replace(
|
|
598
|
-
|
|
599
|
+
a,
|
|
599
600
|
(h, ...d) => {
|
|
600
601
|
if (r >= 0 && y >= r) return h;
|
|
601
602
|
y++;
|
|
602
603
|
const b = d.length > 0 && d[d.length - 1] !== null && typeof d[d.length - 1] == "object" ? d.length - 3 : d.length - 2, $ = [];
|
|
603
|
-
for (let
|
|
604
|
-
$.push(d[
|
|
605
|
-
const
|
|
606
|
-
return w(
|
|
604
|
+
for (let A = 0; A < b; A++)
|
|
605
|
+
$.push(d[A]);
|
|
606
|
+
const E = [h, ...$];
|
|
607
|
+
return w(E);
|
|
607
608
|
}
|
|
608
609
|
);
|
|
609
610
|
} else {
|
|
610
|
-
const y =
|
|
611
|
+
const y = i[u] ?? (i.length === 1 ? i[0] : "");
|
|
611
612
|
if (r < 0)
|
|
612
|
-
g = g.replace(
|
|
613
|
-
const
|
|
614
|
-
return y.replace(/\$(\d{1,2})/g, ($,
|
|
615
|
-
const
|
|
616
|
-
return (b[
|
|
613
|
+
g = g.replace(a, (w, ...h) => {
|
|
614
|
+
const k = h.length > 0 && h[h.length - 1] !== null && typeof h[h.length - 1] == "object" ? h.length - 3 : h.length - 2, b = h.slice(0, k).map(($) => String($));
|
|
615
|
+
return y.replace(/\$(\d{1,2})/g, ($, E) => {
|
|
616
|
+
const A = parseInt(E, 10);
|
|
617
|
+
return (b[A - 1] ?? "").toUpperCase();
|
|
617
618
|
});
|
|
618
619
|
});
|
|
619
620
|
else {
|
|
620
621
|
let w = 0;
|
|
621
|
-
g = g.replace(
|
|
622
|
+
g = g.replace(a, (h, ...d) => {
|
|
622
623
|
if (w >= r) return h;
|
|
623
624
|
w++;
|
|
624
|
-
const b = d.length > 0 && d[d.length - 1] !== null && typeof d[d.length - 1] == "object" ? d.length - 3 : d.length - 2, $ = d.slice(0, b).map((
|
|
625
|
-
return y.replace(/\$(\d{1,2})/g, (
|
|
626
|
-
const
|
|
627
|
-
return ($[
|
|
625
|
+
const b = d.length > 0 && d[d.length - 1] !== null && typeof d[d.length - 1] == "object" ? d.length - 3 : d.length - 2, $ = d.slice(0, b).map((E) => String(E));
|
|
626
|
+
return y.replace(/\$(\d{1,2})/g, (E, A) => {
|
|
627
|
+
const I = parseInt(A, 10);
|
|
628
|
+
return ($[I - 1] ?? "").toUpperCase();
|
|
628
629
|
});
|
|
629
630
|
});
|
|
630
631
|
}
|
|
@@ -632,9 +633,9 @@ function re(t, e, n, r = -1) {
|
|
|
632
633
|
}
|
|
633
634
|
return g;
|
|
634
635
|
};
|
|
635
|
-
return S(n) ? n.map(
|
|
636
|
+
return S(n) ? n.map(m) : m(n);
|
|
636
637
|
}
|
|
637
|
-
function
|
|
638
|
+
function ct(t) {
|
|
638
639
|
let e = "", n = !1;
|
|
639
640
|
for (let r = 0; r < t.length; r++) {
|
|
640
641
|
const s = t[r];
|
|
@@ -642,40 +643,40 @@ function ot(t) {
|
|
|
642
643
|
}
|
|
643
644
|
return e;
|
|
644
645
|
}
|
|
645
|
-
function
|
|
646
|
+
function ce(t, e, n = !0) {
|
|
646
647
|
const r = typeof t == "string" ? [t] : Array.from(t), s = (c) => c.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), o = (c) => {
|
|
647
|
-
let
|
|
648
|
+
let l = c;
|
|
648
649
|
for (const f of r)
|
|
649
650
|
if (f !== "")
|
|
650
651
|
if (n)
|
|
651
|
-
|
|
652
|
+
l = l.split(f).join("");
|
|
652
653
|
else {
|
|
653
|
-
const
|
|
654
|
-
|
|
654
|
+
const i = new RegExp(s(f), "gi");
|
|
655
|
+
l = l.replace(i, "");
|
|
655
656
|
}
|
|
656
|
-
return
|
|
657
|
+
return l;
|
|
657
658
|
};
|
|
658
659
|
return typeof e == "string" ? o(e) : Array.from(e, (c) => o(String(c)));
|
|
659
660
|
}
|
|
660
|
-
function
|
|
661
|
+
function le(t) {
|
|
661
662
|
return Array.from(t).reverse().join("");
|
|
662
663
|
}
|
|
663
|
-
function
|
|
664
|
+
function fe(t, e) {
|
|
664
665
|
const n = e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
665
666
|
return e + t.replace(new RegExp(`^(?:${n})+`, "u"), "");
|
|
666
667
|
}
|
|
667
|
-
function
|
|
668
|
+
function ae(t) {
|
|
668
669
|
const e = String(t).trim();
|
|
669
670
|
if (e === "")
|
|
670
671
|
return "";
|
|
671
672
|
let n = e.split(/\s+/u);
|
|
672
|
-
return n.length > 1 ? n = n.map((s) =>
|
|
673
|
+
return n.length > 1 ? n = n.map((s) => q(s)) : n = at(n.join("_")).map((s) => q(s)), n.join("_").replace(/[-_ ]+/gu, "_").split("_").filter((s) => s.length > 0).join(" ");
|
|
673
674
|
}
|
|
674
|
-
function
|
|
675
|
+
function ue(t, e = !1) {
|
|
675
676
|
const r = t.split(/\s+/u).filter((s) => s.length > 0).map((s) => [...s][0]).join("");
|
|
676
|
-
return e ?
|
|
677
|
+
return e ? B(r) : r;
|
|
677
678
|
}
|
|
678
|
-
function
|
|
679
|
+
function pe(t) {
|
|
679
680
|
if (t.trim() === "")
|
|
680
681
|
return t;
|
|
681
682
|
const e = /* @__PURE__ */ new Set([
|
|
@@ -716,36 +717,36 @@ function fe(t) {
|
|
|
716
717
|
"Ć "
|
|
717
718
|
]), n = /* @__PURE__ */ new Set([".", "!", "?", ":", "ā", ","]), r = t.split(/\s+/u), s = (o) => {
|
|
718
719
|
if (!o) return o;
|
|
719
|
-
const c = Array.from(o),
|
|
720
|
-
return
|
|
720
|
+
const c = Array.from(o), l = c[0].toLocaleUpperCase(), f = c.slice(1).join("");
|
|
721
|
+
return l + f;
|
|
721
722
|
};
|
|
722
723
|
for (let o = 0; o < r.length; o++) {
|
|
723
724
|
const c = r[o].toLocaleLowerCase();
|
|
724
725
|
if (c.includes("-")) {
|
|
725
|
-
const f = c.split("-").map((
|
|
726
|
+
const f = c.split("-").map((i) => e.has(i) && i.length <= 3 ? i : s(i));
|
|
726
727
|
r[o] = f.join("-");
|
|
727
728
|
} else {
|
|
728
|
-
const
|
|
729
|
-
e.has(c) && c.length <= 3 && !
|
|
729
|
+
const l = o > 0 ? r[o - 1] : "", f = l ? Array.from(l).slice(-1)[0] : void 0, i = o === 0 || f !== void 0 && n.has(f);
|
|
730
|
+
e.has(c) && c.length <= 3 && !i ? r[o] = c : r[o] = s(c);
|
|
730
731
|
}
|
|
731
732
|
}
|
|
732
733
|
return r.join(" ");
|
|
733
734
|
}
|
|
734
|
-
function
|
|
735
|
+
function lt(t, e = "_") {
|
|
735
736
|
const r = `${t}|${e}`;
|
|
736
737
|
if (R.has(r))
|
|
737
738
|
return R.get(r);
|
|
738
739
|
let s = t;
|
|
739
|
-
return /^[a-z]+$/.test(t) || (s =
|
|
740
|
+
return /^[a-z]+$/.test(t) || (s = ut(t).replace(/\s+/gu, ""), s = s.replace(/(.)(?=[A-Z])/g, `$1${e}`), s = Z(s)), R.set(r, s), s;
|
|
740
741
|
}
|
|
741
|
-
function
|
|
742
|
-
return
|
|
742
|
+
function me(t) {
|
|
743
|
+
return X(t).replace(/[\s\u3164\u1160]+/gu, " ");
|
|
743
744
|
}
|
|
744
|
-
function
|
|
745
|
+
function P(t, e) {
|
|
745
746
|
if (t == null || e == null)
|
|
746
747
|
return !1;
|
|
747
748
|
let n;
|
|
748
|
-
|
|
749
|
+
O(e) || Q(e) ? n = [e] : Symbol.iterator in Object(e) ? n = Array.from(e) : n = [e];
|
|
749
750
|
const r = String(t);
|
|
750
751
|
for (const s of n) {
|
|
751
752
|
if (s == null)
|
|
@@ -756,29 +757,29 @@ function M(t, e) {
|
|
|
756
757
|
}
|
|
757
758
|
return !1;
|
|
758
759
|
}
|
|
759
|
-
function
|
|
760
|
-
return !
|
|
760
|
+
function ge(t, e) {
|
|
761
|
+
return !P(t, e);
|
|
761
762
|
}
|
|
762
|
-
function
|
|
763
|
+
function K(t, e = !1) {
|
|
763
764
|
let n = t;
|
|
764
765
|
e && (n = t.replace(
|
|
765
766
|
/(^|[-_ \s])([A-Z]+)(?=[-_ \s]|$)/gu,
|
|
766
|
-
(f,
|
|
767
|
+
(f, i, m) => i + m.toLowerCase()
|
|
767
768
|
));
|
|
768
769
|
const r = n;
|
|
769
770
|
if (F.has(r))
|
|
770
771
|
return F.get(r);
|
|
771
772
|
const s = String(n).replace(/[-_]+/g, " "), o = s.trim() === "" ? [] : s.split(/\s+/u), c = (f) => {
|
|
772
773
|
if (!f) return f;
|
|
773
|
-
const
|
|
774
|
-
return
|
|
775
|
-
},
|
|
776
|
-
return F.set(r,
|
|
774
|
+
const i = Array.from(f), m = i[0].toUpperCase(), p = i.slice(1).join("");
|
|
775
|
+
return m + p;
|
|
776
|
+
}, l = o.map(c).join("");
|
|
777
|
+
return F.set(r, l), l;
|
|
777
778
|
}
|
|
778
|
-
function
|
|
779
|
-
return
|
|
779
|
+
function he(t, e = !1) {
|
|
780
|
+
return K(t, e);
|
|
780
781
|
}
|
|
781
|
-
function
|
|
782
|
+
function de(t, e) {
|
|
782
783
|
if (!t || Object.keys(t).length === 0)
|
|
783
784
|
return e;
|
|
784
785
|
const n = Object.keys(t).filter((o) => o !== "");
|
|
@@ -788,169 +789,194 @@ function ge(t, e) {
|
|
|
788
789
|
const r = (o) => o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), s = new RegExp(n.map(r).join("|"), "gu");
|
|
789
790
|
return e.replace(s, (o) => t[o]);
|
|
790
791
|
}
|
|
791
|
-
function
|
|
792
|
+
function ye(t, e) {
|
|
792
793
|
return e < 0 ? x(t, e) : x(t, 0, e);
|
|
793
794
|
}
|
|
794
|
-
function
|
|
795
|
-
return
|
|
795
|
+
function ft(t) {
|
|
796
|
+
return Z(x(t, 0, 1)) + x(t, 1);
|
|
796
797
|
}
|
|
797
|
-
function
|
|
798
|
-
return
|
|
798
|
+
function we(t) {
|
|
799
|
+
return B(x(t, 0, 1)) + x(t, 1);
|
|
799
800
|
}
|
|
800
|
-
function
|
|
801
|
+
function at(t) {
|
|
801
802
|
return t.split(new RegExp("(?=\\p{Lu})", "u")).filter(Boolean);
|
|
802
803
|
}
|
|
803
|
-
function
|
|
804
|
+
function ut(t, e = ` \r
|
|
804
805
|
\f\v`) {
|
|
805
|
-
const n = S(e) ? e.join("") : e, r = (
|
|
806
|
-
return t.replace(c, (
|
|
806
|
+
const n = S(e) ? e.join("") : e, r = (l) => l.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&"), s = n.length ? r(n) : "", o = s.length ? `(?:\\s|[${s}])` : "\\s", c = new RegExp(`(^|${o})(\\p{Ll})`, "gu");
|
|
807
|
+
return t.replace(c, (l, f, i) => f + i.toUpperCase());
|
|
807
808
|
}
|
|
808
|
-
function
|
|
809
|
+
function Se(t, e = null) {
|
|
809
810
|
const n = e && e.length > 0 ? e.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&") : "", r = n.length > 0 ? new RegExp(`[\\p{L}\\p{N}${n}]+`, "gu") : /[\p{L}\p{N}]+/gu, s = t.match(r);
|
|
810
811
|
return s ? s.length : 0;
|
|
811
812
|
}
|
|
812
|
-
function
|
|
813
|
+
function z(t) {
|
|
814
|
+
return t.trim() === "";
|
|
815
|
+
}
|
|
816
|
+
function T(t, e, n) {
|
|
817
|
+
let r = e;
|
|
818
|
+
for (; r < n && z(t[r]); )
|
|
819
|
+
r++;
|
|
820
|
+
return r;
|
|
821
|
+
}
|
|
822
|
+
function pt(t, e, n) {
|
|
823
|
+
let r = n;
|
|
824
|
+
for (; r > e && z(t[r - 1]); )
|
|
825
|
+
r--;
|
|
826
|
+
return r;
|
|
827
|
+
}
|
|
828
|
+
function xe(t, e = 75, n = `
|
|
813
829
|
`, r = !1) {
|
|
814
830
|
if (t.length === 0 || e < 1 || n === "")
|
|
815
831
|
return t;
|
|
816
832
|
const s = t.split(/\r\n|\n|\r/), o = [];
|
|
817
833
|
for (const c of s) {
|
|
818
|
-
|
|
819
|
-
if (
|
|
834
|
+
const l = [...c], f = l.length;
|
|
835
|
+
if (f === 0) {
|
|
820
836
|
o.push("");
|
|
821
837
|
continue;
|
|
822
838
|
}
|
|
839
|
+
let i = 0;
|
|
823
840
|
if (r) {
|
|
824
|
-
for (; i
|
|
825
|
-
if (i
|
|
826
|
-
o.push(i);
|
|
841
|
+
for (; i < f && (i = T(l, i, f), i !== f); ) {
|
|
842
|
+
if (f - i <= e) {
|
|
843
|
+
o.push(l.slice(i, f).join(""));
|
|
827
844
|
break;
|
|
828
845
|
}
|
|
829
|
-
|
|
830
|
-
|
|
846
|
+
const m = pt(
|
|
847
|
+
l,
|
|
848
|
+
i,
|
|
849
|
+
i + e
|
|
850
|
+
);
|
|
851
|
+
o.push(l.slice(i, m).join("")), i += e;
|
|
831
852
|
}
|
|
832
853
|
continue;
|
|
833
854
|
}
|
|
834
|
-
for (; i
|
|
835
|
-
const
|
|
836
|
-
if (
|
|
855
|
+
for (; f - i > e; ) {
|
|
856
|
+
const m = T(l, i, f);
|
|
857
|
+
if (m !== i && (i = m, f - i <= e))
|
|
837
858
|
break;
|
|
838
|
-
const
|
|
839
|
-
let
|
|
840
|
-
for (let
|
|
841
|
-
if (
|
|
842
|
-
|
|
859
|
+
const p = Math.min(f, i + e + 1);
|
|
860
|
+
let g = -1;
|
|
861
|
+
for (let a = p - 1; a >= i; a--)
|
|
862
|
+
if (z(l[a])) {
|
|
863
|
+
g = a;
|
|
843
864
|
break;
|
|
844
865
|
}
|
|
845
|
-
if (
|
|
846
|
-
o.push(
|
|
866
|
+
if (g > i) {
|
|
867
|
+
o.push(l.slice(i, g).join("")), i = g + 1;
|
|
847
868
|
continue;
|
|
848
869
|
}
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
870
|
+
let u = -1;
|
|
871
|
+
for (let a = i; a < f; a++)
|
|
872
|
+
if (z(l[a])) {
|
|
873
|
+
u = a;
|
|
874
|
+
break;
|
|
875
|
+
}
|
|
876
|
+
if (u >= 0) {
|
|
877
|
+
o.push(l.slice(i, u).join("")), i = u + 1;
|
|
852
878
|
continue;
|
|
853
879
|
}
|
|
854
|
-
o.push(i), i =
|
|
880
|
+
o.push(l.slice(i, f).join("")), i = f;
|
|
855
881
|
break;
|
|
856
882
|
}
|
|
857
|
-
i
|
|
883
|
+
f - i > 0 && o.push(l.slice(i, f).join(""));
|
|
858
884
|
}
|
|
859
885
|
return o.join(n);
|
|
860
886
|
}
|
|
861
|
-
function
|
|
887
|
+
function $e() {
|
|
862
888
|
return R.size;
|
|
863
889
|
}
|
|
864
|
-
function
|
|
890
|
+
function ke() {
|
|
865
891
|
return C.size;
|
|
866
892
|
}
|
|
867
|
-
function
|
|
893
|
+
function Ae() {
|
|
868
894
|
return F.size;
|
|
869
895
|
}
|
|
870
|
-
function
|
|
896
|
+
function be() {
|
|
871
897
|
R.clear(), C.clear(), F.clear();
|
|
872
898
|
}
|
|
873
|
-
function
|
|
874
|
-
|
|
899
|
+
function Ee() {
|
|
900
|
+
st(), Y(), v();
|
|
875
901
|
}
|
|
876
902
|
export {
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
903
|
+
H as after,
|
|
904
|
+
$t as afterLast,
|
|
905
|
+
pe as apa,
|
|
906
|
+
tt as before,
|
|
907
|
+
et as beforeLast,
|
|
908
|
+
kt as between,
|
|
909
|
+
At as betweenFirst,
|
|
910
|
+
bt as camel,
|
|
911
|
+
ke as camelCacheSize,
|
|
912
|
+
Et as charAt,
|
|
913
|
+
Rt as chopEnd,
|
|
914
|
+
Lt as chopStart,
|
|
915
|
+
J as contains,
|
|
916
|
+
Ft as containsAll,
|
|
917
|
+
st as createRandomStringsNormally,
|
|
918
|
+
rt as createRandomStringsUsing,
|
|
919
|
+
vt as createRandomStringsUsingSequence,
|
|
920
|
+
Nt as deduplicate,
|
|
921
|
+
_t as doesntContain,
|
|
922
|
+
zt as doesntEndWith,
|
|
923
|
+
ge as doesntStartWith,
|
|
924
|
+
U as endsWith,
|
|
925
|
+
Ct as excerpt,
|
|
926
|
+
Ot as finish,
|
|
927
|
+
be as flushCache,
|
|
928
|
+
ae as headline,
|
|
929
|
+
ue as initials,
|
|
930
|
+
Ut as is,
|
|
931
|
+
Pt as isAscii,
|
|
932
|
+
It as isJson,
|
|
933
|
+
Jt as isMatch,
|
|
934
|
+
qt as isUrl,
|
|
935
|
+
jt as kebab,
|
|
936
|
+
ft as lcfirst,
|
|
911
937
|
_ as length,
|
|
912
|
-
|
|
913
|
-
|
|
938
|
+
Gt as limit,
|
|
939
|
+
Z as lower,
|
|
914
940
|
N as makePad,
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
941
|
+
Bt as mask,
|
|
942
|
+
Ht as match,
|
|
943
|
+
Zt as matchAll,
|
|
944
|
+
Kt as numbers,
|
|
945
|
+
Dt as padBoth,
|
|
946
|
+
Qt as padLeft,
|
|
947
|
+
Vt as padRight,
|
|
948
|
+
he as pascal,
|
|
949
|
+
Xt as password,
|
|
950
|
+
Yt as position,
|
|
951
|
+
nt as random,
|
|
952
|
+
ce as remove,
|
|
953
|
+
te as repeat,
|
|
954
|
+
re as replace,
|
|
955
|
+
ee as replaceArray,
|
|
956
|
+
oe as replaceEnd,
|
|
957
|
+
ot as replaceFirst,
|
|
958
|
+
it as replaceLast,
|
|
959
|
+
ie as replaceMatches,
|
|
960
|
+
se as replaceStart,
|
|
961
|
+
Ee as resetFactoryState,
|
|
962
|
+
le as reverse,
|
|
963
|
+
lt as snake,
|
|
964
|
+
$e as snakeCacheSize,
|
|
965
|
+
me as squish,
|
|
966
|
+
fe as start,
|
|
967
|
+
P as startsWith,
|
|
968
|
+
ct as stripTags,
|
|
969
|
+
K as studly,
|
|
970
|
+
Ae as studlyCacheSize,
|
|
971
|
+
de as swap,
|
|
972
|
+
ye as take,
|
|
973
|
+
ne as toStringOr,
|
|
974
|
+
we as ucfirst,
|
|
975
|
+
at as ucsplit,
|
|
976
|
+
ut as ucwords,
|
|
977
|
+
Mt as unwrap,
|
|
978
|
+
Se as wordCount,
|
|
979
|
+
xe as wordWrap,
|
|
980
|
+
Tt as words,
|
|
981
|
+
Wt as wrap
|
|
956
982
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tolki/str",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Utilities for working with strings similar to Laravel's Str & Stringable classes.",
|
|
5
5
|
"author": "Abraham Arango <https://github.com/abetwothree>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"transliteration": "^2.6.0",
|
|
37
37
|
"ulid": "^2.4.0",
|
|
38
38
|
"uuid": "^11.1.0",
|
|
39
|
-
"@tolki/num": "^2.2.
|
|
40
|
-
"@tolki/utils": "^1.0
|
|
39
|
+
"@tolki/num": "^2.2.2",
|
|
40
|
+
"@tolki/utils": "^1.1.0"
|
|
41
41
|
},
|
|
42
42
|
"files": [
|
|
43
43
|
"dist"
|