@tempots/std 0.11.0 → 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/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 +152 -13
- package/async-result.js +112 -8
- 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 +146 -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 -0
- package/index.d.ts +13 -0
- package/index.js +185 -0
- 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 +8 -8
- 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 +130 -6
- package/result.js +3 -54
- package/string.cjs +4 -4
- package/string.d.ts +217 -9
- package/string.js +153 -156
- 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,63 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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
3
|
function c(n, t, r) {
|
|
4
4
|
return n.split(t).join(r);
|
|
5
5
|
}
|
|
6
|
-
function
|
|
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
54
|
function un(n, t) {
|
|
55
|
-
return
|
|
55
|
+
return N(
|
|
56
56
|
n.toLowerCase(),
|
|
57
57
|
t.map((r) => r.toLowerCase())
|
|
58
58
|
);
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function sn(n) {
|
|
61
61
|
return n.trim().replace(m, " ");
|
|
62
62
|
}
|
|
63
63
|
function y(n, t) {
|
|
@@ -69,93 +69,94 @@ function w(n, t) {
|
|
|
69
69
|
function a(n, t) {
|
|
70
70
|
return n.includes(t);
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function fn(n, t) {
|
|
73
73
|
return n.split(t).length - 1;
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function cn(n, t) {
|
|
76
76
|
return l(t, (r) => w(n, r));
|
|
77
77
|
}
|
|
78
|
-
function
|
|
78
|
+
function ln(n, t) {
|
|
79
79
|
return l(t, (r) => a(n, r));
|
|
80
80
|
}
|
|
81
|
-
function
|
|
81
|
+
function an(n, t) {
|
|
82
82
|
return C(t, (r) => w(n, r));
|
|
83
83
|
}
|
|
84
|
-
function
|
|
84
|
+
function gn(n, t) {
|
|
85
85
|
return C(t, (r) => a(n, r));
|
|
86
86
|
}
|
|
87
87
|
function hn(n) {
|
|
88
88
|
return n.replace("_", "-");
|
|
89
89
|
}
|
|
90
|
-
function
|
|
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
|
+
function z(n, t) {
|
|
110
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
|
-
function
|
|
116
|
-
return
|
|
116
|
+
function Cn(n, t) {
|
|
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
|
|
129
|
+
function wn(n) {
|
|
129
130
|
return n != null && n.length > 0;
|
|
130
131
|
}
|
|
131
|
-
function
|
|
132
|
+
function In(n) {
|
|
132
133
|
return c(k(n), "_", " ");
|
|
133
134
|
}
|
|
134
|
-
function
|
|
135
|
+
function mn(n) {
|
|
135
136
|
return n.length > 0 && !D.test(n);
|
|
136
137
|
}
|
|
137
138
|
function On(n) {
|
|
138
|
-
return
|
|
139
|
+
return G.test(n);
|
|
139
140
|
}
|
|
140
|
-
function
|
|
141
|
-
return !
|
|
141
|
+
function Sn(n) {
|
|
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
150
|
function En(n, t) {
|
|
150
151
|
return n != null && n !== "" ? n : t;
|
|
151
152
|
}
|
|
152
|
-
function
|
|
153
|
-
return
|
|
153
|
+
function zn(n) {
|
|
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,7 +168,7 @@ function B(n, t = 1) {
|
|
|
167
168
|
function j(n, t) {
|
|
168
169
|
return A(t, () => B(n)).join("");
|
|
169
170
|
}
|
|
170
|
-
function
|
|
171
|
+
function _n(n) {
|
|
171
172
|
return j(P, n);
|
|
172
173
|
}
|
|
173
174
|
function Mn(n, t) {
|
|
@@ -176,94 +177,91 @@ function Mn(n, t) {
|
|
|
176
177
|
function Nn(n, t) {
|
|
177
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
200
|
function _(n, t = "'") {
|
|
200
201
|
return t === "'" ? n.includes("'") ? n.includes('"') ? "'" + c(n, "'", "\\'") + "'" : '"' + n + '"' : "'" + n + "'" : n.includes('"') ? n.includes("'") ? '"' + c(n, '"', '\\"') + '"' : "'" + n + "'" : '"' + n + '"';
|
|
201
202
|
}
|
|
202
|
-
function
|
|
203
|
+
function M(n, t = "'") {
|
|
203
204
|
return t + c(n, t, "\\" + t) + t;
|
|
204
205
|
}
|
|
205
|
-
function
|
|
206
|
+
function Pn(n, t = "'") {
|
|
206
207
|
return n.indexOf(`
|
|
207
|
-
`) >= 0 ?
|
|
208
|
+
`) >= 0 ? M(n, "`") : _(n, t);
|
|
208
209
|
}
|
|
209
210
|
function Rn(n, t) {
|
|
210
211
|
const r = n.indexOf(t);
|
|
211
212
|
return r < 0 ? [n] : [n.substring(0, r), n.substring(r + t.length)];
|
|
212
213
|
}
|
|
213
|
-
function
|
|
214
|
+
function N(n, t) {
|
|
214
215
|
return l(t, (r) => n.startsWith(r));
|
|
215
216
|
}
|
|
216
|
-
function
|
|
217
|
-
return n.replace(F, "");
|
|
218
|
-
}
|
|
219
|
-
function Gn(n, t, r = t) {
|
|
217
|
+
function Tn(n, t, r = t) {
|
|
220
218
|
return `${t}${n}${r}`;
|
|
221
219
|
}
|
|
222
220
|
function g(n) {
|
|
223
221
|
return n.split("");
|
|
224
222
|
}
|
|
225
|
-
function
|
|
223
|
+
function U(n) {
|
|
226
224
|
return A(n.length, (t) => n.charCodeAt(t));
|
|
227
225
|
}
|
|
228
|
-
function
|
|
226
|
+
function Dn(n, t) {
|
|
229
227
|
const r = [];
|
|
230
228
|
for (; n.length > 0; )
|
|
231
229
|
r.push(n.substring(0, t)), n = n.substr(t, n.length - t);
|
|
232
230
|
return r;
|
|
233
231
|
}
|
|
234
|
-
function
|
|
235
|
-
return n.split(
|
|
232
|
+
function Hn(n) {
|
|
233
|
+
return n.split(O);
|
|
236
234
|
}
|
|
237
|
-
function
|
|
238
|
-
return
|
|
235
|
+
function Gn(n, t) {
|
|
236
|
+
return x($(n, t), t);
|
|
239
237
|
}
|
|
240
|
-
function
|
|
238
|
+
function $(n, t) {
|
|
241
239
|
let r = 0;
|
|
242
240
|
for (let e = 0; e < n.length && a(t, n.charAt(e)); e++)
|
|
243
241
|
r++;
|
|
244
242
|
return n.substring(r);
|
|
245
243
|
}
|
|
246
|
-
function
|
|
244
|
+
function x(n, t) {
|
|
247
245
|
const r = n.length;
|
|
248
246
|
let e = r, i;
|
|
249
|
-
for (let
|
|
247
|
+
for (let s = 0; s < r && (i = r - s - 1, a(t, n.charAt(i))); s++)
|
|
250
248
|
e = i;
|
|
251
249
|
return n.substring(0, e);
|
|
252
250
|
}
|
|
253
251
|
function k(n) {
|
|
254
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();
|
|
255
253
|
}
|
|
256
|
-
function
|
|
254
|
+
function Fn(n) {
|
|
257
255
|
return n.substring(0, 1).toUpperCase() + n.substring(1);
|
|
258
256
|
}
|
|
259
|
-
function
|
|
257
|
+
function Qn(n, t) {
|
|
260
258
|
const r = n.indexOf(t);
|
|
261
259
|
return r < 0 ? n : n.substring(0, r);
|
|
262
260
|
}
|
|
263
|
-
function
|
|
261
|
+
function Kn(n, t = 78, r = "", e = `
|
|
264
262
|
`) {
|
|
265
|
-
return n.split(
|
|
266
|
-
(i) =>
|
|
263
|
+
return n.split(O).map(
|
|
264
|
+
(i) => Z(i.replace(m, " ").trim(), t, r, e)
|
|
267
265
|
).join(e);
|
|
268
266
|
}
|
|
269
267
|
function b(n, t) {
|
|
@@ -271,135 +269,134 @@ function b(n, t) {
|
|
|
271
269
|
const r = n.charCodeAt(t);
|
|
272
270
|
return r === 9 || r === 10 || r === 11 || r === 12 || r === 13 || r === 32;
|
|
273
271
|
}
|
|
274
|
-
function
|
|
272
|
+
function qn(n) {
|
|
275
273
|
if (typeof Buffer < "u")
|
|
276
274
|
return Buffer.from(n).toString("base64");
|
|
277
275
|
if (typeof btoa < "u")
|
|
278
276
|
return btoa(n);
|
|
279
|
-
throw new Error("no implementation
|
|
277
|
+
throw new Error("no implementation found for base64 encoding");
|
|
280
278
|
}
|
|
281
|
-
function
|
|
279
|
+
function Jn(n) {
|
|
282
280
|
if (typeof Buffer < "u")
|
|
283
281
|
return Buffer.from(n, "base64").toString("utf8");
|
|
284
282
|
if (typeof atob < "u")
|
|
285
283
|
return atob(n);
|
|
286
|
-
throw new Error("no implementation
|
|
284
|
+
throw new Error("no implementation found for base64 decoding");
|
|
287
285
|
}
|
|
288
|
-
function
|
|
289
|
-
const i = [],
|
|
290
|
-
let
|
|
286
|
+
function Z(n, t, r, e) {
|
|
287
|
+
const i = [], s = n.length, f = r.length;
|
|
288
|
+
let u = 0;
|
|
291
289
|
for (t -= f; ; ) {
|
|
292
|
-
if (
|
|
293
|
-
i.push(n.substring(
|
|
290
|
+
if (u + t >= s - f) {
|
|
291
|
+
i.push(n.substring(u));
|
|
294
292
|
break;
|
|
295
293
|
}
|
|
296
294
|
let o = 0;
|
|
297
|
-
for (; !b(n,
|
|
295
|
+
for (; !b(n, u + t - o) && o < t; ) o++;
|
|
298
296
|
if (o === t) {
|
|
299
|
-
for (o = 0; !b(n,
|
|
300
|
-
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;
|
|
301
299
|
} else
|
|
302
|
-
i.push(n.substring(
|
|
300
|
+
i.push(n.substring(u, u + t - o)), u += t - o + 1;
|
|
303
301
|
}
|
|
304
302
|
return r + i.join(e + r);
|
|
305
303
|
}
|
|
306
|
-
function
|
|
304
|
+
function Vn(n, t, r) {
|
|
307
305
|
const e = r - n.length;
|
|
308
306
|
return e > 0 ? I(t, e) + n : n;
|
|
309
307
|
}
|
|
310
|
-
function
|
|
308
|
+
function Xn(n, t, r) {
|
|
311
309
|
const e = r - n.length;
|
|
312
310
|
return e > 0 ? n + I(t, e) : n;
|
|
313
311
|
}
|
|
314
|
-
function
|
|
312
|
+
function Yn(n, t) {
|
|
315
313
|
const r = n.lastIndexOf(t);
|
|
316
314
|
return r >= 0 ? [n.substring(0, r), n.substring(r + t.length)] : [n];
|
|
317
315
|
}
|
|
318
|
-
function
|
|
316
|
+
function vn(n, t) {
|
|
319
317
|
const r = n.indexOf(t);
|
|
320
318
|
return r >= 0 ? [n.substring(0, r), n.substring(r + t.length)] : [n];
|
|
321
319
|
}
|
|
322
|
-
const P = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
|
|
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;
|
|
323
321
|
export {
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
322
|
+
J as after,
|
|
323
|
+
V as afterLast,
|
|
324
|
+
X as before,
|
|
325
|
+
Y as beforeLast,
|
|
326
|
+
nn as canonicalizeNewlines,
|
|
327
|
+
p as capitalize,
|
|
328
|
+
v as capitalizeWords,
|
|
329
|
+
sn as collapse,
|
|
330
|
+
tn as compareCaseInsensitive,
|
|
331
|
+
y as compareStrings,
|
|
334
332
|
a as contains,
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
333
|
+
gn as containsAll,
|
|
334
|
+
an as containsAllCaseInsensitive,
|
|
335
|
+
ln as containsAny,
|
|
336
|
+
cn as containsAnyCaseInsensitive,
|
|
339
337
|
w as containsCaseInsensitive,
|
|
340
|
-
|
|
338
|
+
fn as count,
|
|
341
339
|
hn as dasherize,
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
340
|
+
Jn as decodeBase64,
|
|
341
|
+
pn as diffIndex,
|
|
342
|
+
E as ellipsis,
|
|
343
|
+
dn as ellipsisMiddle,
|
|
344
|
+
qn as encodeBase64,
|
|
347
345
|
L as endsWith,
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
346
|
+
z as endsWithAny,
|
|
347
|
+
on as endsWithAnyCaseInsensitive,
|
|
348
|
+
rn as endsWithCaseInsensitive,
|
|
349
|
+
bn as filter,
|
|
350
|
+
Cn as filterCharcode,
|
|
351
|
+
An as from,
|
|
352
|
+
wn as hasContent,
|
|
353
|
+
Ln as hashCode,
|
|
354
|
+
In as humanize,
|
|
357
355
|
En as ifEmpty,
|
|
358
|
-
|
|
356
|
+
mn as isAlpha,
|
|
359
357
|
On as isAlphaNum,
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
358
|
+
Sn as isBreakingWhitespace,
|
|
359
|
+
zn as isDigitsOnly,
|
|
360
|
+
Bn as isEmpty,
|
|
361
|
+
Wn as isLowerCase,
|
|
364
362
|
b as isSpaceAt,
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
363
|
+
yn as isUpperCase,
|
|
364
|
+
Pn as jsQuote,
|
|
365
|
+
jn as lowerCaseFirst,
|
|
366
|
+
Vn as lpad,
|
|
369
367
|
Mn as map,
|
|
370
|
-
|
|
368
|
+
M as quote,
|
|
371
369
|
B as random,
|
|
372
370
|
j as randomSequence,
|
|
373
|
-
|
|
371
|
+
_n as randomSequence64,
|
|
374
372
|
Nn as remove,
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
373
|
+
Un as removeAfter,
|
|
374
|
+
$n as removeAt,
|
|
375
|
+
xn as removeBefore,
|
|
376
|
+
kn as removeOne,
|
|
379
377
|
I as repeat,
|
|
380
378
|
c as replace,
|
|
381
|
-
|
|
382
|
-
|
|
379
|
+
Zn as reverse,
|
|
380
|
+
Xn as rpad,
|
|
383
381
|
_ as smartQuote,
|
|
384
|
-
|
|
385
|
-
|
|
382
|
+
vn as splitOnFirst,
|
|
383
|
+
Yn as splitOnLast,
|
|
386
384
|
Rn as splitOnce,
|
|
387
385
|
W as startsWith,
|
|
388
|
-
|
|
386
|
+
N as startsWithAny,
|
|
389
387
|
un as startsWithAnyCaseInsensitive,
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
Gn as surround,
|
|
388
|
+
en as startsWithCaseInsensitive,
|
|
389
|
+
Tn as surround,
|
|
393
390
|
g as toArray,
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
391
|
+
U as toCharcodes,
|
|
392
|
+
Dn as toChunks,
|
|
393
|
+
Hn as toLines,
|
|
394
|
+
Gn as trimChars,
|
|
395
|
+
$ as trimCharsLeft,
|
|
396
|
+
x as trimCharsRight,
|
|
400
397
|
k as underscore,
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
398
|
+
Qn as upTo,
|
|
399
|
+
Fn as upperCaseFirst,
|
|
400
|
+
Kn as wrapColumns,
|
|
401
|
+
Z as wrapLine
|
|
405
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;
|