@tolki/str 1.0.3 → 1.0.5
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/dist/base64/index.js +85 -83
- package/dist/str.d.ts.map +1 -1
- package/dist/str.js +115 -114
- package/package.json +4 -18
package/dist/base64/index.js
CHANGED
|
@@ -1,124 +1,126 @@
|
|
|
1
|
-
import { isFunction as
|
|
2
|
-
function
|
|
3
|
-
const
|
|
4
|
-
if (
|
|
5
|
-
return
|
|
6
|
-
if (
|
|
1
|
+
import { isFunction as u } from "@tolki/utils";
|
|
2
|
+
function T(o) {
|
|
3
|
+
const n = g();
|
|
4
|
+
if (n.Buffer && u(n.Buffer.from))
|
|
5
|
+
return n.Buffer.from(o, "utf8").toString("base64");
|
|
6
|
+
if (u(n.btoa))
|
|
7
7
|
try {
|
|
8
|
-
const
|
|
9
|
-
return
|
|
8
|
+
const e = d(o);
|
|
9
|
+
return n.btoa(e);
|
|
10
10
|
} catch {
|
|
11
|
-
return
|
|
11
|
+
return n.btoa(o);
|
|
12
12
|
}
|
|
13
|
-
const
|
|
14
|
-
return
|
|
13
|
+
const t = d(o);
|
|
14
|
+
return b(t);
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
const
|
|
18
|
-
if (
|
|
19
|
-
return
|
|
20
|
-
let
|
|
21
|
-
for (let
|
|
22
|
-
|
|
23
|
-
return
|
|
16
|
+
function w(o) {
|
|
17
|
+
const n = g();
|
|
18
|
+
if (n.Buffer && u(n.Buffer.from))
|
|
19
|
+
return n.Buffer.from(o).toString("base64");
|
|
20
|
+
let t = "";
|
|
21
|
+
for (let e = 0; e < o.length; e++)
|
|
22
|
+
t += String.fromCharCode(o[e]);
|
|
23
|
+
return u(n.btoa) ? n.btoa(t) : b(t);
|
|
24
24
|
}
|
|
25
|
-
function y(
|
|
26
|
-
const
|
|
27
|
-
let
|
|
28
|
-
if (
|
|
29
|
-
const
|
|
30
|
-
if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(
|
|
25
|
+
function y(o, n = !1) {
|
|
26
|
+
const t = g();
|
|
27
|
+
let e = String(o);
|
|
28
|
+
if (n) {
|
|
29
|
+
const r = e.replace(/\s+/g, "");
|
|
30
|
+
if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(r))
|
|
31
31
|
return !1;
|
|
32
|
-
|
|
32
|
+
e = r;
|
|
33
33
|
} else
|
|
34
|
-
|
|
35
|
-
if (
|
|
34
|
+
e = e.replace(/[^A-Za-z0-9+/=]/g, "");
|
|
35
|
+
if (t.Buffer && u(t.Buffer.from))
|
|
36
36
|
try {
|
|
37
|
-
return
|
|
37
|
+
return t.Buffer.from(e, "base64").toString("utf8");
|
|
38
38
|
} catch {
|
|
39
39
|
return !1;
|
|
40
40
|
}
|
|
41
|
-
if (
|
|
41
|
+
if (u(t.atob))
|
|
42
42
|
try {
|
|
43
|
-
const
|
|
44
|
-
if (typeof
|
|
45
|
-
const
|
|
46
|
-
for (let a = 0; a <
|
|
47
|
-
|
|
48
|
-
return new
|
|
43
|
+
const r = t.atob(e);
|
|
44
|
+
if (typeof t.TextDecoder == "function") {
|
|
45
|
+
const c = new Uint8Array(r.length);
|
|
46
|
+
for (let a = 0; a < r.length; a++)
|
|
47
|
+
c[a] = r.charCodeAt(a);
|
|
48
|
+
return new t.TextDecoder("utf-8").decode(c);
|
|
49
49
|
}
|
|
50
|
-
let
|
|
51
|
-
for (let
|
|
52
|
-
|
|
53
|
-
return decodeURIComponent(
|
|
50
|
+
let f = "";
|
|
51
|
+
for (let c = 0; c < r.length; c++)
|
|
52
|
+
f += "%" + r.charCodeAt(c).toString(16).padStart(2, "0");
|
|
53
|
+
return decodeURIComponent(f);
|
|
54
54
|
} catch {
|
|
55
55
|
return !1;
|
|
56
56
|
}
|
|
57
57
|
try {
|
|
58
|
-
const
|
|
59
|
-
return
|
|
58
|
+
const r = C(e);
|
|
59
|
+
return B(r);
|
|
60
60
|
} catch {
|
|
61
61
|
return !1;
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
function
|
|
64
|
+
function g() {
|
|
65
65
|
return globalThis;
|
|
66
66
|
}
|
|
67
|
-
function d(
|
|
68
|
-
return encodeURIComponent(
|
|
67
|
+
function d(o) {
|
|
68
|
+
return encodeURIComponent(o).replace(
|
|
69
69
|
/%([0-9A-F]{2})/g,
|
|
70
|
-
(
|
|
70
|
+
(n, t) => String.fromCharCode(parseInt(t, 16))
|
|
71
71
|
);
|
|
72
72
|
}
|
|
73
|
-
function
|
|
74
|
-
const
|
|
75
|
-
let
|
|
76
|
-
for (let
|
|
77
|
-
const
|
|
78
|
-
isNaN(
|
|
73
|
+
function b(o) {
|
|
74
|
+
const n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
75
|
+
let t = "";
|
|
76
|
+
for (let e = 0; e < o.length; e += 3) {
|
|
77
|
+
const r = o.charCodeAt(e), f = o.charCodeAt(e + 1), c = o.charCodeAt(e + 2), a = (r ?? 0) << 16 | (f ?? 0) << 8 | (c ?? 0), i = a >> 18 & 63, s = a >> 12 & 63, l = a >> 6 & 63, h = a & 63;
|
|
78
|
+
isNaN(f) ? t += n.charAt(i) + n.charAt(s) + "==" : isNaN(c) ? t += n.charAt(i) + n.charAt(s) + n.charAt(l) + "=" : t += n.charAt(i) + n.charAt(s) + n.charAt(l) + n.charAt(h);
|
|
79
79
|
}
|
|
80
|
-
return
|
|
80
|
+
return t;
|
|
81
81
|
}
|
|
82
|
-
function
|
|
83
|
-
const
|
|
84
|
-
for (let
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
for (
|
|
88
|
-
|
|
89
|
-
|
|
82
|
+
function C(o) {
|
|
83
|
+
const n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", t = /* @__PURE__ */ new Map();
|
|
84
|
+
for (let c = 0; c < n.length; c++)
|
|
85
|
+
t.set(n[c], c);
|
|
86
|
+
let e = o.length;
|
|
87
|
+
for (; e > 0 && o[e - 1] === "="; ) e--;
|
|
88
|
+
const r = o.slice(0, e), f = [];
|
|
89
|
+
for (let c = 0; c < r.length; c += 4) {
|
|
90
|
+
const a = t.has(r[c]) ? t.get(r[c]) : 64, i = t.has(r[c + 1]) ? t.get(r[c + 1]) : 64, s = t.has(r[c + 2]) ? t.get(r[c + 2]) : 64, l = t.has(r[c + 3]) ? t.get(r[c + 3]) : 64, h = a << 18 | i << 12 | (s & 63) << 6 | l & 63, p = h >> 16 & 255, A = h >> 8 & 255, m = h & 255;
|
|
91
|
+
f.push(p), s !== 64 && f.push(A), l !== 64 && f.push(m);
|
|
90
92
|
}
|
|
91
|
-
return
|
|
93
|
+
return f;
|
|
92
94
|
}
|
|
93
|
-
function
|
|
94
|
-
const
|
|
95
|
-
if (typeof
|
|
96
|
-
return new
|
|
97
|
-
let
|
|
98
|
-
for (let
|
|
99
|
-
const
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
else if (
|
|
103
|
-
const
|
|
104
|
-
|
|
105
|
-
} else if (
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
(
|
|
95
|
+
function B(o) {
|
|
96
|
+
const n = g();
|
|
97
|
+
if (typeof n.TextDecoder == "function")
|
|
98
|
+
return new n.TextDecoder("utf-8").decode(new Uint8Array(o));
|
|
99
|
+
let t = "";
|
|
100
|
+
for (let e = 0; e < o.length; ) {
|
|
101
|
+
const r = o[e++];
|
|
102
|
+
if (r < 128)
|
|
103
|
+
t += String.fromCharCode(r);
|
|
104
|
+
else if (r < 224) {
|
|
105
|
+
const f = o[e++];
|
|
106
|
+
t += String.fromCharCode((r & 31) << 6 | f & 63);
|
|
107
|
+
} else if (r < 240) {
|
|
108
|
+
const f = o[e++], c = o[e++];
|
|
109
|
+
t += String.fromCharCode(
|
|
110
|
+
(r & 15) << 12 | (f & 63) << 6 | c & 63
|
|
109
111
|
);
|
|
110
112
|
} else {
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
+
const f = o[e++], c = o[e++], a = o[e++], s = ((r & 7) << 18 | (f & 63) << 12 | (c & 63) << 6 | a & 63) - 65536;
|
|
114
|
+
t += String.fromCharCode(
|
|
113
115
|
55296 + (s >> 10 & 1023),
|
|
114
116
|
56320 + (s & 1023)
|
|
115
117
|
);
|
|
116
118
|
}
|
|
117
119
|
}
|
|
118
|
-
return
|
|
120
|
+
return t;
|
|
119
121
|
}
|
|
120
122
|
export {
|
|
121
|
-
|
|
123
|
+
w as bytesToBase64,
|
|
122
124
|
y as fromBase64,
|
|
123
|
-
|
|
125
|
+
T as toBase64
|
|
124
126
|
};
|
package/dist/str.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"str.d.ts","sourceRoot":"","sources":["../src/str.ts"],"names":[],"mappings":"AAgCA;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAatE;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAY1E;AAED;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAQvE;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAY3E;AAED;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CACnB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,EAAE,EAAE,MAAM,GAAG,MAAM,GACpB,MAAM,CAMR;AAED;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BAAgB,OAAO,CACnB,KAAK,EAAE,MAAM,EACb,UAAU,GAAE,MAAM,GAAG,MAAM,EAAkB,GAC9C,MAAM,CAcR;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CACrB,KAAK,EAAE,MAAM,EACb,UAAU,GAAE,MAAM,GAAG,IAAW,GACjC,MAAM,CAcR;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,QAAQ,CACpB,KAAK,EAAE,MAAM,EACb,UAAU,GAAE,MAAW,EACvB,QAAQ,GAAE,MAAa,EACvB,YAAY,GAAE,OAAe,GAC9B,MAAM,CAqFR;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"}
|
package/dist/str.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { substr as x, ltrim as I, rtrim as q, randomInt as O, title as G, trim as K, upper as Z, randomString as D } from "@tolki/str";
|
|
2
2
|
import { isArray as S, toLower as W, isString as _, isFunction as Q, isNumber as V } from "@tolki/utils";
|
|
3
|
-
const
|
|
4
|
-
let
|
|
3
|
+
const R = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map(), F = /* @__PURE__ */ new Map();
|
|
4
|
+
let L = null;
|
|
5
5
|
function T(t, e) {
|
|
6
6
|
if (e === "")
|
|
7
7
|
return t;
|
|
@@ -35,7 +35,7 @@ function pt(t, e, n) {
|
|
|
35
35
|
function gt(t) {
|
|
36
36
|
if (C.has(t))
|
|
37
37
|
return C.get(t);
|
|
38
|
-
const e = st(
|
|
38
|
+
const e = st(J(t));
|
|
39
39
|
return C.set(t, e), e;
|
|
40
40
|
}
|
|
41
41
|
function mt(t, e) {
|
|
@@ -71,10 +71,10 @@ function yt(t, e = "", n = {}) {
|
|
|
71
71
|
const { radius: r = 100, omission: s = "..." } = n, o = String(t ?? ""), c = e ?? "", i = ($) => $.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), l = new RegExp(`^(.*?)(${i(c)})(.*)$`, "iu").exec(o);
|
|
72
72
|
if (!l)
|
|
73
73
|
return null;
|
|
74
|
-
const
|
|
74
|
+
const p = String(l[1]), a = String(l[2]), g = String(l[3]), u = I(p), m = Array.from(u).length, y = x(u, Math.max(m - r, 0), r);
|
|
75
75
|
let w = I(y);
|
|
76
76
|
w !== u && (w = s + w);
|
|
77
|
-
const h = q(
|
|
77
|
+
const h = q(g), d = x(h, 0, r);
|
|
78
78
|
let k = q(d);
|
|
79
79
|
return k !== h && (k = k + s), w + a + k;
|
|
80
80
|
}
|
|
@@ -112,9 +112,9 @@ function At(t, e, n = null) {
|
|
|
112
112
|
return e + t + (n ?? e);
|
|
113
113
|
}
|
|
114
114
|
function bt(t, e, n = null) {
|
|
115
|
-
return
|
|
115
|
+
return U(t, e) && (t = x(t, z(e))), M(t, n ??= e) && (t = x(t, 0, -z(n))), t;
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function Et(t, e, n = !1) {
|
|
118
118
|
e = String(e);
|
|
119
119
|
let r;
|
|
120
120
|
typeof t == "string" ? r = [t] : r = Array.from(t);
|
|
@@ -128,13 +128,13 @@ function Lt(t, e, n = !1) {
|
|
|
128
128
|
}
|
|
129
129
|
return !1;
|
|
130
130
|
}
|
|
131
|
-
function
|
|
131
|
+
function Lt(t) {
|
|
132
132
|
for (let e = 0; e < t.length; e++)
|
|
133
133
|
if (t.charCodeAt(e) > 127)
|
|
134
134
|
return !1;
|
|
135
135
|
return !0;
|
|
136
136
|
}
|
|
137
|
-
function
|
|
137
|
+
function Rt(t) {
|
|
138
138
|
if (!_(t))
|
|
139
139
|
return !1;
|
|
140
140
|
try {
|
|
@@ -149,8 +149,8 @@ function Ct(t, e = []) {
|
|
|
149
149
|
return !1;
|
|
150
150
|
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("|");
|
|
151
151
|
try {
|
|
152
|
-
const
|
|
153
|
-
if (r.split("|").includes(c))
|
|
152
|
+
const o = new URL(t), c = o.protocol.replace(":", ""), i = o.hostname, l = t.slice(t.indexOf("://") + 3).startsWith("/"), p = i.length > 0 && !/^\.+$/.test(i) && !l, a = c === "file" && l;
|
|
153
|
+
if (r.split("|").includes(c) && (p || a))
|
|
154
154
|
return !0;
|
|
155
155
|
} catch {
|
|
156
156
|
}
|
|
@@ -160,7 +160,7 @@ function Ct(t, e = []) {
|
|
|
160
160
|
"):\\/\\/",
|
|
161
161
|
"(?:((?:[_.\\p{L}\\p{N}-]|%[0-9A-Fa-f]{2})+:)?((?:[_.\\p{L}\\p{N}-]|%[0-9A-Fa-f]{2})+)@)?",
|
|
162
162
|
"(",
|
|
163
|
-
"(?:[\\p{L}\\p{N}\\p{S}_
|
|
163
|
+
"(?:(?:xn--[a-z0-9-]+\\.)*xn--[a-z0-9-]+|(?:[\\p{L}\\p{N}\\p{S}\\p{M}_-]+\\.)+[\\p{L}\\p{N}\\p{M}]+|[a-z0-9_-]+)\\.?",
|
|
164
164
|
"|",
|
|
165
165
|
"(?:\\d{1,3}\\.){3}\\d{1,3}",
|
|
166
166
|
"|",
|
|
@@ -172,19 +172,15 @@ function Ct(t, e = []) {
|
|
|
172
172
|
'(?:#(?:[\\p{L}\\p{N}\\-._~!$&"()*,;=:@/?]|%[0-9A-Fa-f]{2})*)?',
|
|
173
173
|
"$"
|
|
174
174
|
].join("");
|
|
175
|
-
|
|
176
|
-
return new RegExp(s, "iu").test(t);
|
|
177
|
-
} catch {
|
|
178
|
-
return !1;
|
|
179
|
-
}
|
|
175
|
+
return new RegExp(s, "iu").test(t);
|
|
180
176
|
}
|
|
181
177
|
function Ft(t) {
|
|
182
178
|
return rt(t, "-");
|
|
183
179
|
}
|
|
184
|
-
function
|
|
180
|
+
function z(t) {
|
|
185
181
|
return t.length;
|
|
186
182
|
}
|
|
187
|
-
function
|
|
183
|
+
function zt(t, e = 100, n = "...", r = !1) {
|
|
188
184
|
if (t.length <= e)
|
|
189
185
|
return t;
|
|
190
186
|
if (!r)
|
|
@@ -193,14 +189,14 @@ function Nt(t, e = 100, n = "...", r = !1) {
|
|
|
193
189
|
const s = t.slice(0, e).replace(/\s+$/, "");
|
|
194
190
|
return t.substring(e, e + 1) === " " ? s + n : s.replace(/(.*)\s.*/, "$1") + n;
|
|
195
191
|
}
|
|
196
|
-
function
|
|
192
|
+
function H(t) {
|
|
197
193
|
return W(t);
|
|
198
194
|
}
|
|
199
|
-
function
|
|
195
|
+
function Nt(t, e = 100, n = "...") {
|
|
200
196
|
if (e <= 0)
|
|
201
197
|
return t;
|
|
202
198
|
const r = e, s = new RegExp(`^\\s*(?:\\S+\\s*){1,${r}}`, "u"), o = t.match(s);
|
|
203
|
-
return !o ||
|
|
199
|
+
return !o || z(t) === z(o[0]) ? t : o[0].trimEnd() + n;
|
|
204
200
|
}
|
|
205
201
|
function _t(t, e, n, r = null) {
|
|
206
202
|
if (e === "")
|
|
@@ -314,31 +310,31 @@ function Mt(t, e) {
|
|
|
314
310
|
}
|
|
315
311
|
return s;
|
|
316
312
|
}
|
|
317
|
-
function
|
|
313
|
+
function Ut(t) {
|
|
318
314
|
return S(t) ? t.map((e) => e.replace(/[^0-9]/g, "")) : t.replace(/[^0-9]/g, "");
|
|
319
315
|
}
|
|
320
|
-
function
|
|
316
|
+
function Pt(t, e, n = " ") {
|
|
321
317
|
const r = t.length;
|
|
322
318
|
if (e <= r || n === "")
|
|
323
319
|
return t;
|
|
324
320
|
const s = e - r, o = Math.floor(s / 2), c = s - o;
|
|
325
|
-
return
|
|
321
|
+
return N(n, o) + t + N(n, c);
|
|
326
322
|
}
|
|
327
323
|
function It(t, e, n = " ") {
|
|
328
324
|
const r = t.length;
|
|
329
325
|
if (e <= r || n === "")
|
|
330
326
|
return t;
|
|
331
327
|
const o = e - r;
|
|
332
|
-
return
|
|
328
|
+
return N(n, o) + t;
|
|
333
329
|
}
|
|
334
330
|
function qt(t, e, n = " ") {
|
|
335
331
|
const r = t.length;
|
|
336
332
|
if (e <= r || n === "")
|
|
337
333
|
return t;
|
|
338
334
|
const o = e - r;
|
|
339
|
-
return t +
|
|
335
|
+
return t + N(n, o);
|
|
340
336
|
}
|
|
341
|
-
function
|
|
337
|
+
function N(t, e) {
|
|
342
338
|
if (e <= 0 || t.length === 0)
|
|
343
339
|
return "";
|
|
344
340
|
const n = Math.ceil(e / t.length);
|
|
@@ -433,21 +429,21 @@ function Gt(t = 32, e = !0, n = !0, r = !0, s = !1) {
|
|
|
433
429
|
].filter((u) => S(u));
|
|
434
430
|
if (l.length === 0 || t <= 0)
|
|
435
431
|
return "";
|
|
436
|
-
const
|
|
432
|
+
const p = [];
|
|
437
433
|
for (const u of l) {
|
|
438
|
-
const
|
|
439
|
-
|
|
434
|
+
const m = O(0, u.length - 1);
|
|
435
|
+
p.push(u[m]);
|
|
440
436
|
}
|
|
441
|
-
const a = Math.max(0, t -
|
|
437
|
+
const a = Math.max(0, t - p.length), g = l.flat();
|
|
442
438
|
for (let u = 0; u < a; u++) {
|
|
443
|
-
const
|
|
444
|
-
|
|
439
|
+
const m = O(0, g.length - 1);
|
|
440
|
+
p.push(g[m]);
|
|
445
441
|
}
|
|
446
|
-
for (let u =
|
|
447
|
-
const
|
|
448
|
-
|
|
442
|
+
for (let u = p.length - 1; u > 0; u--) {
|
|
443
|
+
const m = O(0, u), y = p[u];
|
|
444
|
+
p[u] = p[m], p[m] = y;
|
|
449
445
|
}
|
|
450
|
-
return
|
|
446
|
+
return p.join("");
|
|
451
447
|
}
|
|
452
448
|
function Tt(t, e, n = 0) {
|
|
453
449
|
if (e === "")
|
|
@@ -470,25 +466,25 @@ function Tt(t, e, n = 0) {
|
|
|
470
466
|
return !1;
|
|
471
467
|
}
|
|
472
468
|
function j(t = 16) {
|
|
473
|
-
return (
|
|
469
|
+
return (L ?? ((n) => D(n)))(t);
|
|
474
470
|
}
|
|
475
471
|
function v(t) {
|
|
476
|
-
|
|
472
|
+
L = t;
|
|
477
473
|
}
|
|
478
474
|
function Bt(t, e) {
|
|
479
475
|
let n = 0;
|
|
480
476
|
const r = e ?? function(s) {
|
|
481
|
-
const o =
|
|
482
|
-
|
|
477
|
+
const o = L;
|
|
478
|
+
L = null;
|
|
483
479
|
const c = j(s);
|
|
484
|
-
return
|
|
480
|
+
return L = o, n++, c;
|
|
485
481
|
};
|
|
486
482
|
v((s) => n < t.length ? String(t[n++]) : r(s));
|
|
487
483
|
}
|
|
488
|
-
function
|
|
489
|
-
|
|
484
|
+
function Ht() {
|
|
485
|
+
L = null;
|
|
490
486
|
}
|
|
491
|
-
function
|
|
487
|
+
function Jt(t, e) {
|
|
492
488
|
return e <= 0 ? "" : t.repeat(e);
|
|
493
489
|
}
|
|
494
490
|
function Kt(t, e, n) {
|
|
@@ -515,13 +511,13 @@ function Zt(t, e) {
|
|
|
515
511
|
}
|
|
516
512
|
}
|
|
517
513
|
function Dt(t, e, n, r = !0) {
|
|
518
|
-
const s = (l) => typeof l == "string" ? [l] : Array.from(l), o = s(t), c = s(e), i = (l) => l.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = (l) => o.reduce((
|
|
519
|
-
if (a === "") return
|
|
520
|
-
const u = c[
|
|
514
|
+
const s = (l) => typeof l == "string" ? [l] : Array.from(l), o = s(t), c = s(e), i = (l) => l.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = (l) => o.reduce((p, a, g) => {
|
|
515
|
+
if (a === "") return p;
|
|
516
|
+
const u = c[g] ?? "";
|
|
521
517
|
if (!r)
|
|
522
|
-
return
|
|
523
|
-
const
|
|
524
|
-
return
|
|
518
|
+
return p.split(a).join(u);
|
|
519
|
+
const m = new RegExp(i(a), "gi");
|
|
520
|
+
return p.replace(m, () => u);
|
|
525
521
|
}, l);
|
|
526
522
|
return _(n) ? f(n) : Array.from(n).map(f);
|
|
527
523
|
}
|
|
@@ -532,7 +528,7 @@ function tt(t, e, n) {
|
|
|
532
528
|
return r !== -1 ? n.slice(0, r) + e + n.slice(r + t.length) : n;
|
|
533
529
|
}
|
|
534
530
|
function Qt(t, e, n) {
|
|
535
|
-
return t = String(t), t === "" ? n :
|
|
531
|
+
return t = String(t), t === "" ? n : U(n, t) ? tt(t, e, n) : n;
|
|
536
532
|
}
|
|
537
533
|
function et(t, e, n) {
|
|
538
534
|
if (t = String(t), t === "")
|
|
@@ -548,32 +544,32 @@ function Xt(t, e, n, r = -1) {
|
|
|
548
544
|
function c(a) {
|
|
549
545
|
try {
|
|
550
546
|
if (a instanceof RegExp) {
|
|
551
|
-
let
|
|
552
|
-
return
|
|
547
|
+
let m = a.flags;
|
|
548
|
+
return m.includes("g") || (m += "g"), m.includes("u") || (m += "u"), new RegExp(a.source, m);
|
|
553
549
|
}
|
|
554
|
-
let
|
|
550
|
+
let g = a, u = "gu";
|
|
555
551
|
if (a.length >= 2 && a[0] === "/") {
|
|
556
|
-
let
|
|
552
|
+
let m = -1;
|
|
557
553
|
for (let y = a.length - 1; y > 0; y--)
|
|
558
554
|
if (a[y] === "/") {
|
|
559
555
|
let w = 0;
|
|
560
556
|
for (let h = y - 1; h >= 0 && a[h] === "\\"; h--)
|
|
561
557
|
w++;
|
|
562
558
|
if (w % 2 === 0) {
|
|
563
|
-
|
|
559
|
+
m = y;
|
|
564
560
|
break;
|
|
565
561
|
}
|
|
566
562
|
}
|
|
567
|
-
if (
|
|
568
|
-
|
|
569
|
-
const y = a.slice(
|
|
563
|
+
if (m > 1) {
|
|
564
|
+
g = a.slice(1, m);
|
|
565
|
+
const y = a.slice(m + 1);
|
|
570
566
|
if (y)
|
|
571
567
|
for (const w of y)
|
|
572
568
|
/[imsuy]/.test(w) && !u.includes(w) && (u += w);
|
|
573
569
|
}
|
|
574
570
|
}
|
|
575
571
|
return new RegExp(
|
|
576
|
-
|
|
572
|
+
g,
|
|
577
573
|
Array.from(new Set(u.split(""))).join("")
|
|
578
574
|
);
|
|
579
575
|
} catch {
|
|
@@ -582,59 +578,64 @@ function Xt(t, e, n, r = -1) {
|
|
|
582
578
|
}
|
|
583
579
|
const i = [];
|
|
584
580
|
for (const a of o) {
|
|
585
|
-
const
|
|
586
|
-
if (!
|
|
587
|
-
i.push(
|
|
581
|
+
const g = c(a);
|
|
582
|
+
if (!g) return null;
|
|
583
|
+
i.push(g);
|
|
588
584
|
}
|
|
589
|
-
const f = Q(e), l = f ? [] : s(e),
|
|
590
|
-
let
|
|
585
|
+
const f = Q(e), l = f ? [] : s(e), p = (a) => {
|
|
586
|
+
let g = a;
|
|
591
587
|
for (let u = 0; u < i.length; u++) {
|
|
592
|
-
const
|
|
588
|
+
const m = i[u];
|
|
593
589
|
if (f) {
|
|
594
590
|
let y = 0;
|
|
595
591
|
const w = e;
|
|
596
|
-
|
|
597
|
-
|
|
592
|
+
g = g.replace(
|
|
593
|
+
m,
|
|
598
594
|
(h, ...d) => {
|
|
599
595
|
if (r >= 0 && y >= r) return h;
|
|
600
596
|
y++;
|
|
601
597
|
const b = d.length > 0 && d[d.length - 1] !== null && typeof d[d.length - 1] == "object" ? d.length - 3 : d.length - 2, $ = [];
|
|
602
598
|
for (let A = 0; A < b; A++)
|
|
603
599
|
$.push(d[A]);
|
|
604
|
-
const
|
|
605
|
-
return w(
|
|
600
|
+
const E = [h, ...$];
|
|
601
|
+
return w(E);
|
|
606
602
|
}
|
|
607
603
|
);
|
|
608
604
|
} else {
|
|
609
605
|
const y = l[u] ?? (l.length === 1 ? l[0] : "");
|
|
610
606
|
if (r < 0)
|
|
611
|
-
|
|
607
|
+
g = g.replace(m, (w, ...h) => {
|
|
612
608
|
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($));
|
|
613
|
-
return y.replace(/\$(\d{1,2})/g, ($,
|
|
614
|
-
const A = parseInt(
|
|
609
|
+
return y.replace(/\$(\d{1,2})/g, ($, E) => {
|
|
610
|
+
const A = parseInt(E, 10);
|
|
615
611
|
return (b[A - 1] ?? "").toUpperCase();
|
|
616
612
|
});
|
|
617
613
|
});
|
|
618
614
|
else {
|
|
619
615
|
let w = 0;
|
|
620
|
-
|
|
616
|
+
g = g.replace(m, (h, ...d) => {
|
|
621
617
|
if (w >= r) return h;
|
|
622
618
|
w++;
|
|
623
|
-
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((
|
|
624
|
-
return y.replace(/\$(\d{1,2})/g, (
|
|
625
|
-
const
|
|
626
|
-
return ($[
|
|
619
|
+
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));
|
|
620
|
+
return y.replace(/\$(\d{1,2})/g, (E, A) => {
|
|
621
|
+
const P = parseInt(A, 10);
|
|
622
|
+
return ($[P - 1] ?? "").toUpperCase();
|
|
627
623
|
});
|
|
628
624
|
});
|
|
629
625
|
}
|
|
630
626
|
}
|
|
631
627
|
}
|
|
632
|
-
return
|
|
628
|
+
return g;
|
|
633
629
|
};
|
|
634
|
-
return S(n) ? n.map(
|
|
630
|
+
return S(n) ? n.map(p) : p(n);
|
|
635
631
|
}
|
|
636
632
|
function nt(t) {
|
|
637
|
-
|
|
633
|
+
let e = "", n = !1;
|
|
634
|
+
for (let r = 0; r < t.length; r++) {
|
|
635
|
+
const s = t[r];
|
|
636
|
+
s === "<" ? n = !0 : s === ">" ? n = !1 : n || (e += s);
|
|
637
|
+
}
|
|
638
|
+
return e;
|
|
638
639
|
}
|
|
639
640
|
function Yt(t, e, n = !0) {
|
|
640
641
|
const r = typeof t == "string" ? [t] : Array.from(t), s = (c) => c.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), o = (c) => {
|
|
@@ -723,15 +724,15 @@ function ee(t) {
|
|
|
723
724
|
}
|
|
724
725
|
function rt(t, e = "_") {
|
|
725
726
|
const r = `${t}|${e}`;
|
|
726
|
-
if (
|
|
727
|
-
return
|
|
727
|
+
if (R.has(r))
|
|
728
|
+
return R.get(r);
|
|
728
729
|
let s = t;
|
|
729
|
-
return /^[a-z]+$/.test(t) || (s = it(t).replace(/\s+/gu, ""), s = s.replace(/(.)(?=[A-Z])/g, `$1${e}`), s =
|
|
730
|
+
return /^[a-z]+$/.test(t) || (s = it(t).replace(/\s+/gu, ""), s = s.replace(/(.)(?=[A-Z])/g, `$1${e}`), s = H(s)), R.set(r, s), s;
|
|
730
731
|
}
|
|
731
732
|
function ne(t) {
|
|
732
733
|
return K(t).replace(/[\s\u3164\u1160]+/gu, " ");
|
|
733
734
|
}
|
|
734
|
-
function
|
|
735
|
+
function U(t, e) {
|
|
735
736
|
if (t == null || e == null)
|
|
736
737
|
return !1;
|
|
737
738
|
let n;
|
|
@@ -747,9 +748,9 @@ function P(t, e) {
|
|
|
747
748
|
return !1;
|
|
748
749
|
}
|
|
749
750
|
function re(t, e) {
|
|
750
|
-
return !
|
|
751
|
+
return !U(t, e);
|
|
751
752
|
}
|
|
752
|
-
function
|
|
753
|
+
function J(t) {
|
|
753
754
|
const e = t;
|
|
754
755
|
if (F.has(e))
|
|
755
756
|
return F.get(e);
|
|
@@ -761,7 +762,7 @@ function H(t) {
|
|
|
761
762
|
return F.set(e, o), o;
|
|
762
763
|
}
|
|
763
764
|
function se(t) {
|
|
764
|
-
return
|
|
765
|
+
return J(t);
|
|
765
766
|
}
|
|
766
767
|
function oe(t, e) {
|
|
767
768
|
if (!t || Object.keys(t).length === 0)
|
|
@@ -777,7 +778,7 @@ function ie(t, e) {
|
|
|
777
778
|
return e < 0 ? x(t, e) : x(t, 0, e);
|
|
778
779
|
}
|
|
779
780
|
function st(t) {
|
|
780
|
-
return
|
|
781
|
+
return H(x(t, 0, 1)) + x(t, 1);
|
|
781
782
|
}
|
|
782
783
|
function ce(t) {
|
|
783
784
|
return Z(x(t, 0, 1)) + x(t, 1);
|
|
@@ -808,7 +809,7 @@ function fe(t, e = 75, n = `
|
|
|
808
809
|
if (r) {
|
|
809
810
|
for (; i.length > 0 && !(/^\s/u.test(i) && (i = i.replace(/^\s+/u, ""), i.length === 0)); ) {
|
|
810
811
|
if (i.length <= e) {
|
|
811
|
-
o.push(i)
|
|
812
|
+
o.push(i);
|
|
812
813
|
break;
|
|
813
814
|
}
|
|
814
815
|
let f = i.slice(0, e);
|
|
@@ -821,14 +822,14 @@ function fe(t, e = 75, n = `
|
|
|
821
822
|
if (f.length !== i.length && (i = f, i.length <= e))
|
|
822
823
|
break;
|
|
823
824
|
const l = i.slice(0, e + 1);
|
|
824
|
-
let
|
|
825
|
-
for (let
|
|
826
|
-
if (/\s/u.test(l[
|
|
827
|
-
|
|
825
|
+
let p = -1;
|
|
826
|
+
for (let g = l.length - 1; g >= 0; g--)
|
|
827
|
+
if (/\s/u.test(l[g])) {
|
|
828
|
+
p = g;
|
|
828
829
|
break;
|
|
829
830
|
}
|
|
830
|
-
if (
|
|
831
|
-
o.push(i.slice(0,
|
|
831
|
+
if (p > 0) {
|
|
832
|
+
o.push(i.slice(0, p)), i = i.slice(p + 1);
|
|
832
833
|
continue;
|
|
833
834
|
}
|
|
834
835
|
const a = i.search(/\s/u);
|
|
@@ -844,7 +845,7 @@ function fe(t, e = 75, n = `
|
|
|
844
845
|
return o.join(n);
|
|
845
846
|
}
|
|
846
847
|
function ae() {
|
|
847
|
-
return
|
|
848
|
+
return R.size;
|
|
848
849
|
}
|
|
849
850
|
function ue() {
|
|
850
851
|
return C.size;
|
|
@@ -853,7 +854,7 @@ function pe() {
|
|
|
853
854
|
return F.size;
|
|
854
855
|
}
|
|
855
856
|
function ge() {
|
|
856
|
-
|
|
857
|
+
R.clear(), C.clear(), F.clear();
|
|
857
858
|
}
|
|
858
859
|
export {
|
|
859
860
|
T as after,
|
|
@@ -870,7 +871,7 @@ export {
|
|
|
870
871
|
ht as chopStart,
|
|
871
872
|
B as contains,
|
|
872
873
|
wt as containsAll,
|
|
873
|
-
|
|
874
|
+
Ht as createRandomStringsNormally,
|
|
874
875
|
v as createRandomStringsUsing,
|
|
875
876
|
Bt as createRandomStringsUsingSequence,
|
|
876
877
|
St as deduplicate,
|
|
@@ -882,22 +883,22 @@ export {
|
|
|
882
883
|
kt as finish,
|
|
883
884
|
ge as flushCache,
|
|
884
885
|
te as headline,
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
886
|
+
Et as is,
|
|
887
|
+
Lt as isAscii,
|
|
888
|
+
Rt as isJson,
|
|
888
889
|
Wt as isMatch,
|
|
889
890
|
Ct as isUrl,
|
|
890
891
|
Ft as kebab,
|
|
891
892
|
st as lcfirst,
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
893
|
+
z as length,
|
|
894
|
+
zt as limit,
|
|
895
|
+
H as lower,
|
|
896
|
+
N as makePad,
|
|
896
897
|
_t as mask,
|
|
897
898
|
Ot as match,
|
|
898
899
|
Mt as matchAll,
|
|
899
|
-
|
|
900
|
-
|
|
900
|
+
Ut as numbers,
|
|
901
|
+
Pt as padBoth,
|
|
901
902
|
It as padLeft,
|
|
902
903
|
qt as padRight,
|
|
903
904
|
se as pascal,
|
|
@@ -905,7 +906,7 @@ export {
|
|
|
905
906
|
Tt as position,
|
|
906
907
|
j as random,
|
|
907
908
|
Yt as remove,
|
|
908
|
-
|
|
909
|
+
Jt as repeat,
|
|
909
910
|
Dt as replace,
|
|
910
911
|
Kt as replaceArray,
|
|
911
912
|
Vt as replaceEnd,
|
|
@@ -918,9 +919,9 @@ export {
|
|
|
918
919
|
ae as snakeCacheSize,
|
|
919
920
|
ne as squish,
|
|
920
921
|
vt as start,
|
|
921
|
-
|
|
922
|
+
U as startsWith,
|
|
922
923
|
nt as stripTags,
|
|
923
|
-
|
|
924
|
+
J as studly,
|
|
924
925
|
pe as studlyCacheSize,
|
|
925
926
|
oe as swap,
|
|
926
927
|
ie as take,
|
|
@@ -931,6 +932,6 @@ export {
|
|
|
931
932
|
bt as unwrap,
|
|
932
933
|
le as wordCount,
|
|
933
934
|
fe as wordWrap,
|
|
934
|
-
|
|
935
|
+
Nt as words,
|
|
935
936
|
At as wrap
|
|
936
937
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tolki/str",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
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",
|
|
@@ -26,22 +26,6 @@
|
|
|
26
26
|
],
|
|
27
27
|
"sideEffects": false,
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@tolki/utils": "^1.0.0",
|
|
30
|
-
"@tolki/num": "^1.0.3"
|
|
31
|
-
},
|
|
32
|
-
"devDependencies": {
|
|
33
|
-
"@types/markdown-it": "^14.1.2",
|
|
34
|
-
"@types/pluralize": "^0.0.33",
|
|
35
|
-
"any-ascii": "^0.3.3",
|
|
36
|
-
"markdown-it": "^14.1.0",
|
|
37
|
-
"markdown-it-anchor": "^9.2.0",
|
|
38
|
-
"markdown-it-task-lists": "^2.1.1",
|
|
39
|
-
"pluralize": "^8.0.0",
|
|
40
|
-
"transliteration": "^2.6.0",
|
|
41
|
-
"ulid": "^2.4.0",
|
|
42
|
-
"uuid": "^11.1.0"
|
|
43
|
-
},
|
|
44
|
-
"peerDependencies": {
|
|
45
29
|
"@types/markdown-it": "^14.1.2",
|
|
46
30
|
"@types/pluralize": "^0.0.33",
|
|
47
31
|
"any-ascii": "^0.3.3",
|
|
@@ -51,7 +35,9 @@
|
|
|
51
35
|
"pluralize": "^8.0.0",
|
|
52
36
|
"transliteration": "^2.6.0",
|
|
53
37
|
"ulid": "^2.4.0",
|
|
54
|
-
"uuid": "^11.1.0"
|
|
38
|
+
"uuid": "^11.1.0",
|
|
39
|
+
"@tolki/num": "^2.0.0",
|
|
40
|
+
"@tolki/utils": "^1.0.2"
|
|
55
41
|
},
|
|
56
42
|
"files": [
|
|
57
43
|
"dist"
|