ts-data-forge 1.4.0 → 1.5.1
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/array/array-utils.d.mts +4 -72
- package/dist/array/array-utils.d.mts.map +1 -1
- package/dist/array/array-utils.mjs +4 -72
- package/dist/array/array-utils.mjs.map +1 -1
- package/dist/functional/optional.d.mts +5 -146
- package/dist/functional/optional.d.mts.map +1 -1
- package/dist/functional/optional.mjs +5 -146
- package/dist/functional/optional.mjs.map +1 -1
- package/dist/functional/result.d.mts +0 -164
- package/dist/functional/result.d.mts.map +1 -1
- package/dist/functional/result.mjs +0 -164
- package/dist/functional/result.mjs.map +1 -1
- package/dist/guard/has-key.d.mts +1 -1
- package/dist/guard/has-key.mjs +1 -1
- package/dist/json/json.d.mts +14 -438
- package/dist/json/json.d.mts.map +1 -1
- package/dist/json/json.mjs +14 -438
- package/dist/json/json.mjs.map +1 -1
- package/dist/number/num.d.mts +6 -103
- package/dist/number/num.d.mts.map +1 -1
- package/dist/number/num.mjs +5 -102
- package/dist/number/num.mjs.map +1 -1
- package/package.json +1 -1
- package/src/array/array-utils.mts +4 -72
- package/src/functional/optional.mts +5 -146
- package/src/functional/result.mts +0 -164
- package/src/guard/has-key.mts +1 -1
- package/src/json/json.mts +14 -438
- package/src/number/num.mts +9 -104
- package/src/number/num.test.mts +2 -1
|
@@ -257,7 +257,6 @@ export declare namespace Result {
|
|
|
257
257
|
* @throws {Error} Error with the stringified error value if the `Result` is `Result.Err`.
|
|
258
258
|
* @example
|
|
259
259
|
* ```typescript
|
|
260
|
-
* // Basic usage with default string conversion
|
|
261
260
|
* const success = Result.ok(42);
|
|
262
261
|
* console.log(Result.unwrapThrow(success)); // 42
|
|
263
262
|
*
|
|
@@ -267,25 +266,6 @@ export declare namespace Result {
|
|
|
267
266
|
* } catch (error) {
|
|
268
267
|
* console.log(error.message); // "Network error"
|
|
269
268
|
* }
|
|
270
|
-
*
|
|
271
|
-
* // Custom error string conversion
|
|
272
|
-
* interface ApiError {
|
|
273
|
-
* code: number;
|
|
274
|
-
* message: string;
|
|
275
|
-
* }
|
|
276
|
-
*
|
|
277
|
-
* const apiResult = Result.err<ApiError>({ code: 404, message: "Not found" });
|
|
278
|
-
* try {
|
|
279
|
-
* Result.unwrapThrow(apiResult, err => `API Error ${err.code}: ${err.message}`);
|
|
280
|
-
* } catch (error) {
|
|
281
|
-
* console.log(error.message); // "API Error 404: Not found"
|
|
282
|
-
* }
|
|
283
|
-
*
|
|
284
|
-
* // In contexts where failure is unexpected
|
|
285
|
-
* const configResult = loadConfiguration();
|
|
286
|
-
* const config = Result.unwrapThrow(configResult, err =>
|
|
287
|
-
* `Failed to load configuration: ${err}`
|
|
288
|
-
* ); // Will throw if config loading fails
|
|
289
269
|
* ```
|
|
290
270
|
*/
|
|
291
271
|
export const unwrapThrow: <R extends Base>(result: R, toStr?: (e: UnwrapErr<R>) => string) => UnwrapOk<R>;
|
|
@@ -338,15 +318,9 @@ export declare namespace Result {
|
|
|
338
318
|
* @returns The success value if `Result.Ok`, otherwise `defaultValue`.
|
|
339
319
|
* @example
|
|
340
320
|
* ```typescript
|
|
341
|
-
* // Regular usage
|
|
342
321
|
* const result = Result.ok(42);
|
|
343
322
|
* const value = Result.unwrapOkOr(result, 0);
|
|
344
323
|
* console.log(value); // 42
|
|
345
|
-
*
|
|
346
|
-
* // Curried usage for pipe composition
|
|
347
|
-
* const unwrapWithDefault = Result.unwrapOkOr(0);
|
|
348
|
-
* const value2 = pipe(Result.err("error")).map(unwrapWithDefault).value;
|
|
349
|
-
* console.log(value2); // 0
|
|
350
324
|
* ```
|
|
351
325
|
*/
|
|
352
326
|
export const unwrapOkOr: UnwrapOkOrFnOverload;
|
|
@@ -369,34 +343,15 @@ export declare namespace Result {
|
|
|
369
343
|
* @throws {Error} Error with message "Expected Err but got Ok: {value}" if the `Result` is `Result.Ok`.
|
|
370
344
|
* @example
|
|
371
345
|
* ```typescript
|
|
372
|
-
* // Basic usage - extracting error from known failure
|
|
373
346
|
* const failure = Result.err("Network timeout");
|
|
374
347
|
* console.log(Result.unwrapErrThrow(failure)); // "Network timeout"
|
|
375
348
|
*
|
|
376
|
-
* // Throws when Result is unexpectedly Ok
|
|
377
349
|
* const success = Result.ok(42);
|
|
378
350
|
* try {
|
|
379
351
|
* Result.unwrapErrThrow(success); // throws Error: "Expected Err but got Ok: 42"
|
|
380
352
|
* } catch (error) {
|
|
381
353
|
* console.log(error.message); // "Expected Err but got Ok: 42"
|
|
382
354
|
* }
|
|
383
|
-
*
|
|
384
|
-
* // Custom success value string conversion
|
|
385
|
-
* interface User { name: string; id: number; }
|
|
386
|
-
* const userResult = Result.ok<User>({ name: "John", id: 123 });
|
|
387
|
-
* try {
|
|
388
|
-
* Result.unwrapErrThrow(userResult, user => `User(${user.name}:${user.id})`);
|
|
389
|
-
* } catch (error) {
|
|
390
|
-
* console.log(error.message); // "Expected Err but got Ok: User(John:123)"
|
|
391
|
-
* }
|
|
392
|
-
*
|
|
393
|
-
* // In error handling contexts
|
|
394
|
-
* const validateAndGetError = (result: Result<any, ValidationError>) => {
|
|
395
|
-
* if (Result.isErr(result)) {
|
|
396
|
-
* return Result.unwrapErrThrow(result); // Safe to unwrap error
|
|
397
|
-
* }
|
|
398
|
-
* throw new Error("Validation unexpectedly succeeded");
|
|
399
|
-
* };
|
|
400
355
|
* ```
|
|
401
356
|
*/
|
|
402
357
|
export const unwrapErrThrow: <R extends Base>(result: R, toStr?: (v: UnwrapOk<R>) => string) => UnwrapErr<R>;
|
|
@@ -412,39 +367,11 @@ export declare namespace Result {
|
|
|
412
367
|
* @returns The error value if `Result.Err`, otherwise `undefined`.
|
|
413
368
|
* @example
|
|
414
369
|
* ```typescript
|
|
415
|
-
* // Basic error extraction
|
|
416
370
|
* const failure = Result.err("Connection failed");
|
|
417
371
|
* console.log(Result.unwrapErr(failure)); // "Connection failed"
|
|
418
372
|
*
|
|
419
373
|
* const success = Result.ok(42);
|
|
420
374
|
* console.log(Result.unwrapErr(success)); // undefined
|
|
421
|
-
*
|
|
422
|
-
* // Error handling patterns
|
|
423
|
-
* const handleApiCall = (result: Result<Data, ApiError>) => {
|
|
424
|
-
* const error = Result.unwrapErr(result);
|
|
425
|
-
* if (error !== undefined) {
|
|
426
|
-
* switch (error.type) {
|
|
427
|
-
* case "NETWORK_ERROR":
|
|
428
|
-
* return retry(result);
|
|
429
|
-
* case "AUTH_ERROR":
|
|
430
|
-
* return redirectToLogin();
|
|
431
|
-
* default:
|
|
432
|
-
* return showGenericError(error);
|
|
433
|
-
* }
|
|
434
|
-
* }
|
|
435
|
-
* // Handle success case...
|
|
436
|
-
* };
|
|
437
|
-
*
|
|
438
|
-
* // Collecting errors from multiple operations
|
|
439
|
-
* const results = await Promise.all([
|
|
440
|
-
* operation1(),
|
|
441
|
-
* operation2(),
|
|
442
|
-
* operation3()
|
|
443
|
-
* ]);
|
|
444
|
-
*
|
|
445
|
-
* const errors = results
|
|
446
|
-
* .map(Result.unwrapErr)
|
|
447
|
-
* .filter(err => err !== undefined); // Only actual errors
|
|
448
375
|
* ```
|
|
449
376
|
*/
|
|
450
377
|
export const unwrapErr: <R extends Base>(result: R) => UnwrapErr<R> | undefined;
|
|
@@ -457,15 +384,9 @@ export declare namespace Result {
|
|
|
457
384
|
* @returns The error value if `Result.Err`, otherwise `defaultValue`.
|
|
458
385
|
* @example
|
|
459
386
|
* ```typescript
|
|
460
|
-
* // Regular usage
|
|
461
387
|
* const result = Result.err("failed");
|
|
462
388
|
* const error = Result.unwrapErrOr(result, "default");
|
|
463
389
|
* console.log(error); // "failed"
|
|
464
|
-
*
|
|
465
|
-
* // Curried usage for pipe composition
|
|
466
|
-
* const unwrapErrorWithDefault = Result.unwrapErrOr("unknown error");
|
|
467
|
-
* const error2 = pipe(Result.ok(42)).map(unwrapErrorWithDefault).value;
|
|
468
|
-
* console.log(error2); // "unknown error"
|
|
469
390
|
* ```
|
|
470
391
|
*/
|
|
471
392
|
export const unwrapErrOr: UnwrapErrOrFnOverload;
|
|
@@ -509,15 +430,9 @@ export declare namespace Result {
|
|
|
509
430
|
* @returns A new `Result<UnwrapOk<R>, E2>`.
|
|
510
431
|
* @example
|
|
511
432
|
* ```typescript
|
|
512
|
-
* // Regular usage
|
|
513
433
|
* const result = Result.err("error");
|
|
514
434
|
* const mapped = Result.mapErr(result, e => e.toUpperCase());
|
|
515
435
|
* console.log(Result.unwrapErr(mapped)); // "ERROR"
|
|
516
|
-
*
|
|
517
|
-
* // Curried usage for pipe composition
|
|
518
|
-
* const errorUppercase = Result.mapErr((e: string) => e.toUpperCase());
|
|
519
|
-
* const result2 = pipe(Result.err("error")).map(errorUppercase).value;
|
|
520
|
-
* console.log(Result.unwrapErr(result2)); // "ERROR"
|
|
521
436
|
* ```
|
|
522
437
|
*/
|
|
523
438
|
export const mapErr: MapErrFnOverload;
|
|
@@ -536,15 +451,9 @@ export declare namespace Result {
|
|
|
536
451
|
* @returns A new `Result<S2, E2>` based on the applied function.
|
|
537
452
|
* @example
|
|
538
453
|
* ```typescript
|
|
539
|
-
* // Regular usage
|
|
540
454
|
* const result = Result.ok(42);
|
|
541
455
|
* const folded = Result.fold(result, x => x * 2, () => 0);
|
|
542
456
|
* console.log(Result.unwrapOk(folded)); // 84
|
|
543
|
-
*
|
|
544
|
-
* // Curried usage for pipe composition
|
|
545
|
-
* const folder = Result.fold((x: number) => x * 2, () => 0);
|
|
546
|
-
* const result2 = pipe(Result.ok(42)).map(folder).value;
|
|
547
|
-
* console.log(Result.unwrapOk(result2)); // 84
|
|
548
457
|
* ```
|
|
549
458
|
*/
|
|
550
459
|
export const fold: FoldFnOverload;
|
|
@@ -564,17 +473,11 @@ export declare namespace Result {
|
|
|
564
473
|
* @returns The result of applying the function, or the original `Err`.
|
|
565
474
|
* @example
|
|
566
475
|
* ```typescript
|
|
567
|
-
* // Regular usage
|
|
568
476
|
* const divide = (a: number, b: number): Result<number, string> =>
|
|
569
477
|
* b === 0 ? Result.err("Division by zero") : Result.ok(a / b);
|
|
570
478
|
*
|
|
571
479
|
* const result = Result.flatMap(Result.ok(10), x => divide(x, 2));
|
|
572
480
|
* console.log(Result.unwrapOk(result)); // 5
|
|
573
|
-
*
|
|
574
|
-
* // Curried usage for pipe composition
|
|
575
|
-
* const divideBy2 = Result.flatMap((x: number) => divide(x, 2));
|
|
576
|
-
* const result2 = pipe(Result.ok(10)).map(divideBy2).value;
|
|
577
|
-
* console.log(Result.unwrapOk(result2)); // 5
|
|
578
481
|
* ```
|
|
579
482
|
*/
|
|
580
483
|
export const flatMap: FlatMapFnOverload;
|
|
@@ -591,15 +494,9 @@ export declare namespace Result {
|
|
|
591
494
|
* @throws Error with the provided message if the `Result` is `Result.Err`.
|
|
592
495
|
* @example
|
|
593
496
|
* ```typescript
|
|
594
|
-
* // Regular usage
|
|
595
497
|
* const result = Result.ok(42);
|
|
596
498
|
* const value = Result.expectToBe(result, "Operation must succeed");
|
|
597
499
|
* console.log(value); // 42
|
|
598
|
-
*
|
|
599
|
-
* // Curried usage for pipe composition
|
|
600
|
-
* const mustBeOk = Result.expectToBe("Operation must succeed");
|
|
601
|
-
* const value2 = pipe(Result.ok(42)).map(mustBeOk).value;
|
|
602
|
-
* console.log(value2); // 42
|
|
603
500
|
* ```
|
|
604
501
|
*/
|
|
605
502
|
export const expectToBe: ExpectToBeFnOverload;
|
|
@@ -649,39 +546,6 @@ export declare namespace Result {
|
|
|
649
546
|
* console.log(validJson.value.valid); // true
|
|
650
547
|
* }
|
|
651
548
|
*
|
|
652
|
-
* const invalidJson = parseJson('{invalid json}');
|
|
653
|
-
* if (Result.isErr(invalidJson)) {
|
|
654
|
-
* console.log(invalidJson.value.message); // SyntaxError message
|
|
655
|
-
* }
|
|
656
|
-
*
|
|
657
|
-
* // Using with custom validation
|
|
658
|
-
* const parsePositiveNumber = (str: string): Result<number, Error> =>
|
|
659
|
-
* Result.fromThrowable(() => {
|
|
660
|
-
* const num = Number(str);
|
|
661
|
-
* if (Number.isNaN(num)) throw new Error(`Not a number: ${str}`);
|
|
662
|
-
* if (num <= 0) throw new Error(`Must be positive: ${num}`);
|
|
663
|
-
* return num;
|
|
664
|
-
* });
|
|
665
|
-
*
|
|
666
|
-
* const success = parsePositiveNumber('42');
|
|
667
|
-
* console.log(Result.unwrapOkOr(success, 0)); // 42
|
|
668
|
-
*
|
|
669
|
-
* const failure = parsePositiveNumber('abc');
|
|
670
|
-
* console.log(Result.unwrapOkOr(failure, 0)); // 0
|
|
671
|
-
*
|
|
672
|
-
* // Wrapping DOM operations that might fail
|
|
673
|
-
* const getElementText = (id: string): Result<string, Error> =>
|
|
674
|
-
* Result.fromThrowable(() => {
|
|
675
|
-
* const element = document.getElementById(id);
|
|
676
|
-
* if (!element) throw new Error(`Element not found: ${id}`);
|
|
677
|
-
* return element.textContent || "";
|
|
678
|
-
* });
|
|
679
|
-
*
|
|
680
|
-
* // Wrapping file operations
|
|
681
|
-
* const readFileSync = (path: string): Result<string, Error> =>
|
|
682
|
-
* Result.fromThrowable(() =>
|
|
683
|
-
* require('fs').readFileSync(path, 'utf8')
|
|
684
|
-
* );
|
|
685
549
|
* ```
|
|
686
550
|
*/
|
|
687
551
|
export const fromThrowable: <T>(fn: () => T) => Result<T, Error>;
|
|
@@ -724,28 +588,6 @@ export declare namespace Result {
|
|
|
724
588
|
* const none = Result.toOptional(errResult);
|
|
725
589
|
* console.log(Optional.isNone(none)); // true
|
|
726
590
|
*
|
|
727
|
-
* // Use case: when you only care about success, not error details
|
|
728
|
-
* const fetchUserName = (id: number): Result<string, ApiError> => {
|
|
729
|
-
* // ... implementation
|
|
730
|
-
* };
|
|
731
|
-
*
|
|
732
|
-
* const maybeUserName = Result.toOptional(fetchUserName(123));
|
|
733
|
-
* const displayName = Optional.unwrapOr(maybeUserName, "Unknown User");
|
|
734
|
-
*
|
|
735
|
-
* // Converting multiple Results and filtering successes
|
|
736
|
-
* const userIds = [1, 2, 3, 4];
|
|
737
|
-
* const userNames = userIds
|
|
738
|
-
* .map(fetchUserName)
|
|
739
|
-
* .map(Result.toOptional)
|
|
740
|
-
* .filter(Optional.isSome)
|
|
741
|
-
* .map(Optional.unwrap); // string[]
|
|
742
|
-
*
|
|
743
|
-
* // Chaining with Optional operations
|
|
744
|
-
* const processResult = (r: Result<string, Error>) =>
|
|
745
|
-
* pipe(Result.toOptional(r))
|
|
746
|
-
* .map(Optional.map(s => s.toUpperCase()))
|
|
747
|
-
* .map(Optional.filter(s => s.length > 0))
|
|
748
|
-
* .value;
|
|
749
591
|
* ```
|
|
750
592
|
*/
|
|
751
593
|
export const toOptional: <R extends Base>(result: R) => Optional<UnwrapOk<R>>;
|
|
@@ -757,16 +599,10 @@ export declare namespace Result {
|
|
|
757
599
|
* @returns The first `Result` if `Ok`, otherwise the alternative.
|
|
758
600
|
* @example
|
|
759
601
|
* ```typescript
|
|
760
|
-
* // Regular usage
|
|
761
602
|
* const primary = Result.err("error");
|
|
762
603
|
* const fallback = Result.ok("default");
|
|
763
604
|
* const result = Result.orElse(primary, fallback);
|
|
764
605
|
* console.log(Result.unwrapOk(result)); // "default"
|
|
765
|
-
*
|
|
766
|
-
* // Curried usage for pipe composition
|
|
767
|
-
* const fallbackTo = Result.orElse(Result.ok("fallback"));
|
|
768
|
-
* const result2 = pipe(Result.err("error")).map(fallbackTo).value;
|
|
769
|
-
* console.log(Result.unwrapOk(result2)); // "fallback"
|
|
770
606
|
* ```
|
|
771
607
|
*/
|
|
772
608
|
export const orElse: OrElseFnOverload;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result.d.mts","sourceRoot":"","sources":["../../src/functional/result.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,2EAA2E;AAC3E,QAAA,MAAM,aAAa,6BAA6B,CAAC;AAEjD,4EAA4E;AAC5E,QAAA,MAAM,cAAc,8BAA8B,CAAC;AAEnD;;;;GAIG;AACH,KAAK,GAAG,CAAC,CAAC,IAAI,QAAQ,CA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AM,EAAE,gBAoBC,CAAC;IAEvB,KAAK,gBAAgB,GAAG;QACtB,CAAC,CAAC,SAAS,IAAI,EAAE,EAAE,SAAS,IAAI,EAC9B,MAAM,EAAE,CAAC,EACT,WAAW,EAAE,EAAE,GACd,UAAU,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC;QAGtB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EACX,WAAW,EAAE,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,GAC1B,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;KAC5D,CAAC;IAEF;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,MAAM,CAAC,MAAM,GAAG,GAAI,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAChC,SAAS,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,EACvB,SAAS,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,KACtB,MAAM,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,CAKvB,CAAC;;CACf"}
|
|
@@ -203,7 +203,6 @@ var Result;
|
|
|
203
203
|
* @throws {Error} Error with the stringified error value if the `Result` is `Result.Err`.
|
|
204
204
|
* @example
|
|
205
205
|
* ```typescript
|
|
206
|
-
* // Basic usage with default string conversion
|
|
207
206
|
* const success = Result.ok(42);
|
|
208
207
|
* console.log(Result.unwrapThrow(success)); // 42
|
|
209
208
|
*
|
|
@@ -213,25 +212,6 @@ var Result;
|
|
|
213
212
|
* } catch (error) {
|
|
214
213
|
* console.log(error.message); // "Network error"
|
|
215
214
|
* }
|
|
216
|
-
*
|
|
217
|
-
* // Custom error string conversion
|
|
218
|
-
* interface ApiError {
|
|
219
|
-
* code: number;
|
|
220
|
-
* message: string;
|
|
221
|
-
* }
|
|
222
|
-
*
|
|
223
|
-
* const apiResult = Result.err<ApiError>({ code: 404, message: "Not found" });
|
|
224
|
-
* try {
|
|
225
|
-
* Result.unwrapThrow(apiResult, err => `API Error ${err.code}: ${err.message}`);
|
|
226
|
-
* } catch (error) {
|
|
227
|
-
* console.log(error.message); // "API Error 404: Not found"
|
|
228
|
-
* }
|
|
229
|
-
*
|
|
230
|
-
* // In contexts where failure is unexpected
|
|
231
|
-
* const configResult = loadConfiguration();
|
|
232
|
-
* const config = Result.unwrapThrow(configResult, err =>
|
|
233
|
-
* `Failed to load configuration: ${err}`
|
|
234
|
-
* ); // Will throw if config loading fails
|
|
235
215
|
* ```
|
|
236
216
|
*/
|
|
237
217
|
Result.unwrapThrow = (result, toStr = toStr_) => {
|
|
@@ -290,15 +270,9 @@ var Result;
|
|
|
290
270
|
* @returns The success value if `Result.Ok`, otherwise `defaultValue`.
|
|
291
271
|
* @example
|
|
292
272
|
* ```typescript
|
|
293
|
-
* // Regular usage
|
|
294
273
|
* const result = Result.ok(42);
|
|
295
274
|
* const value = Result.unwrapOkOr(result, 0);
|
|
296
275
|
* console.log(value); // 42
|
|
297
|
-
*
|
|
298
|
-
* // Curried usage for pipe composition
|
|
299
|
-
* const unwrapWithDefault = Result.unwrapOkOr(0);
|
|
300
|
-
* const value2 = pipe(Result.err("error")).map(unwrapWithDefault).value;
|
|
301
|
-
* console.log(value2); // 0
|
|
302
276
|
* ```
|
|
303
277
|
*/
|
|
304
278
|
Result.unwrapOkOr = ((...args) => {
|
|
@@ -331,34 +305,15 @@ var Result;
|
|
|
331
305
|
* @throws {Error} Error with message "Expected Err but got Ok: {value}" if the `Result` is `Result.Ok`.
|
|
332
306
|
* @example
|
|
333
307
|
* ```typescript
|
|
334
|
-
* // Basic usage - extracting error from known failure
|
|
335
308
|
* const failure = Result.err("Network timeout");
|
|
336
309
|
* console.log(Result.unwrapErrThrow(failure)); // "Network timeout"
|
|
337
310
|
*
|
|
338
|
-
* // Throws when Result is unexpectedly Ok
|
|
339
311
|
* const success = Result.ok(42);
|
|
340
312
|
* try {
|
|
341
313
|
* Result.unwrapErrThrow(success); // throws Error: "Expected Err but got Ok: 42"
|
|
342
314
|
* } catch (error) {
|
|
343
315
|
* console.log(error.message); // "Expected Err but got Ok: 42"
|
|
344
316
|
* }
|
|
345
|
-
*
|
|
346
|
-
* // Custom success value string conversion
|
|
347
|
-
* interface User { name: string; id: number; }
|
|
348
|
-
* const userResult = Result.ok<User>({ name: "John", id: 123 });
|
|
349
|
-
* try {
|
|
350
|
-
* Result.unwrapErrThrow(userResult, user => `User(${user.name}:${user.id})`);
|
|
351
|
-
* } catch (error) {
|
|
352
|
-
* console.log(error.message); // "Expected Err but got Ok: User(John:123)"
|
|
353
|
-
* }
|
|
354
|
-
*
|
|
355
|
-
* // In error handling contexts
|
|
356
|
-
* const validateAndGetError = (result: Result<any, ValidationError>) => {
|
|
357
|
-
* if (Result.isErr(result)) {
|
|
358
|
-
* return Result.unwrapErrThrow(result); // Safe to unwrap error
|
|
359
|
-
* }
|
|
360
|
-
* throw new Error("Validation unexpectedly succeeded");
|
|
361
|
-
* };
|
|
362
317
|
* ```
|
|
363
318
|
*/
|
|
364
319
|
Result.unwrapErrThrow = (result, toStr = toStr_) => {
|
|
@@ -382,39 +337,11 @@ var Result;
|
|
|
382
337
|
* @returns The error value if `Result.Err`, otherwise `undefined`.
|
|
383
338
|
* @example
|
|
384
339
|
* ```typescript
|
|
385
|
-
* // Basic error extraction
|
|
386
340
|
* const failure = Result.err("Connection failed");
|
|
387
341
|
* console.log(Result.unwrapErr(failure)); // "Connection failed"
|
|
388
342
|
*
|
|
389
343
|
* const success = Result.ok(42);
|
|
390
344
|
* console.log(Result.unwrapErr(success)); // undefined
|
|
391
|
-
*
|
|
392
|
-
* // Error handling patterns
|
|
393
|
-
* const handleApiCall = (result: Result<Data, ApiError>) => {
|
|
394
|
-
* const error = Result.unwrapErr(result);
|
|
395
|
-
* if (error !== undefined) {
|
|
396
|
-
* switch (error.type) {
|
|
397
|
-
* case "NETWORK_ERROR":
|
|
398
|
-
* return retry(result);
|
|
399
|
-
* case "AUTH_ERROR":
|
|
400
|
-
* return redirectToLogin();
|
|
401
|
-
* default:
|
|
402
|
-
* return showGenericError(error);
|
|
403
|
-
* }
|
|
404
|
-
* }
|
|
405
|
-
* // Handle success case...
|
|
406
|
-
* };
|
|
407
|
-
*
|
|
408
|
-
* // Collecting errors from multiple operations
|
|
409
|
-
* const results = await Promise.all([
|
|
410
|
-
* operation1(),
|
|
411
|
-
* operation2(),
|
|
412
|
-
* operation3()
|
|
413
|
-
* ]);
|
|
414
|
-
*
|
|
415
|
-
* const errors = results
|
|
416
|
-
* .map(Result.unwrapErr)
|
|
417
|
-
* .filter(err => err !== undefined); // Only actual errors
|
|
418
345
|
* ```
|
|
419
346
|
*/
|
|
420
347
|
Result.unwrapErr = (result) =>
|
|
@@ -429,15 +356,9 @@ var Result;
|
|
|
429
356
|
* @returns The error value if `Result.Err`, otherwise `defaultValue`.
|
|
430
357
|
* @example
|
|
431
358
|
* ```typescript
|
|
432
|
-
* // Regular usage
|
|
433
359
|
* const result = Result.err("failed");
|
|
434
360
|
* const error = Result.unwrapErrOr(result, "default");
|
|
435
361
|
* console.log(error); // "failed"
|
|
436
|
-
*
|
|
437
|
-
* // Curried usage for pipe composition
|
|
438
|
-
* const unwrapErrorWithDefault = Result.unwrapErrOr("unknown error");
|
|
439
|
-
* const error2 = pipe(Result.ok(42)).map(unwrapErrorWithDefault).value;
|
|
440
|
-
* console.log(error2); // "unknown error"
|
|
441
362
|
* ```
|
|
442
363
|
*/
|
|
443
364
|
Result.unwrapErrOr = ((...args) => {
|
|
@@ -504,15 +425,9 @@ var Result;
|
|
|
504
425
|
* @returns A new `Result<UnwrapOk<R>, E2>`.
|
|
505
426
|
* @example
|
|
506
427
|
* ```typescript
|
|
507
|
-
* // Regular usage
|
|
508
428
|
* const result = Result.err("error");
|
|
509
429
|
* const mapped = Result.mapErr(result, e => e.toUpperCase());
|
|
510
430
|
* console.log(Result.unwrapErr(mapped)); // "ERROR"
|
|
511
|
-
*
|
|
512
|
-
* // Curried usage for pipe composition
|
|
513
|
-
* const errorUppercase = Result.mapErr((e: string) => e.toUpperCase());
|
|
514
|
-
* const result2 = pipe(Result.err("error")).map(errorUppercase).value;
|
|
515
|
-
* console.log(Result.unwrapErr(result2)); // "ERROR"
|
|
516
431
|
* ```
|
|
517
432
|
*/
|
|
518
433
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
@@ -544,15 +459,9 @@ var Result;
|
|
|
544
459
|
* @returns A new `Result<S2, E2>` based on the applied function.
|
|
545
460
|
* @example
|
|
546
461
|
* ```typescript
|
|
547
|
-
* // Regular usage
|
|
548
462
|
* const result = Result.ok(42);
|
|
549
463
|
* const folded = Result.fold(result, x => x * 2, () => 0);
|
|
550
464
|
* console.log(Result.unwrapOk(folded)); // 84
|
|
551
|
-
*
|
|
552
|
-
* // Curried usage for pipe composition
|
|
553
|
-
* const folder = Result.fold((x: number) => x * 2, () => 0);
|
|
554
|
-
* const result2 = pipe(Result.ok(42)).map(folder).value;
|
|
555
|
-
* console.log(Result.unwrapOk(result2)); // 84
|
|
556
465
|
* ```
|
|
557
466
|
*/
|
|
558
467
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
@@ -584,17 +493,11 @@ var Result;
|
|
|
584
493
|
* @returns The result of applying the function, or the original `Err`.
|
|
585
494
|
* @example
|
|
586
495
|
* ```typescript
|
|
587
|
-
* // Regular usage
|
|
588
496
|
* const divide = (a: number, b: number): Result<number, string> =>
|
|
589
497
|
* b === 0 ? Result.err("Division by zero") : Result.ok(a / b);
|
|
590
498
|
*
|
|
591
499
|
* const result = Result.flatMap(Result.ok(10), x => divide(x, 2));
|
|
592
500
|
* console.log(Result.unwrapOk(result)); // 5
|
|
593
|
-
*
|
|
594
|
-
* // Curried usage for pipe composition
|
|
595
|
-
* const divideBy2 = Result.flatMap((x: number) => divide(x, 2));
|
|
596
|
-
* const result2 = pipe(Result.ok(10)).map(divideBy2).value;
|
|
597
|
-
* console.log(Result.unwrapOk(result2)); // 5
|
|
598
501
|
* ```
|
|
599
502
|
*/
|
|
600
503
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
@@ -623,15 +526,9 @@ var Result;
|
|
|
623
526
|
* @throws Error with the provided message if the `Result` is `Result.Err`.
|
|
624
527
|
* @example
|
|
625
528
|
* ```typescript
|
|
626
|
-
* // Regular usage
|
|
627
529
|
* const result = Result.ok(42);
|
|
628
530
|
* const value = Result.expectToBe(result, "Operation must succeed");
|
|
629
531
|
* console.log(value); // 42
|
|
630
|
-
*
|
|
631
|
-
* // Curried usage for pipe composition
|
|
632
|
-
* const mustBeOk = Result.expectToBe("Operation must succeed");
|
|
633
|
-
* const value2 = pipe(Result.ok(42)).map(mustBeOk).value;
|
|
634
|
-
* console.log(value2); // 42
|
|
635
532
|
* ```
|
|
636
533
|
*/
|
|
637
534
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
@@ -687,39 +584,6 @@ var Result;
|
|
|
687
584
|
* console.log(validJson.value.valid); // true
|
|
688
585
|
* }
|
|
689
586
|
*
|
|
690
|
-
* const invalidJson = parseJson('{invalid json}');
|
|
691
|
-
* if (Result.isErr(invalidJson)) {
|
|
692
|
-
* console.log(invalidJson.value.message); // SyntaxError message
|
|
693
|
-
* }
|
|
694
|
-
*
|
|
695
|
-
* // Using with custom validation
|
|
696
|
-
* const parsePositiveNumber = (str: string): Result<number, Error> =>
|
|
697
|
-
* Result.fromThrowable(() => {
|
|
698
|
-
* const num = Number(str);
|
|
699
|
-
* if (Number.isNaN(num)) throw new Error(`Not a number: ${str}`);
|
|
700
|
-
* if (num <= 0) throw new Error(`Must be positive: ${num}`);
|
|
701
|
-
* return num;
|
|
702
|
-
* });
|
|
703
|
-
*
|
|
704
|
-
* const success = parsePositiveNumber('42');
|
|
705
|
-
* console.log(Result.unwrapOkOr(success, 0)); // 42
|
|
706
|
-
*
|
|
707
|
-
* const failure = parsePositiveNumber('abc');
|
|
708
|
-
* console.log(Result.unwrapOkOr(failure, 0)); // 0
|
|
709
|
-
*
|
|
710
|
-
* // Wrapping DOM operations that might fail
|
|
711
|
-
* const getElementText = (id: string): Result<string, Error> =>
|
|
712
|
-
* Result.fromThrowable(() => {
|
|
713
|
-
* const element = document.getElementById(id);
|
|
714
|
-
* if (!element) throw new Error(`Element not found: ${id}`);
|
|
715
|
-
* return element.textContent || "";
|
|
716
|
-
* });
|
|
717
|
-
*
|
|
718
|
-
* // Wrapping file operations
|
|
719
|
-
* const readFileSync = (path: string): Result<string, Error> =>
|
|
720
|
-
* Result.fromThrowable(() =>
|
|
721
|
-
* require('fs').readFileSync(path, 'utf8')
|
|
722
|
-
* );
|
|
723
587
|
* ```
|
|
724
588
|
*/
|
|
725
589
|
Result.fromThrowable = (fn) => {
|
|
@@ -780,28 +644,6 @@ var Result;
|
|
|
780
644
|
* const none = Result.toOptional(errResult);
|
|
781
645
|
* console.log(Optional.isNone(none)); // true
|
|
782
646
|
*
|
|
783
|
-
* // Use case: when you only care about success, not error details
|
|
784
|
-
* const fetchUserName = (id: number): Result<string, ApiError> => {
|
|
785
|
-
* // ... implementation
|
|
786
|
-
* };
|
|
787
|
-
*
|
|
788
|
-
* const maybeUserName = Result.toOptional(fetchUserName(123));
|
|
789
|
-
* const displayName = Optional.unwrapOr(maybeUserName, "Unknown User");
|
|
790
|
-
*
|
|
791
|
-
* // Converting multiple Results and filtering successes
|
|
792
|
-
* const userIds = [1, 2, 3, 4];
|
|
793
|
-
* const userNames = userIds
|
|
794
|
-
* .map(fetchUserName)
|
|
795
|
-
* .map(Result.toOptional)
|
|
796
|
-
* .filter(Optional.isSome)
|
|
797
|
-
* .map(Optional.unwrap); // string[]
|
|
798
|
-
*
|
|
799
|
-
* // Chaining with Optional operations
|
|
800
|
-
* const processResult = (r: Result<string, Error>) =>
|
|
801
|
-
* pipe(Result.toOptional(r))
|
|
802
|
-
* .map(Optional.map(s => s.toUpperCase()))
|
|
803
|
-
* .map(Optional.filter(s => s.length > 0))
|
|
804
|
-
* .value;
|
|
805
647
|
* ```
|
|
806
648
|
*/
|
|
807
649
|
Result.toOptional = (result) => Result.isOk(result) ? Optional.some(Result.unwrapOk(result)) : Optional.none;
|
|
@@ -813,16 +655,10 @@ var Result;
|
|
|
813
655
|
* @returns The first `Result` if `Ok`, otherwise the alternative.
|
|
814
656
|
* @example
|
|
815
657
|
* ```typescript
|
|
816
|
-
* // Regular usage
|
|
817
658
|
* const primary = Result.err("error");
|
|
818
659
|
* const fallback = Result.ok("default");
|
|
819
660
|
* const result = Result.orElse(primary, fallback);
|
|
820
661
|
* console.log(Result.unwrapOk(result)); // "default"
|
|
821
|
-
*
|
|
822
|
-
* // Curried usage for pipe composition
|
|
823
|
-
* const fallbackTo = Result.orElse(Result.ok("fallback"));
|
|
824
|
-
* const result2 = pipe(Result.err("error")).map(fallbackTo).value;
|
|
825
|
-
* console.log(Result.unwrapOk(result2)); // "fallback"
|
|
826
662
|
* ```
|
|
827
663
|
*/
|
|
828
664
|
Result.orElse = ((...args) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"result.mjs","sources":["../../src/functional/result.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAIA;AACA,MAAM,aAAa,GAAG,0BAA0B;AAEhD;AACA,MAAM,cAAc,GAAG,2BAA2B;AAyClD;;;AAGG;AACG,IAAW;AAAjB,CAAA,UAAiB,MAAM,EAAA;AACrB;;;;AAIG;IACU,MAAA,CAAA,QAAQ,GAAG,CACtB,aAAsB,KAEtB,QAAQ,CAAC,aAAa,CAAC;AACvB,QAAA,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC;AACrC,QAAA,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC;AACrC,SAAC,aAAa,CAAC,OAAO,CAAC,KAAK,cAAc;AACxC,YAAA,aAAa,CAAC,O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