ts-data-forge 1.5.0 → 1.5.2

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.
Files changed (68) hide show
  1. package/dist/array/array-utils.d.mts +137 -358
  2. package/dist/array/array-utils.d.mts.map +1 -1
  3. package/dist/array/array-utils.mjs +191 -1966
  4. package/dist/array/array-utils.mjs.map +1 -1
  5. package/dist/array/tuple-utils.d.mts +9 -23
  6. package/dist/array/tuple-utils.d.mts.map +1 -1
  7. package/dist/array/tuple-utils.mjs +10 -56
  8. package/dist/array/tuple-utils.mjs.map +1 -1
  9. package/dist/collections/imap-mapped.mjs.map +1 -1
  10. package/dist/collections/imap.mjs.map +1 -1
  11. package/dist/collections/iset-mapped.mjs.map +1 -1
  12. package/dist/collections/iset.mjs.map +1 -1
  13. package/dist/collections/queue.mjs.map +1 -1
  14. package/dist/collections/stack.mjs.map +1 -1
  15. package/dist/functional/match.d.mts +2 -33
  16. package/dist/functional/match.d.mts.map +1 -1
  17. package/dist/functional/match.mjs +2 -119
  18. package/dist/functional/match.mjs.map +1 -1
  19. package/dist/functional/optional.d.mts +34 -197
  20. package/dist/functional/optional.d.mts.map +1 -1
  21. package/dist/functional/optional.mjs +40 -312
  22. package/dist/functional/optional.mjs.map +1 -1
  23. package/dist/functional/pipe.d.mts +2 -15
  24. package/dist/functional/pipe.d.mts.map +1 -1
  25. package/dist/functional/pipe.mjs +2 -110
  26. package/dist/functional/pipe.mjs.map +1 -1
  27. package/dist/functional/result.d.mts +18 -209
  28. package/dist/functional/result.d.mts.map +1 -1
  29. package/dist/functional/result.mjs +40 -360
  30. package/dist/functional/result.mjs.map +1 -1
  31. package/dist/guard/has-key.d.mts +1 -1
  32. package/dist/guard/has-key.mjs +1 -1
  33. package/dist/iterator/range.d.mts +2 -6
  34. package/dist/iterator/range.d.mts.map +1 -1
  35. package/dist/iterator/range.mjs +2 -93
  36. package/dist/iterator/range.mjs.map +1 -1
  37. package/dist/json/json.d.mts +14 -438
  38. package/dist/json/json.d.mts.map +1 -1
  39. package/dist/json/json.mjs +14 -438
  40. package/dist/json/json.mjs.map +1 -1
  41. package/dist/number/num.d.mts +7 -107
  42. package/dist/number/num.d.mts.map +1 -1
  43. package/dist/number/num.mjs +7 -122
  44. package/dist/number/num.mjs.map +1 -1
  45. package/dist/number/refined-number-utils.mjs.map +1 -1
  46. package/dist/object/object.d.mts +4 -10
  47. package/dist/object/object.d.mts.map +1 -1
  48. package/dist/object/object.mjs +8 -140
  49. package/dist/object/object.mjs.map +1 -1
  50. package/dist/others/map-nullable.d.mts +2 -6
  51. package/dist/others/map-nullable.d.mts.map +1 -1
  52. package/dist/others/map-nullable.mjs +2 -146
  53. package/dist/others/map-nullable.mjs.map +1 -1
  54. package/dist/others/memoize-function.mjs.map +1 -1
  55. package/dist/others/unknown-to-string.mjs.map +1 -1
  56. package/package.json +11 -11
  57. package/src/array/array-utils.mts +707 -881
  58. package/src/array/tuple-utils.mts +20 -41
  59. package/src/functional/match.mts +18 -44
  60. package/src/functional/optional.mts +93 -248
  61. package/src/functional/pipe.mts +25 -20
  62. package/src/functional/result.mts +114 -288
  63. package/src/guard/has-key.mts +1 -1
  64. package/src/iterator/range.mts +14 -17
  65. package/src/json/json.mts +14 -438
  66. package/src/number/num.mts +20 -113
  67. package/src/object/object.mts +30 -45
  68. package/src/others/map-nullable.mts +13 -15
@@ -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_) => {
@@ -242,66 +222,14 @@ var Result;
242
222
  // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
243
223
  return result.value;
244
224
  };
245
- /**
246
- * Unwraps a `Result`, returning the success value or `undefined` if it's an error.
247
- *
248
- * This function provides a safe way to extract success values from Results without
249
- * throwing exceptions. It has overloaded behavior based on the type:
250
- * - For `Result.Ok<T>`: Always returns `T` (guaranteed by type system)
251
- * - For general `Result<T, E>`: Returns `T | undefined`
252
- *
253
- * @template R The `Result.Base` type to unwrap.
254
- * @param result The `Result` to unwrap.
255
- * @returns The success value if `Result.Ok`, otherwise `undefined`.
256
- * @example
257
- * ```typescript
258
- * // With guaranteed Ok - returns the value
259
- * const success = Result.ok(42);
260
- * const value = Result.unwrapOk(success); // Type: number, Value: 42
261
- *
262
- * // With general Result - may return undefined
263
- * const maybeResult: Result<string, Error> = fetchData();
264
- * const data = Result.unwrapOk(maybeResult); // Type: string | undefined
265
- *
266
- * // Safe pattern for handling both cases
267
- * const result = Result.ok("hello");
268
- * const unwrapped = Result.unwrapOk(result);
269
- * if (unwrapped !== undefined) {
270
- * console.log(unwrapped.toUpperCase()); // "HELLO"
271
- * }
272
- *
273
- * // Useful in conditional chains
274
- * const processResult = (r: Result<number, string>) => {
275
- * const value = Result.unwrapOk(r);
276
- * return value !== undefined ? value * 2 : 0;
277
- * };
278
- * ```
279
- */
280
- Result.unwrapOk = ((result) => Result.isErr(result)
281
- ? undefined
282
- : // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
283
- result.value);
284
- /**
285
- * Unwraps a `Result`, returning the success value or a default value if it is `Result.Err`.
286
- * @template R The `Result.Base` type to unwrap.
287
- * @template D The type of the default value.
288
- * @param result The `Result` to unwrap.
289
- * @param defaultValue The value to return if `result` is `Result.Err`.
290
- * @returns The success value if `Result.Ok`, otherwise `defaultValue`.
291
- * @example
292
- * ```typescript
293
- * // Regular usage
294
- * const result = Result.ok(42);
295
- * const value = Result.unwrapOkOr(result, 0);
296
- * 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
- * ```
303
- */
304
- Result.unwrapOkOr = ((...args) => {
225
+ function unwrapOk(result) {
226
+ return Result.isErr(result)
227
+ ? undefined
228
+ : // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
229
+ result.value;
230
+ }
231
+ Result.unwrapOk = unwrapOk;
232
+ function unwrapOkOr(...args) {
305
233
  switch (args.length) {
306
234
  case 2: {
307
235
  // Direct version: first argument is result
@@ -312,10 +240,11 @@ var Result;
312
240
  case 1: {
313
241
  // Curried version: first argument is default value
314
242
  const [defaultValue] = args;
315
- return (result) => Result.unwrapOkOr(result, defaultValue);
243
+ return (result) => unwrapOkOr(result, defaultValue);
316
244
  }
317
245
  }
318
- });
246
+ }
247
+ Result.unwrapOkOr = unwrapOkOr;
319
248
  /**
320
249
  * Unwraps a `Result`, returning the error value.
321
250
  * Throws an error if the `Result` is `Result.Ok`.
@@ -331,34 +260,15 @@ var Result;
331
260
  * @throws {Error} Error with message "Expected Err but got Ok: {value}" if the `Result` is `Result.Ok`.
332
261
  * @example
333
262
  * ```typescript
334
- * // Basic usage - extracting error from known failure
335
263
  * const failure = Result.err("Network timeout");
336
264
  * console.log(Result.unwrapErrThrow(failure)); // "Network timeout"
337
265
  *
338
- * // Throws when Result is unexpectedly Ok
339
266
  * const success = Result.ok(42);
340
267
  * try {
341
268
  * Result.unwrapErrThrow(success); // throws Error: "Expected Err but got Ok: 42"
342
269
  * } catch (error) {
343
270
  * console.log(error.message); // "Expected Err but got Ok: 42"
344
271
  * }
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
272
  * ```
363
273
  */
364
274
  Result.unwrapErrThrow = (result, toStr = toStr_) => {
@@ -382,65 +292,17 @@ var Result;
382
292
  * @returns The error value if `Result.Err`, otherwise `undefined`.
383
293
  * @example
384
294
  * ```typescript
385
- * // Basic error extraction
386
295
  * const failure = Result.err("Connection failed");
387
296
  * console.log(Result.unwrapErr(failure)); // "Connection failed"
388
297
  *
389
298
  * const success = Result.ok(42);
390
299
  * 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
300
  * ```
419
301
  */
420
302
  Result.unwrapErr = (result) =>
421
303
  // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
422
304
  Result.isErr(result) ? result.value : undefined;
423
- /**
424
- * Unwraps a `Result`, returning the error value or a default value if it is `Result.Ok`.
425
- * @template R The `Result.Base` type to unwrap.
426
- * @template D The type of the default value.
427
- * @param result The `Result` to unwrap.
428
- * @param defaultValue The value to return if `result` is `Result.Ok`.
429
- * @returns The error value if `Result.Err`, otherwise `defaultValue`.
430
- * @example
431
- * ```typescript
432
- * // Regular usage
433
- * const result = Result.err("failed");
434
- * const error = Result.unwrapErrOr(result, "default");
435
- * 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
- * ```
442
- */
443
- Result.unwrapErrOr = ((...args) => {
305
+ function unwrapErrOr(...args) {
444
306
  switch (args.length) {
445
307
  case 2: {
446
308
  // Direct version: first argument is result
@@ -451,33 +313,12 @@ var Result;
451
313
  case 1: {
452
314
  // Curried version: first argument is default value
453
315
  const [defaultValue] = args;
454
- return (result) => Result.unwrapErrOr(result, defaultValue);
316
+ return (result) => unwrapErrOr(result, defaultValue);
455
317
  }
456
318
  }
457
- });
458
- /**
459
- * Maps a `Result<S, E>` to `Result<S2, E>` by applying a function to the success value.
460
- * If the `Result` is `Result.Err`, returns the original `Err`.
461
- * @template R The input `Result.Base` type.
462
- * @template S2 The type of the success value returned by the mapping function.
463
- * @param result The `Result` to map.
464
- * @param mapFn The function to apply to the success value if present.
465
- * @returns A new `Result<S2, UnwrapErr<R>>`.
466
- * @example
467
- * ```typescript
468
- * // Regular usage
469
- * const result = Result.ok(5);
470
- * const mapped = Result.map(result, x => x * 2);
471
- * console.log(Result.unwrap(mapped)); // 10
472
- *
473
- * // Curried version for use with pipe
474
- * const doubler = Result.map((x: number) => x * 2);
475
- * const result2 = pipe(Result.ok(5)).map(doubler).value;
476
- * console.log(Result.unwrap(result2)); // 10
477
- * ```
478
- */
479
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
480
- Result.map = ((...args) => {
319
+ }
320
+ Result.unwrapErrOr = unwrapErrOr;
321
+ function map(...args) {
481
322
  switch (args.length) {
482
323
  case 2: {
483
324
  const [result, mapFn] = args;
@@ -490,33 +331,12 @@ var Result;
490
331
  case 1: {
491
332
  // Curried version: first argument is mapping function
492
333
  const [mapFn] = args;
493
- return (result) => Result.map(result, mapFn);
334
+ return (result) => map(result, mapFn);
494
335
  }
495
336
  }
496
- });
497
- /**
498
- * Maps a `Result<S, E>` to `Result<S, E2>` by applying a function to the error value.
499
- * If the `Result` is `Result.Ok`, returns the original `Ok`.
500
- * @template R The input `Result.Base` type.
501
- * @template E2 The type of the error value returned by the mapping function.
502
- * @param result The `Result` to map.
503
- * @param mapFn The function to apply to the error value if present.
504
- * @returns A new `Result<UnwrapOk<R>, E2>`.
505
- * @example
506
- * ```typescript
507
- * // Regular usage
508
- * const result = Result.err("error");
509
- * const mapped = Result.mapErr(result, e => e.toUpperCase());
510
- * 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
- * ```
517
- */
518
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
519
- Result.mapErr = ((...args) => {
337
+ }
338
+ Result.map = map;
339
+ function mapErr(...args) {
520
340
  switch (args.length) {
521
341
  case 2: {
522
342
  const [result, mapFn] = args;
@@ -529,34 +349,12 @@ var Result;
529
349
  case 1: {
530
350
  // Curried version: first argument is mapping function
531
351
  const [mapFn] = args;
532
- return (result) => Result.mapErr(result, mapFn);
352
+ return (result) => mapErr(result, mapFn);
533
353
  }
534
354
  }
535
- });
536
- /**
537
- * Applies one of two functions depending on whether the `Result` is `Ok` or `Err`.
538
- * @template R The input `Result.Base` type.
539
- * @template S2 The type of the success value returned by `mapFn`.
540
- * @template E2 The type of the error value returned by `mapErrFn`.
541
- * @param result The `Result` to fold.
542
- * @param mapFn The function to apply if `result` is `Ok`.
543
- * @param mapErrFn The function to apply if `result` is `Err`.
544
- * @returns A new `Result<S2, E2>` based on the applied function.
545
- * @example
546
- * ```typescript
547
- * // Regular usage
548
- * const result = Result.ok(42);
549
- * const folded = Result.fold(result, x => x * 2, () => 0);
550
- * 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
- * ```
557
- */
558
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
559
- Result.fold = ((...args) => {
355
+ }
356
+ Result.mapErr = mapErr;
357
+ function fold(...args) {
560
358
  switch (args.length) {
561
359
  case 3: {
562
360
  const [result, mapFn, mapErrFn] = args;
@@ -571,34 +369,9 @@ var Result;
571
369
  return (result) => Result.isOk(result) ? Result.ok(mapFn(result.value)) : Result.err(mapErrFn(result.value));
572
370
  }
573
371
  }
574
- });
575
- /**
576
- * Applies a function that returns a `Result` to the success value of a `Result`.
577
- * If the input is `Err`, returns the original `Err`.
578
- * This is the monadic bind operation for `Result`.
579
- * @template R The input `Result.Base` type.
580
- * @template S2 The success type of the `Result` returned by the function.
581
- * @template E2 The error type of the `Result` returned by the function.
582
- * @param result The `Result` to flat map.
583
- * @param flatMapFn The function to apply that returns a `Result`.
584
- * @returns The result of applying the function, or the original `Err`.
585
- * @example
586
- * ```typescript
587
- * // Regular usage
588
- * const divide = (a: number, b: number): Result<number, string> =>
589
- * b === 0 ? Result.err("Division by zero") : Result.ok(a / b);
590
- *
591
- * const result = Result.flatMap(Result.ok(10), x => divide(x, 2));
592
- * 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
- * ```
599
- */
600
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
601
- Result.flatMap = ((...args) => {
372
+ }
373
+ Result.fold = fold;
374
+ function flatMap(...args) {
602
375
  switch (args.length) {
603
376
  case 2: {
604
377
  const [result, flatMapFn] = args;
@@ -613,45 +386,26 @@ var Result;
613
386
  return (result) => Result.isErr(result) ? result : flatMapFn(result.value);
614
387
  }
615
388
  }
616
- });
617
- /**
618
- * Unwraps a `Result`, returning the success value or throwing an error with the provided message.
619
- * @template R The `Result.Base` type to unwrap.
620
- * @param result The `Result` to unwrap.
621
- * @param message The error message to throw if the `Result` is `Result.Err`.
622
- * @returns The success value if `Result.Ok`.
623
- * @throws Error with the provided message if the `Result` is `Result.Err`.
624
- * @example
625
- * ```typescript
626
- * // Regular usage
627
- * const result = Result.ok(42);
628
- * const value = Result.expectToBe(result, "Operation must succeed");
629
- * 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
- * ```
636
- */
637
- // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
638
- Result.expectToBe = ((...args) => {
389
+ }
390
+ Result.flatMap = flatMap;
391
+ function expectToBe(...args) {
639
392
  switch (args.length) {
640
393
  case 2: {
641
394
  // Direct version: first argument is result
642
395
  const [result, message] = args;
643
396
  if (Result.isOk(result)) {
644
- return Result.unwrapOk(result);
397
+ return unwrapOk(result);
645
398
  }
646
399
  throw new Error(message);
647
400
  }
648
401
  case 1: {
649
402
  // Curried version: first argument is message
650
403
  const [message] = args;
651
- return (result) => Result.expectToBe(result, message);
404
+ return (result) => expectToBe(result, message);
652
405
  }
653
406
  }
654
- });
407
+ }
408
+ Result.expectToBe = expectToBe;
655
409
  /**
656
410
  * Converts a Promise into a Promise that resolves to a `Result`.
657
411
  * If the input Promise resolves, the `Result` will be `Ok` with the resolved value.
@@ -687,39 +441,6 @@ var Result;
687
441
  * console.log(validJson.value.valid); // true
688
442
  * }
689
443
  *
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
444
  * ```
724
445
  */
725
446
  Result.fromThrowable = (fn) => {
@@ -754,7 +475,7 @@ var Result;
754
475
  */
755
476
  Result.swap = (result) =>
756
477
  // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
757
- Result.isOk(result) ? Result.err(Result.unwrapOk(result)) : Result.ok(result.value);
478
+ Result.isOk(result) ? Result.err(unwrapOk(result)) : Result.ok(result.value);
758
479
  /**
759
480
  * Converts a `Result` to an `Optional`.
760
481
  *
@@ -780,52 +501,10 @@ var Result;
780
501
  * const none = Result.toOptional(errResult);
781
502
  * console.log(Optional.isNone(none)); // true
782
503
  *
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
504
  * ```
806
505
  */
807
- Result.toOptional = (result) => Result.isOk(result) ? Optional.some(Result.unwrapOk(result)) : Optional.none;
808
- /**
809
- * Returns the `Result` if it is `Ok`, otherwise returns the alternative.
810
- * @template R The input `Result.Base` type.
811
- * @param result The `Result` to check.
812
- * @param alternative The alternative `Result` to return if the first is `Err`.
813
- * @returns The first `Result` if `Ok`, otherwise the alternative.
814
- * @example
815
- * ```typescript
816
- * // Regular usage
817
- * const primary = Result.err("error");
818
- * const fallback = Result.ok("default");
819
- * const result = Result.orElse(primary, fallback);
820
- * 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
- * ```
827
- */
828
- Result.orElse = ((...args) => {
506
+ Result.toOptional = (result) => Result.isOk(result) ? Optional.some(unwrapOk(result)) : Optional.none;
507
+ function orElse(...args) {
829
508
  switch (args.length) {
830
509
  case 2: {
831
510
  const [result, alternative] = args;
@@ -834,10 +513,11 @@ var Result;
834
513
  case 1: {
835
514
  // Curried version: one argument (alternative) provided
836
515
  const [alternative] = args;
837
- return (result) => Result.orElse(result, alternative);
516
+ return (result) => orElse(result, alternative);
838
517
  }
839
518
  }
840
- });
519
+ }
520
+ Result.orElse = orElse;
841
521
  /**
842
522
  * Combines two `Result` values into a single `Result` containing a tuple.
843
523
  * If either `Result` is `Err`, returns the first `Err` encountered.
@@ -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,OAAO,CAAC,KAAK,aAAa,CAAC;AAgD7C;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BG;AACU,IAAA,MAAA,CAAA,EAAE,GAAG,CAAK,KAAQ,MAAa;AAC1C,QAAA,KAAK,EAAE,aAAa;QACpB,KAAK;AACN,KAAA,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCG;AACU,IAAA,MAAA,CAAA,GAAG,GAAG,CAAK,KAAQ,MAAc;AAC5C,QAAA,KAAK,EAAE,cAAc;QACrB,KAAK;AACN,KAAA,CAAC;AAEF;;;AAGG;IACH,MAAM,MAAM,GAAG,MAAM;AAErB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCG;IACU,MAAA,CAAA,IAAI,GAAG,CAAiB,MAAS,KAC5C,MAAM,CAAC,KAA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CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,IAAI;AAClC,gBAAA,OAAO,MAAA,CAAA,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG,WAAW;YAC5C;YAEA,KAAK,CAAC,EAAE;;AAEN,gBAAA,MAAM,CAAC,WAAW,CAAC,GAAG,IAAI;gBAC1B,OAAO,CAAC,MAAyC,KAC/C,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC;YAC/B;;IAEJ;AApBgB,IAAA,MAAA,CAAA,MAAM,SAoBrB;AAED;;;;;;;;;;;;;;;;;;;;AAoBG;AACU,IAAA,MAAA,CAAA,GAAG,GAAG,CACjB,OAAuB,EACvB,OAAuB,KAEvB,MAAA,CAAA,IAAI,CAAC,OAAO;AACV,UAAE,MAAA,CAAA,IAAI,CAAC,OAAO;AACZ,cAAE,MAAA,CAAA,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAU;AAC5C,cAAE;UACF,OAAO;AACf,CAAC,EAx6BgB,MAAM,KAAN,MAAM,GAAA,EAAA,CAAA,CAAA;;;;"}
@@ -71,7 +71,7 @@
71
71
  * ```
72
72
  *
73
73
  * @example
74
- * Combining with other type guards for progressive narrowing:
74
+ * Basic usage with isRecord for progressive narrowing:
75
75
  * ```typescript
76
76
  * const data: unknown = parseApiResponse();
77
77
  *
@@ -71,7 +71,7 @@
71
71
  * ```
72
72
  *
73
73
  * @example
74
- * Combining with other type guards for progressive narrowing:
74
+ * Basic usage with isRecord for progressive narrowing:
75
75
  * ```typescript
76
76
  * const data: unknown = parseApiResponse();
77
77
  *
@@ -88,10 +88,6 @@
88
88
  * }
89
89
  * ```
90
90
  */
91
- export declare const range: RangeFnOverload;
92
- type RangeFnOverload = {
93
- (start: SafeUintWithSmallInt, end: SafeUintWithSmallInt, step?: PositiveSafeIntWithSmallInt): Generator<SafeUint, void, unknown>;
94
- (start: SafeIntWithSmallInt, end: SafeIntWithSmallInt, step?: NonZeroSafeIntWithSmallInt): Generator<SafeInt, void, unknown>;
95
- };
96
- export {};
91
+ export declare function range(start: SafeUintWithSmallInt, end: SafeUintWithSmallInt, step?: PositiveSafeIntWithSmallInt): Generator<SafeUint, void, unknown>;
92
+ export declare function range(start: SafeIntWithSmallInt, end: SafeIntWithSmallInt, step?: NonZeroSafeIntWithSmallInt): Generator<SafeInt, void, unknown>;
97
93
  //# sourceMappingURL=range.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"range.d.mts","sourceRoot":"","sources":["../../src/iterator/range.mts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyFG;AAEH,eAAO,MAAM,KAAK,EAAE,eAYA,CAAC;AAErB,KAAK,eAAe,GAAG;IACrB,CACE,KAAK,EAAE,oBAAoB,EAC3B,GAAG,EAAE,oBAAoB,EACzB,IAAI,CAAC,EAAE,2BAA2B,GACjC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAEtC,CACE,KAAK,EAAE,mBAAmB,EAC1B,GAAG,EAAE,mBAAmB,EACxB,IAAI,CAAC,EAAE,0BAA0B,GAChC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;CACtC,CAAC"}
1
+ {"version":3,"file":"range.d.mts","sourceRoot":"","sources":["../../src/iterator/range.mts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyFG;AACH,wBAAgB,KAAK,CACnB,KAAK,EAAE,oBAAoB,EAC3B,GAAG,EAAE,oBAAoB,EACzB,IAAI,CAAC,EAAE,2BAA2B,GACjC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;AAEtC,wBAAgB,KAAK,CACnB,KAAK,EAAE,mBAAmB,EAC1B,GAAG,EAAE,mBAAmB,EACxB,IAAI,CAAC,EAAE,0BAA0B,GAChC,SAAS,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC"}