@tempots/std 0.24.0 → 0.25.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.
@@ -0,0 +1,462 @@
1
+ import { AsyncResult as n } from "./async-result.js";
2
+ const i = {
3
+ /**
4
+ * Creates a valid `Validation`.
5
+ * @returns A `Validation` that is `Valid`.
6
+ */
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ valid: { type: "valid" },
9
+ /**
10
+ * Creates an invalid `Validation`.
11
+ * @param error - The error associated with the invalid value.
12
+ * @returns A `Validation` that is `Invalid`.
13
+ */
14
+ invalid(e) {
15
+ return { type: "invalid", error: e };
16
+ },
17
+ /**
18
+ * Checks if a `Validation` is `Valid`.
19
+ * @param r - The `Validation` to check.
20
+ * @returns `true` if the `Validation` is `Valid`, otherwise `false`.
21
+ */
22
+ isValid(e) {
23
+ return e.type === "valid";
24
+ },
25
+ /**
26
+ * Checks if a `Validation` is `Invalid`.
27
+ * @param r - The `Validation` to check.
28
+ * @returns `true` if the `Validation` is `Invalid`, otherwise `false`.
29
+ */
30
+ isInvalid(e) {
31
+ return e.type === "invalid";
32
+ },
33
+ /**
34
+ * Maps the value of a `Validation` to a new value.
35
+ * @param r - The `Validation` to map.
36
+ * @param valid - The mapping function for a valid value.
37
+ * @param invalid - The mapping function for an invalid value.
38
+ * @returns The mapped value.
39
+ */
40
+ match: (e, r, u) => i.isValid(e) ? r() : u(e.error),
41
+ /**
42
+ * Maps the value of a `Validation` to a new `Validation`.
43
+ * @param validation - The `Validation` to map.
44
+ * @param value - The value to map.
45
+ * @returns A new `Validation` with the mapped value.
46
+ */
47
+ toResult: (e, r) => i.match(
48
+ e,
49
+ () => s.success(r),
50
+ (u) => s.failure(u)
51
+ ),
52
+ /**
53
+ * Execute a function when the `Validation` is valid.
54
+ *
55
+ * @param r - The `Validation` to check.
56
+ * @param apply - The function to execute when the `Validation` is valid.
57
+ * @returns The `Validation` object.
58
+ */
59
+ whenValid: (e, r) => (i.isValid(e) && r(), e),
60
+ /**
61
+ * Execute a function when the `Validation` is invalid.
62
+ *
63
+ * @param r - The `Validation` to check.
64
+ * @param apply - The function to execute when the `Validation` is invalid.
65
+ * @returns The `Validation` object.
66
+ */
67
+ whenInvalid: (e, r) => (i.isInvalid(e) && r(e.error), e),
68
+ /**
69
+ * Maps the error of an invalid `Validation` to a new error using the provided function.
70
+ * For valid validations, the validation is preserved unchanged.
71
+ * @param v - The `Validation` to map the error of.
72
+ * @param f - The mapping function to apply to the error.
73
+ * @returns A new `Validation` with the mapped error if invalid, otherwise the original valid.
74
+ * @public
75
+ */
76
+ mapError: (e, r) => e.type === "invalid" ? i.invalid(r(e.error)) : e,
77
+ /**
78
+ * Maps the error of an invalid `Validation` to a new `Validation` using the provided function.
79
+ * This allows recovery from errors by returning a valid validation.
80
+ * @param v - The `Validation` to recover from.
81
+ * @param f - The recovery function that returns a new `Validation`.
82
+ * @returns The result of the recovery function if invalid, otherwise the original valid.
83
+ * @public
84
+ */
85
+ flatMapError: (e, r) => e.type === "invalid" ? r(e.error) : e,
86
+ /**
87
+ * Combines two validations. Both must be valid for the result to be valid.
88
+ * If both are invalid, errors are combined using the provided function.
89
+ * @param v1 - The first validation.
90
+ * @param v2 - The second validation.
91
+ * @param combineErrors - The function to combine two errors.
92
+ * @returns A combined validation.
93
+ * @public
94
+ */
95
+ combine: (e, r, u) => i.isValid(e) && i.isValid(r) ? i.valid : i.isInvalid(e) && i.isInvalid(r) ? i.invalid(u(e.error, r.error)) : i.isInvalid(e) ? e : r,
96
+ /**
97
+ * Combines multiple validations into a single validation.
98
+ * All must be valid for the result to be valid.
99
+ * Returns the first invalid validation if any.
100
+ * @param validations - The validations to combine.
101
+ * @returns A single validation that is valid only if all inputs are valid.
102
+ * @public
103
+ */
104
+ all: (e) => {
105
+ for (const r of e)
106
+ if (i.isInvalid(r))
107
+ return r;
108
+ return i.valid;
109
+ },
110
+ /**
111
+ * Combines multiple validations, accumulating all errors.
112
+ * All must be valid for the result to be valid.
113
+ * If any are invalid, all errors are collected into an array.
114
+ * @param validations - The validations to combine.
115
+ * @returns A validation that is valid only if all inputs are valid, otherwise contains all errors.
116
+ * @public
117
+ */
118
+ allErrors: (e) => {
119
+ const r = [];
120
+ for (const u of e)
121
+ i.isInvalid(u) && r.push(u.error);
122
+ return r.length > 0 ? i.invalid(r) : i.valid;
123
+ },
124
+ /**
125
+ * Compares two validations for equality.
126
+ * @param v1 - The first validation.
127
+ * @param v2 - The second validation.
128
+ * @param errorEquals - Optional custom equality function for errors. Defaults to strict equality.
129
+ * @returns `true` if the validations are equal, `false` otherwise.
130
+ * @public
131
+ */
132
+ equals: (e, r, u = (t, l) => t === l) => e.type === "valid" && r.type === "valid" ? !0 : e.type === "invalid" && r.type === "invalid" ? u(e.error, r.error) : !1,
133
+ /**
134
+ * Recovers from an invalid validation by returning a valid validation.
135
+ * @param v - The `Validation` to recover from.
136
+ * @returns A valid validation regardless of the input.
137
+ * @public
138
+ */
139
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
140
+ recover: (e) => i.valid,
141
+ /**
142
+ * Gets the error if the validation is invalid, otherwise returns undefined.
143
+ * @param v - The validation to get the error from.
144
+ * @returns The error if invalid, otherwise undefined.
145
+ * @public
146
+ */
147
+ getError: (e) => {
148
+ if (i.isInvalid(e))
149
+ return e.error;
150
+ },
151
+ /**
152
+ * Gets the error if the validation is invalid, otherwise returns the default value.
153
+ * @param v - The validation to get the error from.
154
+ * @param defaultError - The default error to return if valid.
155
+ * @returns The error if invalid, otherwise the default error.
156
+ * @public
157
+ */
158
+ getErrorOrElse: (e, r) => i.isInvalid(e) ? e.error : r
159
+ }, s = {
160
+ /**
161
+ * Creates a successful `Result`.
162
+ * @param value - The value to wrap in a `Success` type.
163
+ * @returns A `Result` that is a `Success`.
164
+ * @public
165
+ */
166
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
167
+ success(e) {
168
+ return { type: "Success", value: e };
169
+ },
170
+ /**
171
+ * Creates a failure `Result`.
172
+ * @param error - The error to wrap in a `Failure` type.
173
+ * @returns A `Result` that is a `Failure`.
174
+ * @public
175
+ */
176
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
177
+ failure(e) {
178
+ return { type: "Failure", error: e };
179
+ },
180
+ /**
181
+ * Maps the value of a `Result` to a new value.
182
+ * @param r - The `Result` to map.
183
+ * @param f - The mapping function.
184
+ * @returns A new `Result` with the mapped value.
185
+ * @public
186
+ */
187
+ map: (e, r) => e.type === "Success" ? s.success(r(e.value)) : e,
188
+ /**
189
+ * Maps the value of a `Result` to a new `Result`.
190
+ * @param r - The `Result` to map.
191
+ * @param f - The mapping function.
192
+ * @returns A new `Result` with the mapped value.
193
+ * @public
194
+ */
195
+ flatMap: (e, r) => e.type === "Success" ? r(e.value) : e,
196
+ /**
197
+ * Converts a `Result` to an `AsyncResult`.
198
+ * @param r - The `Result` to convert.
199
+ * @returns An `AsyncResult` that is equivalent to the input `Result`.
200
+ * @public
201
+ */
202
+ toAsync(e) {
203
+ return s.match(
204
+ e,
205
+ (r) => n.success(r),
206
+ (r) => n.failure(r)
207
+ );
208
+ },
209
+ /**
210
+ * Converts a `Result` to a `Validation`.
211
+ * @param r - The `Result` to convert.
212
+ * @returns A `Validation` that is equivalent to the input `Result`.
213
+ * @public
214
+ */
215
+ toValidation(e) {
216
+ return s.match(
217
+ e,
218
+ () => i.valid,
219
+ (r) => i.invalid(r)
220
+ );
221
+ },
222
+ /**
223
+ * Checks if a `Result` is a success.
224
+ * @param r - The `Result` to check.
225
+ * @returns `true` if the `Result` is a `Success`, `false` otherwise.
226
+ * @public
227
+ */
228
+ isSuccess(e) {
229
+ return e.type === "Success";
230
+ },
231
+ /**
232
+ * Checks if a `Result` is a failure.
233
+ * @param r - The `Result` to check.
234
+ * @returns `true` if the `Result` is a `Failure`, `false` otherwise.
235
+ * @public
236
+ */
237
+ isFailure(e) {
238
+ return e.type === "Failure";
239
+ },
240
+ /**
241
+ * Gets the value of a `Result` if it is a `Success`, otherwise returns the provided default value.
242
+ * @param r - The `Result` to get the value from.
243
+ * @param alt - The default value to return if the `Result` is a `Failure`.
244
+ * @returns The value of the `Result` if it is a `Success`, otherwise the default value.
245
+ * @public
246
+ */
247
+ getOrElse(e, r) {
248
+ return s.isSuccess(e) ? e.value : r;
249
+ },
250
+ /**
251
+ * Gets the value of a `Result` if it is a `Success`, otherwise returns the result of the provided function.
252
+ * @param r - The `Result` to get the value from.
253
+ * @param altf - The function to call if the `Result` is a `Failure`.
254
+ * @returns The value of the `Result` if it is a `Success`, otherwise the result of the function.
255
+ * @public
256
+ */
257
+ getOrElseLazy(e, r) {
258
+ return s.isSuccess(e) ? e.value : r();
259
+ },
260
+ /**
261
+ * Gets the value of a `Result` if it is a `Success`, otherwise returns `null`.
262
+ * @param r - The `Result` to get the value from.
263
+ * @returns The value of the `Result` if it is a `Success`, otherwise `null`.
264
+ * @public
265
+ */
266
+ getOrNull(e) {
267
+ return s.isSuccess(e) ? e.value : null;
268
+ },
269
+ /**
270
+ * Gets the value of a `Result` if it is a `Success`, otherwise returns `undefined`.
271
+ * @param r - The `Result` to get the value from.
272
+ * @returns The value of the `Result` if it is a `Success`, otherwise `undefined`.
273
+ * @public
274
+ */
275
+ getOrUndefined(e) {
276
+ return s.isSuccess(e) ? e.value : void 0;
277
+ },
278
+ /**
279
+ * Gets the value of a `Result` if it is a `Success`, otherwise it throws the error contained in the `Failure`.
280
+ * @param r - The `Result` to get the value from.
281
+ * @returns The value of the `Result` if it is a `Success`.
282
+ */
283
+ getUnsafe: (e) => {
284
+ if (s.isSuccess(e))
285
+ return e.value;
286
+ throw e.error;
287
+ },
288
+ /**
289
+ * Based on the state of the result, it picks the appropriate function to call and returns the result.
290
+ * @param success - The function to call if the result is a success.
291
+ * @param failure - The function to call if the result is a failure.
292
+ * @returns The result of calling the appropriate function based on the state of the result.
293
+ * @public
294
+ */
295
+ match: (e, r, u) => s.isSuccess(e) ? r(e.value) : u(e.error),
296
+ /**
297
+ * Calls the provided function if the result is a success.
298
+ * @param apply - The function to call if the result is a success.
299
+ * @returns A function that takes a `Result` and calls the provided function if the result is a success.
300
+ * @public
301
+ */
302
+ whenSuccess: (e, r) => (s.isSuccess(e) && r(e.value), e),
303
+ whenFailure: (e, r) => (s.isFailure(e) && r(e.error), e),
304
+ /**
305
+ * Combines two results into a single result.
306
+ * @param r1 - The first result.
307
+ * @param r2 - The second result.
308
+ * @param combineV - The function to combine two values.
309
+ * @param combineE - The function to combine two errors.
310
+ * @returns The combined result.
311
+ * @public
312
+ */
313
+ combine: (e, r, u, t) => s.match(
314
+ e,
315
+ (l) => s.match(
316
+ r,
317
+ (a) => s.success(u(l, a)),
318
+ (a) => s.failure(a)
319
+ ),
320
+ (l) => s.match(
321
+ r,
322
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
323
+ (a) => s.failure(l),
324
+ (a) => s.failure(t(l, a))
325
+ )
326
+ ),
327
+ /**
328
+ * Compares two results for equality.
329
+ * @param r1 - The first result.
330
+ * @param r2 - The second result.
331
+ * @param options - The options to use for comparison. By default, uses strict equality.
332
+ * @returns `true` if the results are equal, `false` otherwise.
333
+ */
334
+ equals: (e, r, u = {
335
+ valueEquals: (t, l) => t === l,
336
+ errorEquals: (t, l) => t === l
337
+ }) => e.type === "Success" && r.type === "Success" ? u.valueEquals(e.value, r.value) : e.type === "Failure" && r.type === "Failure" ? u.errorEquals(e.error, r.error) : !1,
338
+ /**
339
+ * Combines multiple results into a single result.
340
+ * @param results - The results to combine.
341
+ * @returns A single result that is a success if all the input results are successes, otherwise a failure.
342
+ */
343
+ all: (e) => {
344
+ const r = [];
345
+ for (const u of e)
346
+ if (s.isSuccess(u))
347
+ r.push(u.value);
348
+ else
349
+ return u;
350
+ return s.success(r);
351
+ },
352
+ /**
353
+ * Maps the error of a failed `Result` to a new error using the provided function.
354
+ * For success results, the result is preserved unchanged.
355
+ * @param r - The `Result` to map the error of.
356
+ * @param f - The mapping function to apply to the error.
357
+ * @returns A new `Result` with the mapped error if failed, otherwise the original success.
358
+ * @public
359
+ */
360
+ mapError: (e, r) => e.type === "Failure" ? s.failure(r(e.error)) : e,
361
+ /**
362
+ * Maps the error of a failed `Result` to a new `Result` using the provided function.
363
+ * This allows recovery from errors by returning a new successful result.
364
+ * @param r - The `Result` to recover from.
365
+ * @param f - The recovery function that returns a new `Result`.
366
+ * @returns The result of the recovery function if failed, otherwise the original success.
367
+ * @public
368
+ */
369
+ flatMapError: (e, r) => e.type === "Failure" ? r(e.error) : e,
370
+ /**
371
+ * Recovers from a failure by providing an alternative value.
372
+ * @param r - The `Result` to recover from.
373
+ * @param f - The function that provides an alternative value given the error.
374
+ * @returns A successful `Result` with the alternative value if failed, otherwise the original success.
375
+ * @public
376
+ */
377
+ recover: (e, r) => e.type === "Failure" ? { type: "Success", value: r(e.error) } : e,
378
+ /**
379
+ * Applies a function wrapped in a `Result` to a value wrapped in a `Result`.
380
+ * Useful for applying multiple arguments to a function in a safe way.
381
+ * @param resultFn - The `Result` containing the function.
382
+ * @param resultVal - The `Result` containing the value.
383
+ * @returns A new `Result` with the result of applying the function to the value.
384
+ * @public
385
+ */
386
+ ap: (e, r) => s.isSuccess(e) && s.isSuccess(r) ? s.success(e.value(r.value)) : s.isFailure(e) ? s.failure(e.error) : s.failure(r.error),
387
+ /**
388
+ * Maps two `Result` values using a function.
389
+ * @param r1 - The first `Result`.
390
+ * @param r2 - The second `Result`.
391
+ * @param f - The function to apply to both values.
392
+ * @returns A new `Result` with the result of applying the function to both values.
393
+ * @public
394
+ */
395
+ map2: (e, r, u) => s.isSuccess(e) && s.isSuccess(r) ? s.success(u(e.value, r.value)) : s.isFailure(e) ? s.failure(e.error) : s.failure(r.error),
396
+ /**
397
+ * Maps three `Result` values using a function.
398
+ * @param r1 - The first `Result`.
399
+ * @param r2 - The second `Result`.
400
+ * @param r3 - The third `Result`.
401
+ * @param f - The function to apply to all three values.
402
+ * @returns A new `Result` with the result of applying the function to all three values.
403
+ * @public
404
+ */
405
+ map3: (e, r, u, t) => s.isSuccess(e) && s.isSuccess(r) && s.isSuccess(u) ? s.success(t(e.value, r.value, u.value)) : s.isFailure(e) ? s.failure(e.error) : s.isFailure(r) ? s.failure(r.error) : s.failure(u.error),
406
+ /**
407
+ * Converts a Promise to a Result.
408
+ * @param p - The Promise to convert.
409
+ * @returns A Promise that resolves to a Result.
410
+ * @public
411
+ */
412
+ ofPromise: async (e) => {
413
+ try {
414
+ const r = await e;
415
+ return s.success(r);
416
+ } catch (r) {
417
+ return s.failure(r instanceof Error ? r : new Error(String(r)));
418
+ }
419
+ },
420
+ /**
421
+ * Swaps the success and failure values of a Result.
422
+ * A success becomes a failure with the value as the error,
423
+ * and a failure becomes a success with the error as the value.
424
+ * @param r - The Result to swap.
425
+ * @returns A new Result with swapped success and failure.
426
+ * @public
427
+ */
428
+ swap: (e) => s.isSuccess(e) ? s.failure(e.value) : s.success(e.error),
429
+ /**
430
+ * Converts a nullable value to a Result.
431
+ * @param value - The nullable value.
432
+ * @param error - The error to use if the value is null or undefined.
433
+ * @returns A Result containing the value if not null/undefined, otherwise a failure.
434
+ * @public
435
+ */
436
+ fromNullable: (e, r) => e == null ? s.failure(r) : s.success(e),
437
+ /**
438
+ * Converts a nullable value to a Result using a lazy error function.
439
+ * @param value - The nullable value.
440
+ * @param errorFn - The function to call to get the error if the value is null or undefined.
441
+ * @returns A Result containing the value if not null/undefined, otherwise a failure.
442
+ * @public
443
+ */
444
+ fromNullableLazy: (e, r) => e == null ? s.failure(r()) : s.success(e),
445
+ /**
446
+ * Wraps a function that may throw into a function that returns a Result.
447
+ * @param f - The function that may throw.
448
+ * @returns A function that returns a Result instead of throwing.
449
+ * @public
450
+ */
451
+ tryCatch: (e) => {
452
+ try {
453
+ return s.success(e());
454
+ } catch (r) {
455
+ return s.failure(r instanceof Error ? r : new Error(String(r)));
456
+ }
457
+ }
458
+ };
459
+ export {
460
+ s as R,
461
+ i as V
462
+ };
@@ -0,0 +1 @@
1
+ "use strict";const n=require("./async-result.cjs"),i={valid:{type:"valid"},invalid(e){return{type:"invalid",error:e}},isValid(e){return e.type==="valid"},isInvalid(e){return e.type==="invalid"},match:(e,r,u)=>i.isValid(e)?r():u(e.error),toResult:(e,r)=>i.match(e,()=>s.success(r),u=>s.failure(u)),whenValid:(e,r)=>(i.isValid(e)&&r(),e),whenInvalid:(e,r)=>(i.isInvalid(e)&&r(e.error),e),mapError:(e,r)=>e.type==="invalid"?i.invalid(r(e.error)):e,flatMapError:(e,r)=>e.type==="invalid"?r(e.error):e,combine:(e,r,u)=>i.isValid(e)&&i.isValid(r)?i.valid:i.isInvalid(e)&&i.isInvalid(r)?i.invalid(u(e.error,r.error)):i.isInvalid(e)?e:r,all:e=>{for(const r of e)if(i.isInvalid(r))return r;return i.valid},allErrors:e=>{const r=[];for(const u of e)i.isInvalid(u)&&r.push(u.error);return r.length>0?i.invalid(r):i.valid},equals:(e,r,u=(t,l)=>t===l)=>e.type==="valid"&&r.type==="valid"?!0:e.type==="invalid"&&r.type==="invalid"?u(e.error,r.error):!1,recover:e=>i.valid,getError:e=>{if(i.isInvalid(e))return e.error},getErrorOrElse:(e,r)=>i.isInvalid(e)?e.error:r},s={success(e){return{type:"Success",value:e}},failure(e){return{type:"Failure",error:e}},map:(e,r)=>e.type==="Success"?s.success(r(e.value)):e,flatMap:(e,r)=>e.type==="Success"?r(e.value):e,toAsync(e){return s.match(e,r=>n.AsyncResult.success(r),r=>n.AsyncResult.failure(r))},toValidation(e){return s.match(e,()=>i.valid,r=>i.invalid(r))},isSuccess(e){return e.type==="Success"},isFailure(e){return e.type==="Failure"},getOrElse(e,r){return s.isSuccess(e)?e.value:r},getOrElseLazy(e,r){return s.isSuccess(e)?e.value:r()},getOrNull(e){return s.isSuccess(e)?e.value:null},getOrUndefined(e){return s.isSuccess(e)?e.value:void 0},getUnsafe:e=>{if(s.isSuccess(e))return e.value;throw e.error},match:(e,r,u)=>s.isSuccess(e)?r(e.value):u(e.error),whenSuccess:(e,r)=>(s.isSuccess(e)&&r(e.value),e),whenFailure:(e,r)=>(s.isFailure(e)&&r(e.error),e),combine:(e,r,u,t)=>s.match(e,l=>s.match(r,a=>s.success(u(l,a)),a=>s.failure(a)),l=>s.match(r,a=>s.failure(l),a=>s.failure(t(l,a)))),equals:(e,r,u={valueEquals:(t,l)=>t===l,errorEquals:(t,l)=>t===l})=>e.type==="Success"&&r.type==="Success"?u.valueEquals(e.value,r.value):e.type==="Failure"&&r.type==="Failure"?u.errorEquals(e.error,r.error):!1,all:e=>{const r=[];for(const u of e)if(s.isSuccess(u))r.push(u.value);else return u;return s.success(r)},mapError:(e,r)=>e.type==="Failure"?s.failure(r(e.error)):e,flatMapError:(e,r)=>e.type==="Failure"?r(e.error):e,recover:(e,r)=>e.type==="Failure"?{type:"Success",value:r(e.error)}:e,ap:(e,r)=>s.isSuccess(e)&&s.isSuccess(r)?s.success(e.value(r.value)):s.isFailure(e)?s.failure(e.error):s.failure(r.error),map2:(e,r,u)=>s.isSuccess(e)&&s.isSuccess(r)?s.success(u(e.value,r.value)):s.isFailure(e)?s.failure(e.error):s.failure(r.error),map3:(e,r,u,t)=>s.isSuccess(e)&&s.isSuccess(r)&&s.isSuccess(u)?s.success(t(e.value,r.value,u.value)):s.isFailure(e)?s.failure(e.error):s.isFailure(r)?s.failure(r.error):s.failure(u.error),ofPromise:async e=>{try{const r=await e;return s.success(r)}catch(r){return s.failure(r instanceof Error?r:new Error(String(r)))}},swap:e=>s.isSuccess(e)?s.failure(e.value):s.success(e.error),fromNullable:(e,r)=>e==null?s.failure(r):s.success(e),fromNullableLazy:(e,r)=>e==null?s.failure(r()):s.success(e),tryCatch:e=>{try{return s.success(e())}catch(r){return s.failure(r instanceof Error?r:new Error(String(r)))}}};exports.Result=s;exports.Validation=i;
package/result.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./async-result.cjs");const e=require("./result-CdwVhaAc.cjs");exports.Result=e.Result;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require("./async-result.cjs");const e=require("./result-cY1uEC-G.cjs");exports.Result=e.Result;
package/result.d.ts CHANGED
@@ -175,4 +175,97 @@ export declare const Result: {
175
175
  * @returns A single result that is a success if all the input results are successes, otherwise a failure.
176
176
  */
177
177
  all: <V, E>(results: Result<V, E>[]) => Result<V[], E>;
178
+ /**
179
+ * Maps the error of a failed `Result` to a new error using the provided function.
180
+ * For success results, the result is preserved unchanged.
181
+ * @param r - The `Result` to map the error of.
182
+ * @param f - The mapping function to apply to the error.
183
+ * @returns A new `Result` with the mapped error if failed, otherwise the original success.
184
+ * @public
185
+ */
186
+ mapError: <V, E, F>(r: Result<V, E>, f: (error: E) => F) => Result<V, F>;
187
+ /**
188
+ * Maps the error of a failed `Result` to a new `Result` using the provided function.
189
+ * This allows recovery from errors by returning a new successful result.
190
+ * @param r - The `Result` to recover from.
191
+ * @param f - The recovery function that returns a new `Result`.
192
+ * @returns The result of the recovery function if failed, otherwise the original success.
193
+ * @public
194
+ */
195
+ flatMapError: <V, E, F>(r: Result<V, E>, f: (error: E) => Result<V, F>) => Result<V, F>;
196
+ /**
197
+ * Recovers from a failure by providing an alternative value.
198
+ * @param r - The `Result` to recover from.
199
+ * @param f - The function that provides an alternative value given the error.
200
+ * @returns A successful `Result` with the alternative value if failed, otherwise the original success.
201
+ * @public
202
+ */
203
+ recover: <V, E>(r: Result<V, E>, f: (error: E) => V) => Result<V, never>;
204
+ /**
205
+ * Applies a function wrapped in a `Result` to a value wrapped in a `Result`.
206
+ * Useful for applying multiple arguments to a function in a safe way.
207
+ * @param resultFn - The `Result` containing the function.
208
+ * @param resultVal - The `Result` containing the value.
209
+ * @returns A new `Result` with the result of applying the function to the value.
210
+ * @public
211
+ */
212
+ ap: <V, U, E>(resultFn: Result<(v: V) => U, E>, resultVal: Result<V, E>) => Result<U, E>;
213
+ /**
214
+ * Maps two `Result` values using a function.
215
+ * @param r1 - The first `Result`.
216
+ * @param r2 - The second `Result`.
217
+ * @param f - The function to apply to both values.
218
+ * @returns A new `Result` with the result of applying the function to both values.
219
+ * @public
220
+ */
221
+ map2: <V1, V2, U, E>(r1: Result<V1, E>, r2: Result<V2, E>, f: (v1: V1, v2: V2) => U) => Result<U, E>;
222
+ /**
223
+ * Maps three `Result` values using a function.
224
+ * @param r1 - The first `Result`.
225
+ * @param r2 - The second `Result`.
226
+ * @param r3 - The third `Result`.
227
+ * @param f - The function to apply to all three values.
228
+ * @returns A new `Result` with the result of applying the function to all three values.
229
+ * @public
230
+ */
231
+ map3: <V1, V2, V3, U, E>(r1: Result<V1, E>, r2: Result<V2, E>, r3: Result<V3, E>, f: (v1: V1, v2: V2, v3: V3) => U) => Result<U, E>;
232
+ /**
233
+ * Converts a Promise to a Result.
234
+ * @param p - The Promise to convert.
235
+ * @returns A Promise that resolves to a Result.
236
+ * @public
237
+ */
238
+ ofPromise: <V>(p: Promise<V>) => Promise<Result<V, Error>>;
239
+ /**
240
+ * Swaps the success and failure values of a Result.
241
+ * A success becomes a failure with the value as the error,
242
+ * and a failure becomes a success with the error as the value.
243
+ * @param r - The Result to swap.
244
+ * @returns A new Result with swapped success and failure.
245
+ * @public
246
+ */
247
+ swap: <V, E>(r: Result<V, E>) => Result<E, V>;
248
+ /**
249
+ * Converts a nullable value to a Result.
250
+ * @param value - The nullable value.
251
+ * @param error - The error to use if the value is null or undefined.
252
+ * @returns A Result containing the value if not null/undefined, otherwise a failure.
253
+ * @public
254
+ */
255
+ fromNullable: <V, E>(value: V | null | undefined, error: E) => Result<V, E>;
256
+ /**
257
+ * Converts a nullable value to a Result using a lazy error function.
258
+ * @param value - The nullable value.
259
+ * @param errorFn - The function to call to get the error if the value is null or undefined.
260
+ * @returns A Result containing the value if not null/undefined, otherwise a failure.
261
+ * @public
262
+ */
263
+ fromNullableLazy: <V, E>(value: V | null | undefined, errorFn: () => E) => Result<V, E>;
264
+ /**
265
+ * Wraps a function that may throw into a function that returns a Result.
266
+ * @param f - The function that may throw.
267
+ * @returns A function that returns a Result instead of throwing.
268
+ * @public
269
+ */
270
+ tryCatch: <V>(f: () => V) => Result<V, Error>;
178
271
  };
package/result.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./async-result.js";
2
- import { R as e } from "./result-CGd0jCdl.js";
2
+ import { R as e } from "./result-BrVFeaNO.js";
3
3
  export {
4
4
  e as Result
5
5
  };
package/string.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./error.cjs"),f=require("./regexp.cjs"),T=(t,e)=>{const n=t.indexOf(e);return n<0?"":t.substring(n+e.length)},z=(t,e)=>{const n=t.lastIndexOf(e);return n<0?"":t.substring(n+e.length)},j=(t,e)=>{const n=t.indexOf(e);return n<0?"":t.substring(0,n)},M=(t,e)=>{const n=t.lastIndexOf(e);return n<0?"":t.substring(0,n)},a=t=>t.substring(0,1).toUpperCase()+t.substring(1),p=t=>t.toUpperCase(),N=(t,e=!1)=>e?f.mapRegExp(a(t),Ut,p):f.mapRegExp(a(t),Mt,p),_=t=>t.replace(Ht,`
2
- `),U=(t,e)=>t==null&&e==null?0:t==null?-1:e==null?1:d(t.toLowerCase(),e.toLowerCase()),k=(t,e)=>t.substring(t.length-e.length).toLowerCase()===e.toLowerCase(),F=(t,e)=>t.substring(0,e.length).toLowerCase()===e.toLowerCase(),H=(t,e)=>S(t.toLowerCase(),e.map(n=>n.toLowerCase())),$=(t,e)=>I(t.toLowerCase(),e.map(n=>n.toLowerCase())),D=t=>t.trim().replace(E," "),d=(t,e)=>t<e?-1:t>e?1:0,g=(t,e)=>t.toLowerCase().includes(e.toLowerCase()),R=(t,e)=>t.split(e).length-1,P=(t,e)=>e.some(n=>g(t,n)),Z=(t,e)=>e.some(n=>t.includes(n)),q=(t,e)=>e.every(n=>g(t,n)),Q=(t,e)=>e.every(n=>t.includes(n)),G=t=>t.replace(/_/g,"-"),K=(t,e)=>{if(t===e)return-1;const n=Math.min(t.length,e.length);for(let r=0;r<n;r++)if(t.substring(r,r+1)!==e.substring(r,r+1))return r;return n},C=(t,e=20,n="…")=>{const r=t.length,s=n.length;return r>e?e<s?n.slice(s-e,e):t.slice(0,e-s)+n:t},J=(t,e=20,n="…")=>{const r=t.length,s=n.length;if(r>e){if(e<=s)return C(t,e,n);const c=Math.ceil((e-s)/2),u=Math.floor((e-s)/2);return t.slice(0,c)+n+t.slice(r-u)}else return t},S=(t,e)=>e.some(n=>t.endsWith(n)),V=(t,e)=>Array.from(t).filter(e).join(""),X=(t,e)=>w(t).filter(e).map(r=>String.fromCharCode(r)).join(""),Y=(t,e=2166136261)=>{let n=e;for(let r=0,s=t.length;r<s;r++)n^=t.charCodeAt(r),n+=(n<<1)+(n<<4)+(n<<7)+(n<<8)+(n<<24);return n>>>0},v=t=>t!=null&&t.length>0,tt=t=>W(t).split("_").join(" "),et=t=>t.length>0&&!_t.test(t),nt=t=>kt.test(t),rt=t=>!Nt.test(t),st=t=>t.toLowerCase()===t,it=t=>t.toUpperCase()===t,ot=(t,e)=>t!=null&&t!==""?t:e,ct=t=>Ft.test(t),ut=t=>t==null||t==="",at=t=>t.substring(0,1).toLowerCase()+t.substring(1),A=(t,e=1)=>{const n=Math.floor((t.length-e+1)*Math.random());return t.substring(n,n+e)},b=(t,e)=>Array.from({length:e},()=>A(t)).join(""),lt=t=>b(jt,t),gt=(t,e)=>Array.from(e).map(t),ft=(t,e)=>t.split(e).join(""),pt=(t,e)=>t.endsWith(e)?t.substring(0,t.length-e.length):t,ht=(t,e,n)=>t.substring(0,e)+t.substring(e+n),dt=(t,e)=>t.startsWith(e)?t.substring(e.length):t,Ct=(t,e)=>{const n=t.indexOf(e);return n<0?t:t.substring(0,n)+t.substring(n+e.length)},St=t=>{const e=Array.from(t);return e.reverse(),e.join("")},m=(t,e="'")=>e==="'"?t.includes("'")?t.includes('"')?"'"+t.split("'").join("\\'")+"'":'"'+t+'"':"'"+t+"'":t.includes('"')?t.includes("'")?'"'+t.split('"').join('\\"')+'"':"'"+t+"'":'"'+t+'"',L=(t,e="'")=>e+t.split(e).join("\\"+e)+e,At=(t,e="'")=>t.indexOf(`
3
- `)>=0?L(t,"`"):m(t,e),bt=(t,e)=>{const n=t.indexOf(e);return n<0?[t]:[t.substring(0,n),t.substring(n+e.length)]},I=(t,e)=>e.some(n=>t.startsWith(n)),mt=(t,e,n=e)=>`${e}${t}${n}`,w=t=>Array.from({length:t.length},(e,n)=>t.charCodeAt(n)),Lt=(t,e)=>{const n=[];for(;t.length>0;)n.push(t.substring(0,e)),t=t.substring(e);return n},It=t=>t.split(B),wt=(t,e)=>y(x(t,e),e),x=(t,e)=>{let n=0;for(let r=0;r<t.length&&e.includes(t.charAt(r));r++)n++;return t.substring(n)},y=(t,e)=>{const n=t.length;let r=n,s;for(let c=0;c<n&&(s=n-c-1,e.includes(t.charAt(s)));c++)r=s;return t.substring(0,r)},W=t=>(t=t.replace(/::/g,"/"),t=t.replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2"),t=t.replace(/([a-z\d])([A-Z])/g,"$1_$2"),t=t.replace(/-/g,"_"),t.toLowerCase()),xt=t=>t.substring(0,1).toUpperCase()+t.substring(1),yt=(t,e=78,n="",r=`
4
- `)=>t.split(B).map(s=>O(s.replace(E," ").trim(),e,n,r)).join(r),l=(t,e)=>{if(e<0||e>=t.length)return!1;const n=t.charCodeAt(e);return n===9||n===10||n===11||n===12||n===13||n===32},Wt=t=>{if(typeof Buffer<"u")return Buffer.from(t).toString("base64");if(typeof btoa<"u")return btoa(t);throw new h.MissingImplementationError("No implementation found for base64 encoding")},Ot=t=>{if(typeof Buffer<"u")return Buffer.from(t,"base64").toString("utf8");if(typeof atob<"u")return atob(t);throw new h.MissingImplementationError("No implementation found for base64 decoding")},O=(t,e,n,r)=>{const s=[],c=t.length,u=n.length;let o=0;for(e-=u;;){if(o+e>=c-u){s.push(t.substring(o));break}let i=0;for(;!l(t,o+e-i)&&i<e;)i++;if(i===e){for(i=0;!l(t,o+e+i)&&o+e+i<c;)i++;s.push(t.substring(o,o+e+i)),o+=e+i+1}else s.push(t.substring(o,o+e-i)),o+=e-i+1}return n+s.join(r+n)},Et=(t,e,n)=>{const r=n-t.length;return r>0?e.repeat(r)+t:t},Bt=(t,e,n)=>{const r=n-t.length;return r>0?t+e.repeat(r):t},Tt=(t,e)=>{const n=t.lastIndexOf(e);return n>=0?[t.substring(0,n),t.substring(n+e.length)]:[t]},zt=(t,e)=>{const n=t.indexOf(e);return n>=0?[t.substring(0,n),t.substring(n+e.length)]:[t]},jt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Mt=/[^a-zA-Z]([a-z])/g,Nt=/[^\t\n\r ]/,_t=/[^a-zA-Z]/,Ut=/[ \t\r\n][a-z]/g,kt=/^[a-z0-9]+$/i,Ft=/^[0-9]+$/,E=/[ \t\r\n]+/g,B=/\r\n|\n\r|\n|\r/g,Ht=/\r\n|\n\r|\r/g;exports.canonicalizeNewlines=_;exports.capitalize=a;exports.capitalizeWords=N;exports.chunkString=Lt;exports.collapseText=D;exports.compareCaseInsensitive=U;exports.compareStrings=d;exports.containsAllText=Q;exports.containsAllTextCaseInsensitive=q;exports.containsAnyText=Z;exports.containsAnyTextCaseInsensitive=P;exports.countStringOccurrences=R;exports.dasherize=G;exports.decodeBase64=Ot;exports.deleteFirstFromString=Ct;exports.deleteStringAfter=pt;exports.deleteStringBefore=dt;exports.deleteSubstring=ft;exports.ellipsis=C;exports.ellipsisMiddle=J;exports.encodeBase64=Wt;exports.filterCharcodes=X;exports.filterChars=V;exports.humanize=tt;exports.ifEmptyString=ot;exports.isAlpha=et;exports.isAlphaNum=nt;exports.isBreakingWhitespace=rt;exports.isDigitsOnly=ct;exports.isEmptyString=ut;exports.isLowerCase=st;exports.isSpaceAt=l;exports.isUpperCase=it;exports.jsQuote=At;exports.lowerCaseFirst=at;exports.lpad=Et;exports.mapChars=gt;exports.quote=L;exports.randomStringSequence=b;exports.randomStringSequenceBase64=lt;exports.randomSubString=A;exports.reverseString=St;exports.rpad=Bt;exports.smartQuote=m;exports.splitStringOnFirst=zt;exports.splitStringOnLast=Tt;exports.splitStringOnce=bt;exports.stringEndsWithAny=S;exports.stringHasContent=v;exports.stringHashCode=Y;exports.stringStartsWithAny=I;exports.stringToCharcodes=w;exports.stringsDifferAtIndex=K;exports.substringAfter=T;exports.substringAfterLast=z;exports.substringBefore=j;exports.substringBeforeLast=M;exports.surroundString=mt;exports.textContainsCaseInsensitive=g;exports.textEndsWithAnyCaseInsensitive=H;exports.textEndsWithCaseInsensitive=k;exports.textStartsWithAnyCaseInsensitive=$;exports.textStartsWithCaseInsensitive=F;exports.textToLines=It;exports.trimChars=wt;exports.trimCharsLeft=x;exports.trimCharsRight=y;exports.trimStringSlice=ht;exports.underscore=W;exports.upperCaseFirst=xt;exports.wrapColumns=yt;exports.wrapLine=O;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./error.cjs"),f=require("./regexp.cjs"),T=(t,e)=>{const n=t.indexOf(e);return n<0?"":t.substring(n+e.length)},z=(t,e)=>{const n=t.lastIndexOf(e);return n<0?"":t.substring(n+e.length)},j=(t,e)=>{const n=t.indexOf(e);return n<0?"":t.substring(0,n)},M=(t,e)=>{const n=t.lastIndexOf(e);return n<0?"":t.substring(0,n)},u=t=>t.substring(0,1).toUpperCase()+t.substring(1),p=t=>t.toUpperCase(),N=(t,e=!1)=>e?f.mapRegExp(u(t),Ut,p):f.mapRegExp(u(t),Mt,p),_=t=>t.replace(Ht,`
2
+ `),U=(t,e)=>t==null&&e==null?0:t==null?-1:e==null?1:d(t.toLowerCase(),e.toLowerCase()),k=(t,e)=>t.substring(t.length-e.length).toLowerCase()===e.toLowerCase(),F=(t,e)=>t.substring(0,e.length).toLowerCase()===e.toLowerCase(),H=(t,e)=>C(t.toLowerCase(),e.map(n=>n.toLowerCase())),$=(t,e)=>I(t.toLowerCase(),e.map(n=>n.toLowerCase())),D=t=>t.trim().replace(E," "),d=(t,e)=>t<e?-1:t>e?1:0,g=(t,e)=>t.toLowerCase().includes(e.toLowerCase()),R=(t,e)=>t.split(e).length-1,P=(t,e)=>e.some(n=>g(t,n)),Z=(t,e)=>e.some(n=>t.includes(n)),q=(t,e)=>e.every(n=>g(t,n)),Q=(t,e)=>e.every(n=>t.includes(n)),G=t=>t.replace(/_/g,"-"),K=(t,e)=>{if(t===e)return-1;const n=Math.min(t.length,e.length);for(let r=0;r<n;r++)if(t.substring(r,r+1)!==e.substring(r,r+1))return r;return n},S=(t,e=20,n="…")=>{const r=t.length,s=n.length;return r>e?e<s?n.slice(s-e,e):t.slice(0,e-s)+n:t},J=(t,e=20,n="…")=>{const r=t.length,s=n.length;if(r>e){if(e<=s)return S(t,e,n);const c=Math.ceil((e-s)/2),a=Math.floor((e-s)/2);return t.slice(0,c)+n+t.slice(r-a)}else return t},C=(t,e)=>e.some(n=>t.endsWith(n)),V=(t,e)=>Array.from(t).filter(e).join(""),X=(t,e)=>w(t).filter(e).map(r=>String.fromCharCode(r)).join(""),Y=(t,e=2166136261)=>{let n=e;for(let r=0,s=t.length;r<s;r++)n^=t.charCodeAt(r),n+=(n<<1)+(n<<4)+(n<<7)+(n<<8)+(n<<24);return n>>>0},v=t=>t!=null&&t.length>0,tt=t=>W(t).split("_").join(" "),et=t=>t.length>0&&!_t.test(t),nt=t=>kt.test(t),rt=t=>!Nt.test(t),st=t=>t.toLowerCase()===t,it=t=>t.toUpperCase()===t,ot=(t,e)=>t!=null&&t!==""?t:e,ct=t=>Ft.test(t),at=t=>t==null||t==="",ut=t=>t.substring(0,1).toLowerCase()+t.substring(1),A=(t,e=1)=>{const n=Math.floor((t.length-e+1)*Math.random());return t.substring(n,n+e)},b=(t,e)=>Array.from({length:e},()=>A(t)).join(""),lt=t=>b(jt,t),gt=(t,e)=>Array.from(e).map(t),ft=(t,e)=>t.split(e).join(""),pt=(t,e)=>t.endsWith(e)?t.substring(0,t.length-e.length):t,ht=(t,e,n)=>t.substring(0,e)+t.substring(e+n),dt=(t,e)=>t.startsWith(e)?t.substring(e.length):t,St=(t,e)=>{const n=t.indexOf(e);return n<0?t:t.substring(0,n)+t.substring(n+e.length)},Ct=t=>{const e=Array.from(t);return e.reverse(),e.join("")},m=(t,e="'")=>e==="'"?t.includes("'")?t.includes('"')?"'"+t.split("'").join("\\'")+"'":'"'+t+'"':"'"+t+"'":t.includes('"')?t.includes("'")?'"'+t.split('"').join('\\"')+'"':"'"+t+"'":'"'+t+'"',L=(t,e="'")=>e+t.split(e).join("\\"+e)+e,At=(t,e="'")=>t.indexOf(`
3
+ `)>=0?L(t,"`"):m(t,e),bt=(t,e)=>{const n=t.indexOf(e);return n<0?[t]:[t.substring(0,n),t.substring(n+e.length)]},I=(t,e)=>e.some(n=>t.startsWith(n)),mt=(t,e,n=e)=>`${e}${t}${n}`,w=t=>Array.from({length:t.length},(e,n)=>t.charCodeAt(n)),Lt=(t,e)=>{const n=[];for(let r=0;r<t.length;r+=e)n.push(t.substring(r,r+e));return n},It=t=>t.split(B),wt=(t,e)=>y(x(t,e),e),x=(t,e)=>{const n=new Set(e);let r=0;for(let s=0;s<t.length&&n.has(t.charAt(s));s++)r++;return t.substring(r)},y=(t,e)=>{const n=new Set(e),r=t.length;let s=r,c;for(let a=0;a<r&&(c=r-a-1,n.has(t.charAt(c)));a++)s=c;return t.substring(0,s)},W=t=>(t=t.replace(/::/g,"/"),t=t.replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2"),t=t.replace(/([a-z\d])([A-Z])/g,"$1_$2"),t=t.replace(/-/g,"_"),t.toLowerCase()),xt=t=>t.substring(0,1).toUpperCase()+t.substring(1),yt=(t,e=78,n="",r=`
4
+ `)=>t.split(B).map(s=>O(s.replace(E," ").trim(),e,n,r)).join(r),l=(t,e)=>{if(e<0||e>=t.length)return!1;const n=t.charCodeAt(e);return n===9||n===10||n===11||n===12||n===13||n===32},Wt=t=>{if(typeof Buffer<"u")return Buffer.from(t).toString("base64");if(typeof btoa<"u")return btoa(t);throw new h.MissingImplementationError("No implementation found for base64 encoding")},Ot=t=>{if(typeof Buffer<"u")return Buffer.from(t,"base64").toString("utf8");if(typeof atob<"u")return atob(t);throw new h.MissingImplementationError("No implementation found for base64 decoding")},O=(t,e,n,r)=>{const s=[],c=t.length,a=n.length;let o=0;for(e-=a;;){if(o+e>=c-a){s.push(t.substring(o));break}let i=0;for(;!l(t,o+e-i)&&i<e;)i++;if(i===e){for(i=0;!l(t,o+e+i)&&o+e+i<c;)i++;s.push(t.substring(o,o+e+i)),o+=e+i+1}else s.push(t.substring(o,o+e-i)),o+=e-i+1}return n+s.join(r+n)},Et=(t,e,n)=>{const r=n-t.length;return r>0?e.repeat(r)+t:t},Bt=(t,e,n)=>{const r=n-t.length;return r>0?t+e.repeat(r):t},Tt=(t,e)=>{const n=t.lastIndexOf(e);return n>=0?[t.substring(0,n),t.substring(n+e.length)]:[t]},zt=(t,e)=>{const n=t.indexOf(e);return n>=0?[t.substring(0,n),t.substring(n+e.length)]:[t]},jt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Mt=/[^a-zA-Z]([a-z])/g,Nt=/[^\t\n\r ]/,_t=/[^a-zA-Z]/,Ut=/[ \t\r\n][a-z]/g,kt=/^[a-z0-9]+$/i,Ft=/^[0-9]+$/,E=/[ \t\r\n]+/g,B=/\r\n|\n\r|\n|\r/g,Ht=/\r\n|\n\r|\r/g;exports.canonicalizeNewlines=_;exports.capitalize=u;exports.capitalizeWords=N;exports.chunkString=Lt;exports.collapseText=D;exports.compareCaseInsensitive=U;exports.compareStrings=d;exports.containsAllText=Q;exports.containsAllTextCaseInsensitive=q;exports.containsAnyText=Z;exports.containsAnyTextCaseInsensitive=P;exports.countStringOccurrences=R;exports.dasherize=G;exports.decodeBase64=Ot;exports.deleteFirstFromString=St;exports.deleteStringAfter=pt;exports.deleteStringBefore=dt;exports.deleteSubstring=ft;exports.ellipsis=S;exports.ellipsisMiddle=J;exports.encodeBase64=Wt;exports.filterCharcodes=X;exports.filterChars=V;exports.humanize=tt;exports.ifEmptyString=ot;exports.isAlpha=et;exports.isAlphaNum=nt;exports.isBreakingWhitespace=rt;exports.isDigitsOnly=ct;exports.isEmptyString=at;exports.isLowerCase=st;exports.isSpaceAt=l;exports.isUpperCase=it;exports.jsQuote=At;exports.lowerCaseFirst=ut;exports.lpad=Et;exports.mapChars=gt;exports.quote=L;exports.randomStringSequence=b;exports.randomStringSequenceBase64=lt;exports.randomSubString=A;exports.reverseString=Ct;exports.rpad=Bt;exports.smartQuote=m;exports.splitStringOnFirst=zt;exports.splitStringOnLast=Tt;exports.splitStringOnce=bt;exports.stringEndsWithAny=C;exports.stringHasContent=v;exports.stringHashCode=Y;exports.stringStartsWithAny=I;exports.stringToCharcodes=w;exports.stringsDifferAtIndex=K;exports.substringAfter=T;exports.substringAfterLast=z;exports.substringBefore=j;exports.substringBeforeLast=M;exports.surroundString=mt;exports.textContainsCaseInsensitive=g;exports.textEndsWithAnyCaseInsensitive=H;exports.textEndsWithCaseInsensitive=k;exports.textStartsWithAnyCaseInsensitive=$;exports.textStartsWithCaseInsensitive=F;exports.textToLines=It;exports.trimChars=wt;exports.trimCharsLeft=x;exports.trimCharsRight=y;exports.trimStringSlice=ht;exports.underscore=W;exports.upperCaseFirst=xt;exports.wrapColumns=yt;exports.wrapLine=O;