@tempots/std 0.10.7 → 0.12.0
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 +2 -0
- package/array.cjs +1 -1
- package/array.d.ts +357 -35
- package/array.js +148 -152
- package/async-result.cjs +1 -1
- package/async-result.d.ts +161 -23
- package/async-result.js +119 -13
- package/bigint.cjs +1 -1
- package/bigint.d.ts +155 -18
- package/bigint.js +37 -37
- package/boolean.cjs +1 -1
- package/boolean.d.ts +39 -7
- package/boolean.js +10 -10
- package/domain.d.ts +149 -5
- package/equal.d.ts +26 -0
- package/function.cjs +1 -1
- package/function.d.ts +24 -1
- package/function.js +15 -19
- package/index.cjs +1 -1
- package/index.d.ts +13 -0
- package/index.js +185 -1
- package/json.d.ts +20 -1
- package/number.d.ts +324 -55
- package/object.cjs +1 -1
- package/object.d.ts +53 -5
- package/object.js +15 -15
- package/package.json +26 -19
- package/regexp.cjs +1 -1
- package/regexp.d.ts +5 -4
- package/regexp.js +8 -8
- package/result-Czm7RKNP.js +230 -0
- package/result-DzdZiQoR.cjs +1 -0
- package/result.cjs +1 -1
- package/result.d.ts +132 -8
- package/result.js +3 -54
- package/string.cjs +4 -3
- package/string.d.ts +220 -10
- package/string.js +166 -160
- package/validation.cjs +1 -1
- package/validation.d.ts +72 -4
- package/validation.js +2 -23
- package/maybe.cjs +0 -1
- package/maybe.d.ts +0 -9
- package/maybe.js +0 -9
package/string.js
CHANGED
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
function
|
|
1
|
+
import { anyElement as l, allElements as C, generateArray as A, createFilledArray as S } from "./array.js";
|
|
2
|
+
import { mapRegExp as h } from "./regexp.js";
|
|
3
|
+
function c(n, t, r) {
|
|
4
4
|
return n.split(t).join(r);
|
|
5
5
|
}
|
|
6
6
|
function J(n, t) {
|
|
7
7
|
const r = n.indexOf(t);
|
|
8
8
|
return r < 0 ? "" : n.substring(r + t.length);
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function V(n, t) {
|
|
11
11
|
const r = n.lastIndexOf(t);
|
|
12
12
|
return r < 0 ? "" : n.substring(r + t.length);
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function X(n, t) {
|
|
15
15
|
const r = n.indexOf(t);
|
|
16
16
|
return r < 0 ? "" : n.substring(0, r);
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function Y(n, t) {
|
|
19
19
|
const r = n.lastIndexOf(t);
|
|
20
20
|
return r < 0 ? "" : n.substring(0, r);
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function p(n) {
|
|
23
23
|
return n.substring(0, 1).toUpperCase() + n.substring(1);
|
|
24
24
|
}
|
|
25
25
|
const d = (n) => n.toUpperCase();
|
|
26
|
-
function
|
|
27
|
-
return t ? p(
|
|
26
|
+
function v(n, t = !1) {
|
|
27
|
+
return t ? h(p(n), H, d) : h(p(n), R, d);
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
return n.replace(
|
|
29
|
+
function nn(n) {
|
|
30
|
+
return n.replace(Q, `
|
|
31
31
|
`);
|
|
32
32
|
}
|
|
33
|
-
function
|
|
33
|
+
function tn(n, t) {
|
|
34
34
|
return n == null && t == null ? 0 : n == null ? -1 : t == null ? 1 : y(n.toLowerCase(), t.toLowerCase());
|
|
35
35
|
}
|
|
36
36
|
function L(n, t) {
|
|
37
37
|
return n.substring(0, n.length - t.length) === t;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function rn(n, t) {
|
|
40
40
|
return n.substring(0, n.length - t.length).toLowerCase() === t.toLowerCase();
|
|
41
41
|
}
|
|
42
42
|
function W(n, t) {
|
|
43
43
|
return n.substring(0, t.length) === t;
|
|
44
44
|
}
|
|
45
|
-
function
|
|
45
|
+
function en(n, t) {
|
|
46
46
|
return n.substring(0, t.length).toLowerCase() === t.toLowerCase();
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
return
|
|
48
|
+
function on(n, t) {
|
|
49
|
+
return z(
|
|
50
50
|
n.toLowerCase(),
|
|
51
51
|
t.map((r) => r.toLowerCase())
|
|
52
52
|
);
|
|
53
53
|
}
|
|
54
|
-
function
|
|
55
|
-
return
|
|
54
|
+
function un(n, t) {
|
|
55
|
+
return N(
|
|
56
56
|
n.toLowerCase(),
|
|
57
57
|
t.map((r) => r.toLowerCase())
|
|
58
58
|
);
|
|
@@ -66,96 +66,97 @@ function y(n, t) {
|
|
|
66
66
|
function w(n, t) {
|
|
67
67
|
return n.toLowerCase().includes(t.toLowerCase());
|
|
68
68
|
}
|
|
69
|
-
function
|
|
69
|
+
function a(n, t) {
|
|
70
70
|
return n.includes(t);
|
|
71
71
|
}
|
|
72
|
-
function un(n, t) {
|
|
73
|
-
return n.split(t).length - 1;
|
|
74
|
-
}
|
|
75
72
|
function fn(n, t) {
|
|
76
|
-
return
|
|
73
|
+
return n.split(t).length - 1;
|
|
77
74
|
}
|
|
78
75
|
function cn(n, t) {
|
|
79
|
-
return
|
|
76
|
+
return l(t, (r) => w(n, r));
|
|
80
77
|
}
|
|
81
78
|
function ln(n, t) {
|
|
82
|
-
return
|
|
79
|
+
return l(t, (r) => a(n, r));
|
|
83
80
|
}
|
|
84
81
|
function an(n, t) {
|
|
85
|
-
return
|
|
82
|
+
return C(t, (r) => w(n, r));
|
|
83
|
+
}
|
|
84
|
+
function gn(n, t) {
|
|
85
|
+
return C(t, (r) => a(n, r));
|
|
86
86
|
}
|
|
87
|
-
function
|
|
87
|
+
function hn(n) {
|
|
88
88
|
return n.replace("_", "-");
|
|
89
89
|
}
|
|
90
90
|
function pn(n, t) {
|
|
91
|
+
if (n === t) return -1;
|
|
91
92
|
const r = Math.min(n.length, t.length);
|
|
92
93
|
for (let e = 0; e < r; e++)
|
|
93
94
|
if (n.substring(e, e + 1) !== t.substring(e, e + 1)) return e;
|
|
94
95
|
return r;
|
|
95
96
|
}
|
|
96
|
-
function
|
|
97
|
+
function E(n, t = 20, r = "…") {
|
|
97
98
|
const e = n.length, i = r.length;
|
|
98
99
|
return e > t ? t < i ? r.substr(i - t, t) : n.substr(0, t - i) + r : n;
|
|
99
100
|
}
|
|
100
|
-
function
|
|
101
|
+
function dn(n, t = 20, r = "…") {
|
|
101
102
|
const e = n.length, i = r.length;
|
|
102
103
|
if (e > t) {
|
|
103
104
|
if (t <= i)
|
|
104
|
-
return
|
|
105
|
-
const
|
|
106
|
-
return n.substr(0,
|
|
105
|
+
return E(n, t, r);
|
|
106
|
+
const s = Math.ceil((t - i) / 2), f = Math.floor((t - i) / 2);
|
|
107
|
+
return n.substr(0, s) + r + n.substr(e - f, f);
|
|
107
108
|
} else return n;
|
|
108
109
|
}
|
|
109
|
-
function
|
|
110
|
-
return
|
|
110
|
+
function z(n, t) {
|
|
111
|
+
return l(t, (r) => L(n, r));
|
|
111
112
|
}
|
|
112
|
-
function
|
|
113
|
+
function bn(n, t) {
|
|
113
114
|
return g(n).filter(t).join("");
|
|
114
115
|
}
|
|
115
116
|
function Cn(n, t) {
|
|
116
|
-
return
|
|
117
|
+
return U(n).filter(t).map((e) => String.fromCharCode(e)).join("");
|
|
117
118
|
}
|
|
118
|
-
function
|
|
119
|
+
function An(n, t) {
|
|
119
120
|
const r = n.indexOf(t);
|
|
120
121
|
return r < 0 ? "" : n.substring(r);
|
|
121
122
|
}
|
|
122
|
-
function
|
|
123
|
+
function Ln(n, t = 2166136261) {
|
|
123
124
|
let r = t;
|
|
124
125
|
for (let e = 0, i = n.length; e < i; e++)
|
|
125
126
|
r ^= n.charCodeAt(e), r += (r << 1) + (r << 4) + (r << 7) + (r << 8) + (r << 24);
|
|
126
127
|
return r >>> 0;
|
|
127
128
|
}
|
|
128
|
-
function Ln(n) {
|
|
129
|
-
return n != null && n.length > 0;
|
|
130
|
-
}
|
|
131
129
|
function wn(n) {
|
|
132
|
-
return
|
|
130
|
+
return n != null && n.length > 0;
|
|
133
131
|
}
|
|
134
132
|
function In(n) {
|
|
135
|
-
return n
|
|
133
|
+
return c(k(n), "_", " ");
|
|
136
134
|
}
|
|
137
135
|
function mn(n) {
|
|
138
|
-
return D.test(n);
|
|
136
|
+
return n.length > 0 && !D.test(n);
|
|
137
|
+
}
|
|
138
|
+
function On(n) {
|
|
139
|
+
return G.test(n);
|
|
139
140
|
}
|
|
140
141
|
function Sn(n) {
|
|
141
|
-
return !
|
|
142
|
+
return !T.test(n);
|
|
142
143
|
}
|
|
143
|
-
function
|
|
144
|
+
function Wn(n) {
|
|
144
145
|
return n.toLowerCase() === n;
|
|
145
146
|
}
|
|
146
|
-
function
|
|
147
|
+
function yn(n) {
|
|
147
148
|
return n.toUpperCase() === n;
|
|
148
149
|
}
|
|
149
|
-
function
|
|
150
|
+
function En(n, t) {
|
|
150
151
|
return n != null && n !== "" ? n : t;
|
|
151
152
|
}
|
|
152
153
|
function zn(n) {
|
|
153
|
-
return
|
|
154
|
+
return F.test(n);
|
|
154
155
|
}
|
|
155
|
-
function
|
|
156
|
+
function Bn(n) {
|
|
156
157
|
return n == null || n === "";
|
|
157
158
|
}
|
|
158
|
-
function
|
|
159
|
+
function jn(n) {
|
|
159
160
|
return n.substring(0, 1).toLowerCase() + n.substring(1);
|
|
160
161
|
}
|
|
161
162
|
function B(n, t = 1) {
|
|
@@ -167,55 +168,59 @@ function B(n, t = 1) {
|
|
|
167
168
|
function j(n, t) {
|
|
168
169
|
return A(t, () => B(n)).join("");
|
|
169
170
|
}
|
|
170
|
-
function
|
|
171
|
-
return j(
|
|
171
|
+
function _n(n) {
|
|
172
|
+
return j(P, n);
|
|
172
173
|
}
|
|
173
|
-
function
|
|
174
|
+
function Mn(n, t) {
|
|
174
175
|
return g(t).map(n);
|
|
175
176
|
}
|
|
176
|
-
function
|
|
177
|
-
return
|
|
177
|
+
function Nn(n, t) {
|
|
178
|
+
return c(n, t, "");
|
|
178
179
|
}
|
|
179
|
-
function
|
|
180
|
+
function Un(n, t) {
|
|
180
181
|
return L(n, t) ? n.substring(0, n.length - t.length) : n;
|
|
181
182
|
}
|
|
182
|
-
function
|
|
183
|
+
function $n(n, t, r) {
|
|
183
184
|
return n.substring(0, t) + n.substring(t + r);
|
|
184
185
|
}
|
|
185
|
-
function
|
|
186
|
+
function xn(n, t) {
|
|
186
187
|
return W(n, t) ? n.substring(t.length) : n;
|
|
187
188
|
}
|
|
188
|
-
function
|
|
189
|
+
function kn(n, t) {
|
|
189
190
|
const r = n.indexOf(t);
|
|
190
191
|
return r < 0 ? n : n.substring(0, r) + n.substring(r + t.length);
|
|
191
192
|
}
|
|
192
193
|
function I(n, t) {
|
|
193
|
-
return
|
|
194
|
+
return S(t, n).join("");
|
|
194
195
|
}
|
|
195
|
-
function
|
|
196
|
+
function Zn(n) {
|
|
196
197
|
const t = g(n);
|
|
197
198
|
return t.reverse(), t.join("");
|
|
198
199
|
}
|
|
199
|
-
function
|
|
200
|
-
return n.includes('"') ? n.includes("'") ? '"' +
|
|
200
|
+
function _(n, t = "'") {
|
|
201
|
+
return t === "'" ? n.includes("'") ? n.includes('"') ? "'" + c(n, "'", "\\'") + "'" : '"' + n + '"' : "'" + n + "'" : n.includes('"') ? n.includes("'") ? '"' + c(n, '"', '\\"') + '"' : "'" + n + "'" : '"' + n + '"';
|
|
202
|
+
}
|
|
203
|
+
function M(n, t = "'") {
|
|
204
|
+
return t + c(n, t, "\\" + t) + t;
|
|
201
205
|
}
|
|
202
|
-
function
|
|
206
|
+
function Pn(n, t = "'") {
|
|
207
|
+
return n.indexOf(`
|
|
208
|
+
`) >= 0 ? M(n, "`") : _(n, t);
|
|
209
|
+
}
|
|
210
|
+
function Rn(n, t) {
|
|
203
211
|
const r = n.indexOf(t);
|
|
204
212
|
return r < 0 ? [n] : [n.substring(0, r), n.substring(r + t.length)];
|
|
205
213
|
}
|
|
206
|
-
function
|
|
207
|
-
return
|
|
208
|
-
}
|
|
209
|
-
function xn(n) {
|
|
210
|
-
return n.replace(H, "");
|
|
214
|
+
function N(n, t) {
|
|
215
|
+
return l(t, (r) => n.startsWith(r));
|
|
211
216
|
}
|
|
212
|
-
function
|
|
217
|
+
function Tn(n, t, r = t) {
|
|
213
218
|
return `${t}${n}${r}`;
|
|
214
219
|
}
|
|
215
220
|
function g(n) {
|
|
216
221
|
return n.split("");
|
|
217
222
|
}
|
|
218
|
-
function
|
|
223
|
+
function U(n) {
|
|
219
224
|
return A(n.length, (t) => n.charCodeAt(t));
|
|
220
225
|
}
|
|
221
226
|
function Dn(n, t) {
|
|
@@ -224,75 +229,75 @@ function Dn(n, t) {
|
|
|
224
229
|
r.push(n.substring(0, t)), n = n.substr(t, n.length - t);
|
|
225
230
|
return r;
|
|
226
231
|
}
|
|
227
|
-
function
|
|
228
|
-
return n.split(
|
|
232
|
+
function Hn(n) {
|
|
233
|
+
return n.split(O);
|
|
229
234
|
}
|
|
230
|
-
function
|
|
231
|
-
return
|
|
235
|
+
function Gn(n, t) {
|
|
236
|
+
return x($(n, t), t);
|
|
232
237
|
}
|
|
233
|
-
function
|
|
238
|
+
function $(n, t) {
|
|
234
239
|
let r = 0;
|
|
235
|
-
for (let e = 0; e < n.length &&
|
|
240
|
+
for (let e = 0; e < n.length && a(t, n.charAt(e)); e++)
|
|
236
241
|
r++;
|
|
237
242
|
return n.substring(r);
|
|
238
243
|
}
|
|
239
|
-
function
|
|
244
|
+
function x(n, t) {
|
|
240
245
|
const r = n.length;
|
|
241
246
|
let e = r, i;
|
|
242
|
-
for (let
|
|
247
|
+
for (let s = 0; s < r && (i = r - s - 1, a(t, n.charAt(i))); s++)
|
|
243
248
|
e = i;
|
|
244
249
|
return n.substring(0, e);
|
|
245
250
|
}
|
|
246
|
-
function
|
|
251
|
+
function k(n) {
|
|
247
252
|
return n = n.replace(/::/g, "/"), n = n.replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2"), n = n.replace(/([a-z\d])([A-Z])/g, "$1_$2"), n = n.replace(/-/g, "_"), n.toLowerCase();
|
|
248
253
|
}
|
|
249
|
-
function
|
|
254
|
+
function Fn(n) {
|
|
250
255
|
return n.substring(0, 1).toUpperCase() + n.substring(1);
|
|
251
256
|
}
|
|
252
|
-
function
|
|
257
|
+
function Qn(n, t) {
|
|
253
258
|
const r = n.indexOf(t);
|
|
254
259
|
return r < 0 ? n : n.substring(0, r);
|
|
255
260
|
}
|
|
256
261
|
function Kn(n, t = 78, r = "", e = `
|
|
257
262
|
`) {
|
|
258
|
-
return n.split(
|
|
259
|
-
(i) =>
|
|
263
|
+
return n.split(O).map(
|
|
264
|
+
(i) => Z(i.replace(m, " ").trim(), t, r, e)
|
|
260
265
|
).join(e);
|
|
261
266
|
}
|
|
262
|
-
function
|
|
267
|
+
function b(n, t) {
|
|
263
268
|
if (t < 0 || t >= n.length) return !1;
|
|
264
269
|
const r = n.charCodeAt(t);
|
|
265
270
|
return r === 9 || r === 10 || r === 11 || r === 12 || r === 13 || r === 32;
|
|
266
271
|
}
|
|
267
|
-
function
|
|
272
|
+
function qn(n) {
|
|
268
273
|
if (typeof Buffer < "u")
|
|
269
274
|
return Buffer.from(n).toString("base64");
|
|
270
275
|
if (typeof btoa < "u")
|
|
271
276
|
return btoa(n);
|
|
272
|
-
throw new Error("no implementation
|
|
277
|
+
throw new Error("no implementation found for base64 encoding");
|
|
273
278
|
}
|
|
274
|
-
function
|
|
279
|
+
function Jn(n) {
|
|
275
280
|
if (typeof Buffer < "u")
|
|
276
281
|
return Buffer.from(n, "base64").toString("utf8");
|
|
277
282
|
if (typeof atob < "u")
|
|
278
283
|
return atob(n);
|
|
279
|
-
throw new Error("no implementation
|
|
284
|
+
throw new Error("no implementation found for base64 decoding");
|
|
280
285
|
}
|
|
281
|
-
function
|
|
282
|
-
const i = [],
|
|
283
|
-
let
|
|
286
|
+
function Z(n, t, r, e) {
|
|
287
|
+
const i = [], s = n.length, f = r.length;
|
|
288
|
+
let u = 0;
|
|
284
289
|
for (t -= f; ; ) {
|
|
285
|
-
if (
|
|
286
|
-
i.push(n.substring(
|
|
290
|
+
if (u + t >= s - f) {
|
|
291
|
+
i.push(n.substring(u));
|
|
287
292
|
break;
|
|
288
293
|
}
|
|
289
294
|
let o = 0;
|
|
290
|
-
for (; !
|
|
295
|
+
for (; !b(n, u + t - o) && o < t; ) o++;
|
|
291
296
|
if (o === t) {
|
|
292
|
-
for (o = 0; !
|
|
293
|
-
i.push(n.substring(
|
|
297
|
+
for (o = 0; !b(n, u + t + o) && u + t + o < s; ) o++;
|
|
298
|
+
i.push(n.substring(u, u + t + o)), u += t + o + 1;
|
|
294
299
|
} else
|
|
295
|
-
i.push(n.substring(
|
|
300
|
+
i.push(n.substring(u, u + t - o)), u += t - o + 1;
|
|
296
301
|
}
|
|
297
302
|
return r + i.join(e + r);
|
|
298
303
|
}
|
|
@@ -312,85 +317,86 @@ function vn(n, t) {
|
|
|
312
317
|
const r = n.indexOf(t);
|
|
313
318
|
return r >= 0 ? [n.substring(0, r), n.substring(r + t.length)] : [n];
|
|
314
319
|
}
|
|
315
|
-
const
|
|
320
|
+
const P = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", R = /[^a-zA-Z]([a-z])/g, T = /[^\t\n\r ]/, D = /[^a-zA-Z]/, H = /[ \t\r\n][a-z]/g, G = /^[a-z0-9]+$/i, F = /^[0-9]+$/, m = /[ \t\r\n]+/g, O = /\r\n|\n\r|\n|\r/g, Q = /\r\n|\n\r|\r/g;
|
|
316
321
|
export {
|
|
317
322
|
J as after,
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
323
|
+
V as afterLast,
|
|
324
|
+
X as before,
|
|
325
|
+
Y as beforeLast,
|
|
326
|
+
nn as canonicalizeNewlines,
|
|
327
|
+
p as capitalize,
|
|
328
|
+
v as capitalizeWords,
|
|
324
329
|
sn as collapse,
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
330
|
+
tn as compareCaseInsensitive,
|
|
331
|
+
y as compareStrings,
|
|
332
|
+
a as contains,
|
|
333
|
+
gn as containsAll,
|
|
334
|
+
an as containsAllCaseInsensitive,
|
|
335
|
+
ln as containsAny,
|
|
336
|
+
cn as containsAnyCaseInsensitive,
|
|
332
337
|
w as containsCaseInsensitive,
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
338
|
+
fn as count,
|
|
339
|
+
hn as dasherize,
|
|
340
|
+
Jn as decodeBase64,
|
|
336
341
|
pn as diffIndex,
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
342
|
+
E as ellipsis,
|
|
343
|
+
dn as ellipsisMiddle,
|
|
344
|
+
qn as encodeBase64,
|
|
340
345
|
L as endsWith,
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
346
|
+
z as endsWithAny,
|
|
347
|
+
on as endsWithAnyCaseInsensitive,
|
|
348
|
+
rn as endsWithCaseInsensitive,
|
|
349
|
+
bn as filter,
|
|
345
350
|
Cn as filterCharcode,
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
351
|
+
An as from,
|
|
352
|
+
wn as hasContent,
|
|
353
|
+
Ln as hashCode,
|
|
354
|
+
In as humanize,
|
|
355
|
+
En as ifEmpty,
|
|
356
|
+
mn as isAlpha,
|
|
357
|
+
On as isAlphaNum,
|
|
353
358
|
Sn as isBreakingWhitespace,
|
|
354
359
|
zn as isDigitsOnly,
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
+
Bn as isEmpty,
|
|
361
|
+
Wn as isLowerCase,
|
|
362
|
+
b as isSpaceAt,
|
|
363
|
+
yn as isUpperCase,
|
|
364
|
+
Pn as jsQuote,
|
|
365
|
+
jn as lowerCaseFirst,
|
|
360
366
|
Vn as lpad,
|
|
361
|
-
|
|
362
|
-
|
|
367
|
+
Mn as map,
|
|
368
|
+
M as quote,
|
|
363
369
|
B as random,
|
|
364
370
|
j as randomSequence,
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
+
_n as randomSequence64,
|
|
372
|
+
Nn as remove,
|
|
373
|
+
Un as removeAfter,
|
|
374
|
+
$n as removeAt,
|
|
375
|
+
xn as removeBefore,
|
|
376
|
+
kn as removeOne,
|
|
371
377
|
I as repeat,
|
|
372
|
-
|
|
373
|
-
|
|
378
|
+
c as replace,
|
|
379
|
+
Zn as reverse,
|
|
374
380
|
Xn as rpad,
|
|
381
|
+
_ as smartQuote,
|
|
375
382
|
vn as splitOnFirst,
|
|
376
383
|
Yn as splitOnLast,
|
|
377
|
-
|
|
384
|
+
Rn as splitOnce,
|
|
378
385
|
W as startsWith,
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
Rn as surround,
|
|
386
|
+
N as startsWithAny,
|
|
387
|
+
un as startsWithAnyCaseInsensitive,
|
|
388
|
+
en as startsWithCaseInsensitive,
|
|
389
|
+
Tn as surround,
|
|
384
390
|
g as toArray,
|
|
385
|
-
|
|
391
|
+
U as toCharcodes,
|
|
386
392
|
Dn as toChunks,
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
393
|
+
Hn as toLines,
|
|
394
|
+
Gn as trimChars,
|
|
395
|
+
$ as trimCharsLeft,
|
|
396
|
+
x as trimCharsRight,
|
|
397
|
+
k as underscore,
|
|
398
|
+
Qn as upTo,
|
|
399
|
+
Fn as upperCaseFirst,
|
|
394
400
|
Kn as wrapColumns,
|
|
395
|
-
|
|
401
|
+
Z as wrapLine
|
|
396
402
|
};
|
package/validation.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("./result-DzdZiQoR.cjs");exports.Validation=i.Validation;
|
package/validation.d.ts
CHANGED
|
@@ -1,24 +1,92 @@
|
|
|
1
1
|
import { Result } from './result';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Represents a valid result.
|
|
5
|
+
* @public
|
|
6
|
+
*/
|
|
3
7
|
export interface Valid {
|
|
4
8
|
type: 'valid';
|
|
5
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* Represents an invalid value with an associated error.
|
|
12
|
+
* @typeParam E - The type of the error.
|
|
13
|
+
* @public
|
|
14
|
+
*/
|
|
6
15
|
export interface Invalid<E> {
|
|
7
16
|
type: 'invalid';
|
|
8
17
|
error: E;
|
|
9
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Represents a type that can either be `Valid` or `Invalid`.
|
|
21
|
+
* @typeParam E - The type of the error associated with an `Invalid` value.
|
|
22
|
+
* @public
|
|
23
|
+
*/
|
|
10
24
|
export type Validation<E> = Valid | Invalid<E>;
|
|
25
|
+
/**
|
|
26
|
+
* Represents a promise that resolves to a `Validation` object.
|
|
27
|
+
* @typeParam E - The type of the error value in the `Validation` object.
|
|
28
|
+
* @public
|
|
29
|
+
*/
|
|
11
30
|
export type PromiseValidation<E> = PromiseLike<Validation<E>>;
|
|
31
|
+
/**
|
|
32
|
+
* Utility functions for working with `Validation` types.
|
|
33
|
+
* @public
|
|
34
|
+
*/
|
|
12
35
|
export declare const Validation: {
|
|
36
|
+
/**
|
|
37
|
+
* Creates a valid `Validation`.
|
|
38
|
+
* @returns A `Validation` that is `Valid`.
|
|
39
|
+
*/
|
|
13
40
|
valid: {
|
|
14
41
|
type: "valid";
|
|
15
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* Creates an invalid `Validation`.
|
|
45
|
+
* @param error - The error associated with the invalid value.
|
|
46
|
+
* @returns A `Validation` that is `Invalid`.
|
|
47
|
+
*/
|
|
16
48
|
invalid<E>(error: E): Validation<E>;
|
|
49
|
+
/**
|
|
50
|
+
* Checks if a `Validation` is `Valid`.
|
|
51
|
+
* @param r - The `Validation` to check.
|
|
52
|
+
* @returns `true` if the `Validation` is `Valid`, otherwise `false`.
|
|
53
|
+
*/
|
|
17
54
|
isValid<E>(r: Validation<E>): r is Valid;
|
|
55
|
+
/**
|
|
56
|
+
* Checks if a `Validation` is `Invalid`.
|
|
57
|
+
* @param r - The `Validation` to check.
|
|
58
|
+
* @returns `true` if the `Validation` is `Invalid`, otherwise `false`.
|
|
59
|
+
*/
|
|
18
60
|
isInvalid<E>(r: Validation<E>): r is Invalid<E>;
|
|
19
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Maps the value of a `Validation` to a new value.
|
|
63
|
+
* @param r - The `Validation` to map.
|
|
64
|
+
* @param valid - The mapping function for a valid value.
|
|
65
|
+
* @param invalid - The mapping function for an invalid value.
|
|
66
|
+
* @returns The mapped value.
|
|
67
|
+
*/
|
|
20
68
|
match: <V, E>(r: Validation<E>, valid: () => V, invalid: (error: E) => V) => V;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Maps the value of a `Validation` to a new `Validation`.
|
|
71
|
+
* @param validation - The `Validation` to map.
|
|
72
|
+
* @param value - The value to map.
|
|
73
|
+
* @returns A new `Validation` with the mapped value.
|
|
74
|
+
*/
|
|
75
|
+
toResult: <T, E>(validation: Validation<E>, value: T) => Result<T, E>;
|
|
76
|
+
/**
|
|
77
|
+
* Execute a function when the `Validation` is valid.
|
|
78
|
+
*
|
|
79
|
+
* @param r - The `Validation` to check.
|
|
80
|
+
* @param apply - The function to execute when the `Validation` is valid.
|
|
81
|
+
* @returns The `Validation` object.
|
|
82
|
+
*/
|
|
83
|
+
whenValid: <E>(r: Validation<E>, apply: () => void) => Validation<E>;
|
|
84
|
+
/**
|
|
85
|
+
* Execute a function when the `Validation` is invalid.
|
|
86
|
+
*
|
|
87
|
+
* @param r - The `Validation` to check.
|
|
88
|
+
* @param apply - The function to execute when the `Validation` is invalid.
|
|
89
|
+
* @returns The `Validation` object.
|
|
90
|
+
*/
|
|
91
|
+
whenInvalid: <E>(r: Validation<E>, apply: (e: E) => void) => Validation<E>;
|
|
24
92
|
};
|
package/validation.js
CHANGED
|
@@ -1,25 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const r = {
|
|
3
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
4
|
-
valid: { type: "valid" },
|
|
5
|
-
invalid(i) {
|
|
6
|
-
return { type: "invalid", error: i };
|
|
7
|
-
},
|
|
8
|
-
isValid(i) {
|
|
9
|
-
return i.type === "valid";
|
|
10
|
-
},
|
|
11
|
-
isInvalid(i) {
|
|
12
|
-
return i.type === "invalid";
|
|
13
|
-
},
|
|
14
|
-
cmatch: (i, e) => (t) => r.isValid(t) ? i() : e(t.error),
|
|
15
|
-
match: (i, e, t) => r.isValid(i) ? e() : t(i.error),
|
|
16
|
-
toResult: (i) => r.cmatch(
|
|
17
|
-
() => a.success(i),
|
|
18
|
-
(e) => a.failure(e)
|
|
19
|
-
),
|
|
20
|
-
whenValid: (i) => (e) => (r.isValid(e) && i(), e),
|
|
21
|
-
whenInvalid: (i) => (e) => (r.isInvalid(e) && i(e.error), e)
|
|
22
|
-
};
|
|
1
|
+
import { V as i } from "./result-Czm7RKNP.js";
|
|
23
2
|
export {
|
|
24
|
-
|
|
3
|
+
i as Validation
|
|
25
4
|
};
|
package/maybe.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e={nothing:void 0,just:t=>t,isNothing:t=>t==null,isJust:t=>t!=null};exports.Maybe=e;
|
package/maybe.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export type Maybe<T> = Just<T> | Nothing;
|
|
2
|
-
export type Nothing = undefined | null;
|
|
3
|
-
export type Just<T> = NonNullable<T>;
|
|
4
|
-
export declare const Maybe: {
|
|
5
|
-
nothing: Maybe<never>;
|
|
6
|
-
just: <T>(value: T) => Maybe<T>;
|
|
7
|
-
isNothing: <T>(maybe: Maybe<T>) => maybe is Nothing;
|
|
8
|
-
isJust: <T>(maybe: Maybe<T>) => maybe is Just<T>;
|
|
9
|
-
};
|