ts-data-forge 14.6.3 → 14.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -1
- package/dist/array/impl/array-utils-modification.mjs +1 -1
- package/dist/array/impl/array-utils-transformation.mjs +2 -2
- package/dist/expect-type.d.mts +2 -70
- package/dist/expect-type.d.mts.map +1 -1
- package/dist/expect-type.mjs +1 -68
- package/dist/expect-type.mjs.map +1 -1
- package/dist/functional/index.d.mts +11 -6
- package/dist/functional/index.d.mts.map +1 -1
- package/dist/functional/index.mjs +10 -6
- package/dist/functional/index.mjs.map +1 -1
- package/dist/guard/has-key.d.mts +2 -51
- package/dist/guard/has-key.d.mts.map +1 -1
- package/dist/guard/has-key.mjs +1 -41
- package/dist/guard/has-key.mjs.map +1 -1
- package/dist/guard/is-non-null-object.d.mts +2 -34
- package/dist/guard/is-non-null-object.d.mts.map +1 -1
- package/dist/guard/is-non-null-object.mjs +1 -34
- package/dist/guard/is-non-null-object.mjs.map +1 -1
- package/dist/guard/is-record.d.mts +2 -89
- package/dist/guard/is-record.d.mts.map +1 -1
- package/dist/guard/is-record.mjs +1 -88
- package/dist/guard/is-record.mjs.map +1 -1
- package/dist/guard/key-is-in.d.mts +2 -42
- package/dist/guard/key-is-in.d.mts.map +1 -1
- package/dist/guard/key-is-in.mjs +1 -40
- package/dist/guard/key-is-in.mjs.map +1 -1
- package/dist/number/num.d.mts +9 -1
- package/dist/number/num.d.mts.map +1 -1
- package/dist/number/num.mjs +24 -16
- package/dist/number/num.mjs.map +1 -1
- package/dist/others/index.d.mts +1 -0
- package/dist/others/index.d.mts.map +1 -1
- package/dist/others/index.mjs +1 -0
- package/dist/others/index.mjs.map +1 -1
- package/dist/others/panic-error.d.mts +9 -0
- package/dist/others/panic-error.d.mts.map +1 -0
- package/dist/others/panic-error.mjs +9 -0
- package/dist/others/panic-error.mjs.map +1 -0
- package/dist/others/unknown-to-string.d.mts +2 -37
- package/dist/others/unknown-to-string.d.mts.map +1 -1
- package/dist/others/unknown-to-string.mjs +1 -92
- package/dist/others/unknown-to-string.mjs.map +1 -1
- package/dist/types.d.mts +1 -41
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +0 -1
- package/dist/types.mjs.map +1 -1
- package/package.json +6 -6
- package/src/expect-type.mts +2 -78
- package/src/functional/index.mts +31 -6
- package/src/guard/has-key.mts +2 -72
- package/src/guard/is-non-null-object.mts +2 -36
- package/src/guard/is-record.mts +2 -95
- package/src/guard/key-is-in.mts +2 -49
- package/src/number/num.mts +36 -28
- package/src/others/index.mts +1 -0
- package/src/others/panic-error.mts +8 -0
- package/src/others/unknown-to-string.mts +2 -111
- package/src/types.mts +4 -54
- package/dist/functional/async-result/async-result.d.mts +0 -16
- package/dist/functional/async-result/async-result.d.mts.map +0 -1
- package/dist/functional/async-result/async-result.mjs +0 -2
- package/dist/functional/async-result/async-result.mjs.map +0 -1
- package/dist/functional/async-result/impl/async-result-flat-map.d.mts +0 -39
- package/dist/functional/async-result/impl/async-result-flat-map.d.mts.map +0 -1
- package/dist/functional/async-result/impl/async-result-flat-map.mjs +0 -23
- package/dist/functional/async-result/impl/async-result-flat-map.mjs.map +0 -1
- package/dist/functional/async-result/impl/async-result-from-promise.d.mts +0 -47
- package/dist/functional/async-result/impl/async-result-from-promise.d.mts.map +0 -1
- package/dist/functional/async-result/impl/async-result-from-promise.mjs +0 -10
- package/dist/functional/async-result/impl/async-result-from-promise.mjs.map +0 -1
- package/dist/functional/async-result/impl/async-result-from-throwable.d.mts +0 -53
- package/dist/functional/async-result/impl/async-result-from-throwable.d.mts.map +0 -1
- package/dist/functional/async-result/impl/async-result-from-throwable.mjs +0 -15
- package/dist/functional/async-result/impl/async-result-from-throwable.mjs.map +0 -1
- package/dist/functional/async-result/impl/async-result-map-err.d.mts +0 -35
- package/dist/functional/async-result/impl/async-result-map-err.d.mts.map +0 -1
- package/dist/functional/async-result/impl/async-result-map-err.mjs +0 -20
- package/dist/functional/async-result/impl/async-result-map-err.mjs.map +0 -1
- package/dist/functional/async-result/impl/async-result-map.d.mts +0 -45
- package/dist/functional/async-result/impl/async-result-map.d.mts.map +0 -1
- package/dist/functional/async-result/impl/async-result-map.mjs +0 -20
- package/dist/functional/async-result/impl/async-result-map.mjs.map +0 -1
- package/dist/functional/async-result/impl/async-result-unwrap-or.d.mts +0 -34
- package/dist/functional/async-result/impl/async-result-unwrap-or.d.mts.map +0 -1
- package/dist/functional/async-result/impl/async-result-unwrap-or.mjs +0 -37
- package/dist/functional/async-result/impl/async-result-unwrap-or.mjs.map +0 -1
- package/dist/functional/async-result/impl/index.d.mts +0 -8
- package/dist/functional/async-result/impl/index.d.mts.map +0 -1
- package/dist/functional/async-result/impl/index.mjs +0 -8
- package/dist/functional/async-result/impl/index.mjs.map +0 -1
- package/dist/functional/async-result/impl/types.d.mts +0 -45
- package/dist/functional/async-result/impl/types.d.mts.map +0 -1
- package/dist/functional/async-result/impl/types.mjs +0 -2
- package/dist/functional/async-result/impl/types.mjs.map +0 -1
- package/dist/functional/async-result/index.d.mts +0 -2
- package/dist/functional/async-result/index.d.mts.map +0 -1
- package/dist/functional/async-result/index.mjs +0 -2
- package/dist/functional/async-result/index.mjs.map +0 -1
- package/dist/functional/match.d.mts +0 -80
- package/dist/functional/match.d.mts.map +0 -1
- package/dist/functional/match.mjs +0 -31
- package/dist/functional/match.mjs.map +0 -1
- package/dist/functional/optional/impl/index.d.mts +0 -19
- package/dist/functional/optional/impl/index.d.mts.map +0 -1
- package/dist/functional/optional/impl/index.mjs +0 -19
- package/dist/functional/optional/impl/index.mjs.map +0 -1
- package/dist/functional/optional/impl/optional-expect-to-be.d.mts +0 -37
- package/dist/functional/optional/impl/optional-expect-to-be.d.mts.map +0 -1
- package/dist/functional/optional/impl/optional-expect-to-be.mjs +0 -22
- package/dist/functional/optional/impl/optional-expect-to-be.mjs.map +0 -1
- package/dist/functional/optional/impl/optional-filter.d.mts +0 -33
- package/dist/functional/optional/impl/optional-filter.d.mts.map +0 -1
- package/dist/functional/optional/impl/optional-filter.mjs +0 -25
- package/dist/functional/optional/impl/optional-filter.mjs.map +0 -1
- package/dist/functional/optional/impl/optional-flat-map.d.mts +0 -39
- package/dist/functional/optional/impl/optional-flat-map.d.mts.map +0 -1
- package/dist/functional/optional/impl/optional-flat-map.mjs +0 -18
- package/dist/functional/optional/impl/optional-flat-map.mjs.map +0 -1
- package/dist/functional/optional/impl/optional-from-nullable.d.mts +0 -27
- package/dist/functional/optional/impl/optional-from-nullable.d.mts.map +0 -1
- package/dist/functional/optional/impl/optional-from-nullable.mjs +0 -28
- package/dist/functional/optional/impl/optional-from-nullable.mjs.map +0 -1
- package/dist/functional/optional/impl/optional-is-none.d.mts +0 -23
- package/dist/functional/optional/impl/optional-is-none.d.mts.map +0 -1
- package/dist/functional/optional/impl/optional-is-none.mjs +0 -22
- package/dist/functional/optional/impl/optional-is-none.mjs.map +0 -1
- package/dist/functional/optional/impl/optional-is-optional.d.mts +0 -21
- package/dist/functional/optional/impl/optional-is-optional.d.mts.map +0 -1
- package/dist/functional/optional/impl/optional-is-optional.mjs +0 -26
- package/dist/functional/optional/impl/optional-is-optional.mjs.map +0 -1
- package/dist/functional/optional/impl/optional-is-some.d.mts +0 -24
- package/dist/functional/optional/impl/optional-is-some.d.mts.map +0 -1
- package/dist/functional/optional/impl/optional-is-some.mjs +0 -23
- package/dist/functional/optional/impl/optional-is-some.mjs.map +0 -1
- package/dist/functional/optional/impl/optional-map.d.mts +0 -34
- package/dist/functional/optional/impl/optional-map.d.mts.map +0 -1
- package/dist/functional/optional/impl/optional-map.mjs +0 -22
- package/dist/functional/optional/impl/optional-map.mjs.map +0 -1
- package/dist/functional/optional/impl/optional-match.d.mts +0 -48
- package/dist/functional/optional/impl/optional-match.d.mts.map +0 -1
- package/dist/functional/optional/impl/optional-match.mjs +0 -20
- package/dist/functional/optional/impl/optional-match.mjs.map +0 -1
- package/dist/functional/optional/impl/optional-none.d.mts +0 -19
- package/dist/functional/optional/impl/optional-none.d.mts.map +0 -1
- package/dist/functional/optional/impl/optional-none.mjs +0 -19
- package/dist/functional/optional/impl/optional-none.mjs.map +0 -1
- package/dist/functional/optional/impl/optional-or-else.d.mts +0 -43
- package/dist/functional/optional/impl/optional-or-else.d.mts.map +0 -1
- package/dist/functional/optional/impl/optional-or-else.mjs +0 -16
- package/dist/functional/optional/impl/optional-or-else.mjs.map +0 -1
- package/dist/functional/optional/impl/optional-some.d.mts +0 -22
- package/dist/functional/optional/impl/optional-some.d.mts.map +0 -1
- package/dist/functional/optional/impl/optional-some.mjs +0 -25
- package/dist/functional/optional/impl/optional-some.mjs.map +0 -1
- package/dist/functional/optional/impl/optional-to-nullable.d.mts +0 -30
- package/dist/functional/optional/impl/optional-to-nullable.d.mts.map +0 -1
- package/dist/functional/optional/impl/optional-to-nullable.mjs +0 -30
- package/dist/functional/optional/impl/optional-to-nullable.mjs.map +0 -1
- package/dist/functional/optional/impl/optional-unwrap-or.d.mts +0 -37
- package/dist/functional/optional/impl/optional-unwrap-or.d.mts.map +0 -1
- package/dist/functional/optional/impl/optional-unwrap-or.mjs +0 -16
- package/dist/functional/optional/impl/optional-unwrap-or.mjs.map +0 -1
- package/dist/functional/optional/impl/optional-unwrap-throw.d.mts +0 -31
- package/dist/functional/optional/impl/optional-unwrap-throw.d.mts.map +0 -1
- package/dist/functional/optional/impl/optional-unwrap-throw.mjs +0 -36
- package/dist/functional/optional/impl/optional-unwrap-throw.mjs.map +0 -1
- package/dist/functional/optional/impl/optional-unwrap.d.mts +0 -32
- package/dist/functional/optional/impl/optional-unwrap.d.mts.map +0 -1
- package/dist/functional/optional/impl/optional-unwrap.mjs +0 -8
- package/dist/functional/optional/impl/optional-unwrap.mjs.map +0 -1
- package/dist/functional/optional/impl/optional-zip.d.mts +0 -35
- package/dist/functional/optional/impl/optional-zip.d.mts.map +0 -1
- package/dist/functional/optional/impl/optional-zip.mjs +0 -39
- package/dist/functional/optional/impl/optional-zip.mjs.map +0 -1
- package/dist/functional/optional/impl/tag.d.mts +0 -6
- package/dist/functional/optional/impl/tag.d.mts.map +0 -1
- package/dist/functional/optional/impl/tag.mjs +0 -4
- package/dist/functional/optional/impl/tag.mjs.map +0 -1
- package/dist/functional/optional/impl/types.d.mts +0 -24
- package/dist/functional/optional/impl/types.d.mts.map +0 -1
- package/dist/functional/optional/impl/types.mjs +0 -2
- package/dist/functional/optional/impl/types.mjs.map +0 -1
- package/dist/functional/optional/index.d.mts +0 -2
- package/dist/functional/optional/index.d.mts.map +0 -1
- package/dist/functional/optional/index.mjs +0 -2
- package/dist/functional/optional/index.mjs.map +0 -1
- package/dist/functional/optional/optional.d.mts +0 -16
- package/dist/functional/optional/optional.d.mts.map +0 -1
- package/dist/functional/optional/optional.mjs +0 -2
- package/dist/functional/optional/optional.mjs.map +0 -1
- package/dist/functional/pipe.d.mts +0 -102
- package/dist/functional/pipe.d.mts.map +0 -1
- package/dist/functional/pipe.mjs +0 -45
- package/dist/functional/pipe.mjs.map +0 -1
- package/dist/functional/result/impl/index.d.mts +0 -28
- package/dist/functional/result/impl/index.d.mts.map +0 -1
- package/dist/functional/result/impl/index.mjs +0 -28
- package/dist/functional/result/impl/index.mjs.map +0 -1
- package/dist/functional/result/impl/result-err.d.mts +0 -28
- package/dist/functional/result/impl/result-err.d.mts.map +0 -1
- package/dist/functional/result/impl/result-err.mjs +0 -31
- package/dist/functional/result/impl/result-err.mjs.map +0 -1
- package/dist/functional/result/impl/result-expect-to-be.d.mts +0 -33
- package/dist/functional/result/impl/result-expect-to-be.d.mts.map +0 -1
- package/dist/functional/result/impl/result-expect-to-be.mjs +0 -23
- package/dist/functional/result/impl/result-expect-to-be.mjs.map +0 -1
- package/dist/functional/result/impl/result-flat-map.d.mts +0 -45
- package/dist/functional/result/impl/result-flat-map.d.mts.map +0 -1
- package/dist/functional/result/impl/result-flat-map.mjs +0 -21
- package/dist/functional/result/impl/result-flat-map.mjs.map +0 -1
- package/dist/functional/result/impl/result-fold.d.mts +0 -50
- package/dist/functional/result/impl/result-fold.d.mts.map +0 -1
- package/dist/functional/result/impl/result-fold.mjs +0 -23
- package/dist/functional/result/impl/result-fold.mjs.map +0 -1
- package/dist/functional/result/impl/result-from-optional.d.mts +0 -41
- package/dist/functional/result/impl/result-from-optional.d.mts.map +0 -1
- package/dist/functional/result/impl/result-from-optional.mjs +0 -21
- package/dist/functional/result/impl/result-from-optional.mjs.map +0 -1
- package/dist/functional/result/impl/result-from-promise.d.mts +0 -43
- package/dist/functional/result/impl/result-from-promise.d.mts.map +0 -1
- package/dist/functional/result/impl/result-from-promise.mjs +0 -39
- package/dist/functional/result/impl/result-from-promise.mjs.map +0 -1
- package/dist/functional/result/impl/result-from-throwable.d.mts +0 -32
- package/dist/functional/result/impl/result-from-throwable.d.mts.map +0 -1
- package/dist/functional/result/impl/result-from-throwable.mjs +0 -46
- package/dist/functional/result/impl/result-from-throwable.mjs.map +0 -1
- package/dist/functional/result/impl/result-is-err.d.mts +0 -23
- package/dist/functional/result/impl/result-is-err.d.mts.map +0 -1
- package/dist/functional/result/impl/result-is-err.mjs +0 -22
- package/dist/functional/result/impl/result-is-err.mjs.map +0 -1
- package/dist/functional/result/impl/result-is-ok.d.mts +0 -23
- package/dist/functional/result/impl/result-is-ok.d.mts.map +0 -1
- package/dist/functional/result/impl/result-is-ok.mjs +0 -22
- package/dist/functional/result/impl/result-is-ok.mjs.map +0 -1
- package/dist/functional/result/impl/result-is-result.d.mts +0 -22
- package/dist/functional/result/impl/result-is-result.d.mts.map +0 -1
- package/dist/functional/result/impl/result-is-result.mjs +0 -26
- package/dist/functional/result/impl/result-is-result.mjs.map +0 -1
- package/dist/functional/result/impl/result-map-err.d.mts +0 -39
- package/dist/functional/result/impl/result-map-err.d.mts.map +0 -1
- package/dist/functional/result/impl/result-map-err.mjs +0 -22
- package/dist/functional/result/impl/result-map-err.mjs.map +0 -1
- package/dist/functional/result/impl/result-map.d.mts +0 -39
- package/dist/functional/result/impl/result-map.d.mts.map +0 -1
- package/dist/functional/result/impl/result-map.mjs +0 -22
- package/dist/functional/result/impl/result-map.mjs.map +0 -1
- package/dist/functional/result/impl/result-match.d.mts +0 -47
- package/dist/functional/result/impl/result-match.d.mts.map +0 -1
- package/dist/functional/result/impl/result-match.mjs +0 -20
- package/dist/functional/result/impl/result-match.mjs.map +0 -1
- package/dist/functional/result/impl/result-ok.d.mts +0 -28
- package/dist/functional/result/impl/result-ok.d.mts.map +0 -1
- package/dist/functional/result/impl/result-ok.mjs +0 -31
- package/dist/functional/result/impl/result-ok.mjs.map +0 -1
- package/dist/functional/result/impl/result-or-else.d.mts +0 -40
- package/dist/functional/result/impl/result-or-else.d.mts.map +0 -1
- package/dist/functional/result/impl/result-or-else.mjs +0 -17
- package/dist/functional/result/impl/result-or-else.mjs.map +0 -1
- package/dist/functional/result/impl/result-safe-try.d.mts +0 -51
- package/dist/functional/result/impl/result-safe-try.d.mts.map +0 -1
- package/dist/functional/result/impl/result-safe-try.mjs +0 -35
- package/dist/functional/result/impl/result-safe-try.mjs.map +0 -1
- package/dist/functional/result/impl/result-safe-unwrap.d.mts +0 -36
- package/dist/functional/result/impl/result-safe-unwrap.d.mts.map +0 -1
- package/dist/functional/result/impl/result-safe-unwrap.mjs +0 -42
- package/dist/functional/result/impl/result-safe-unwrap.mjs.map +0 -1
- package/dist/functional/result/impl/result-swap.d.mts +0 -23
- package/dist/functional/result/impl/result-swap.d.mts.map +0 -1
- package/dist/functional/result/impl/result-swap.mjs +0 -27
- package/dist/functional/result/impl/result-swap.mjs.map +0 -1
- package/dist/functional/result/impl/result-to-optional.d.mts +0 -32
- package/dist/functional/result/impl/result-to-optional.d.mts.map +0 -1
- package/dist/functional/result/impl/result-to-optional.mjs +0 -32
- package/dist/functional/result/impl/result-to-optional.mjs.map +0 -1
- package/dist/functional/result/impl/result-unwrap-err-or.d.mts +0 -33
- package/dist/functional/result/impl/result-unwrap-err-or.d.mts.map +0 -1
- package/dist/functional/result/impl/result-unwrap-err-or.mjs +0 -17
- package/dist/functional/result/impl/result-unwrap-err-or.mjs.map +0 -1
- package/dist/functional/result/impl/result-unwrap-err-throw.d.mts +0 -33
- package/dist/functional/result/impl/result-unwrap-err-throw.d.mts.map +0 -1
- package/dist/functional/result/impl/result-unwrap-err-throw.mjs +0 -46
- package/dist/functional/result/impl/result-unwrap-err-throw.mjs.map +0 -1
- package/dist/functional/result/impl/result-unwrap-err.d.mts +0 -33
- package/dist/functional/result/impl/result-unwrap-err.d.mts.map +0 -1
- package/dist/functional/result/impl/result-unwrap-err.mjs +0 -34
- package/dist/functional/result/impl/result-unwrap-err.mjs.map +0 -1
- package/dist/functional/result/impl/result-unwrap-ok-or.d.mts +0 -33
- package/dist/functional/result/impl/result-unwrap-ok-or.d.mts.map +0 -1
- package/dist/functional/result/impl/result-unwrap-ok-or.mjs +0 -17
- package/dist/functional/result/impl/result-unwrap-ok-or.mjs.map +0 -1
- package/dist/functional/result/impl/result-unwrap-ok.d.mts +0 -26
- package/dist/functional/result/impl/result-unwrap-ok.d.mts.map +0 -1
- package/dist/functional/result/impl/result-unwrap-ok.mjs +0 -8
- package/dist/functional/result/impl/result-unwrap-ok.mjs.map +0 -1
- package/dist/functional/result/impl/result-unwrap-throw.d.mts +0 -33
- package/dist/functional/result/impl/result-unwrap-throw.d.mts.map +0 -1
- package/dist/functional/result/impl/result-unwrap-throw.mjs +0 -40
- package/dist/functional/result/impl/result-unwrap-throw.mjs.map +0 -1
- package/dist/functional/result/impl/result-zip.d.mts +0 -32
- package/dist/functional/result/impl/result-zip.d.mts.map +0 -1
- package/dist/functional/result/impl/result-zip.mjs +0 -37
- package/dist/functional/result/impl/result-zip.mjs.map +0 -1
- package/dist/functional/result/impl/tag.d.mts +0 -6
- package/dist/functional/result/impl/tag.d.mts.map +0 -1
- package/dist/functional/result/impl/tag.mjs +0 -4
- package/dist/functional/result/impl/tag.mjs.map +0 -1
- package/dist/functional/result/impl/types.d.mts +0 -31
- package/dist/functional/result/impl/types.d.mts.map +0 -1
- package/dist/functional/result/impl/types.mjs +0 -2
- package/dist/functional/result/impl/types.mjs.map +0 -1
- package/dist/functional/result/index.d.mts +0 -2
- package/dist/functional/result/index.d.mts.map +0 -1
- package/dist/functional/result/index.mjs +0 -2
- package/dist/functional/result/index.mjs.map +0 -1
- package/dist/functional/result/result.d.mts +0 -16
- package/dist/functional/result/result.d.mts.map +0 -1
- package/dist/functional/result/result.mjs +0 -2
- package/dist/functional/result/result.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/index.d.mts +0 -29
- package/dist/functional/ternary-result/impl/index.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/index.mjs +0 -29
- package/dist/functional/ternary-result/impl/index.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/tag.d.mts +0 -8
- package/dist/functional/ternary-result/impl/tag.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/tag.mjs +0 -6
- package/dist/functional/ternary-result/impl/tag.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-err.d.mts +0 -16
- package/dist/functional/ternary-result/impl/ternary-result-err.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-err.mjs +0 -19
- package/dist/functional/ternary-result/impl/ternary-result-err.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.d.mts +0 -24
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs +0 -21
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.d.mts +0 -39
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs +0 -38
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-fold.d.mts +0 -30
- package/dist/functional/ternary-result/impl/ternary-result-fold.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-fold.mjs +0 -33
- package/dist/functional/ternary-result/impl/ternary-result-fold.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts +0 -23
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs +0 -23
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts +0 -20
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +0 -33
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-err.d.mts +0 -21
- package/dist/functional/ternary-result/impl/ternary-result-is-err.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs +0 -20
- package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts +0 -23
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs +0 -22
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts +0 -22
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs +0 -28
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.d.mts +0 -22
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs +0 -21
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-map-err.d.mts +0 -27
- package/dist/functional/ternary-result/impl/ternary-result-map-err.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs +0 -23
- package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.d.mts +0 -28
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs +0 -26
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-map.d.mts +0 -36
- package/dist/functional/ternary-result/impl/ternary-result-map.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-map.mjs +0 -32
- package/dist/functional/ternary-result/impl/ternary-result-map.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts +0 -17
- package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-ok.mjs +0 -20
- package/dist/functional/ternary-result/impl/ternary-result-ok.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-or-else.d.mts +0 -29
- package/dist/functional/ternary-result/impl/ternary-result-or-else.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs +0 -16
- package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.d.mts +0 -23
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs +0 -26
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.d.mts +0 -28
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs +0 -14
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.d.mts +0 -20
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs +0 -34
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.d.mts +0 -20
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs +0 -21
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.d.mts +0 -25
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs +0 -14
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.d.mts +0 -20
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs +0 -10
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts +0 -21
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs +0 -35
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.d.mts +0 -22
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs +0 -14
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.d.mts +0 -20
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs +0 -30
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.d.mts +0 -20
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs +0 -21
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts +0 -19
- package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-warn.mjs +0 -23
- package/dist/functional/ternary-result/impl/ternary-result-warn.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts +0 -34
- package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/ternary-result-zip.mjs +0 -52
- package/dist/functional/ternary-result/impl/ternary-result-zip.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/types.d.mts +0 -26
- package/dist/functional/ternary-result/impl/types.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/types.mjs +0 -2
- package/dist/functional/ternary-result/impl/types.mjs.map +0 -1
- package/dist/functional/ternary-result/impl/variant-name.d.mts +0 -4
- package/dist/functional/ternary-result/impl/variant-name.d.mts.map +0 -1
- package/dist/functional/ternary-result/impl/variant-name.mjs +0 -13
- package/dist/functional/ternary-result/impl/variant-name.mjs.map +0 -1
- package/dist/functional/ternary-result/index.d.mts +0 -2
- package/dist/functional/ternary-result/index.d.mts.map +0 -1
- package/dist/functional/ternary-result/index.mjs +0 -2
- package/dist/functional/ternary-result/index.mjs.map +0 -1
- package/dist/functional/ternary-result/ternary-result.d.mts +0 -40
- package/dist/functional/ternary-result/ternary-result.d.mts.map +0 -1
- package/dist/functional/ternary-result/ternary-result.mjs +0 -2
- package/dist/functional/ternary-result/ternary-result.mjs.map +0 -1
- package/src/functional/async-result/async-result.mts +0 -17
- package/src/functional/async-result/impl/async-result-flat-map.mts +0 -99
- package/src/functional/async-result/impl/async-result-from-promise.mts +0 -69
- package/src/functional/async-result/impl/async-result-from-throwable.mts +0 -78
- package/src/functional/async-result/impl/async-result-map-err.mts +0 -84
- package/src/functional/async-result/impl/async-result-map.mts +0 -94
- package/src/functional/async-result/impl/async-result-unwrap-or.mts +0 -42
- package/src/functional/async-result/impl/index.mts +0 -7
- package/src/functional/async-result/impl/types.mts +0 -51
- package/src/functional/async-result/index.mts +0 -1
- package/src/functional/async-result.test.mts +0 -291
- package/src/functional/match.mts +0 -193
- package/src/functional/match.test.mts +0 -180
- package/src/functional/optional/impl/index.mts +0 -18
- package/src/functional/optional/impl/optional-expect-to-be.mts +0 -75
- package/src/functional/optional/impl/optional-filter.mts +0 -78
- package/src/functional/optional/impl/optional-flat-map.mts +0 -75
- package/src/functional/optional/impl/optional-from-nullable.mts +0 -31
- package/src/functional/optional/impl/optional-is-none.mts +0 -26
- package/src/functional/optional/impl/optional-is-optional.mts +0 -30
- package/src/functional/optional/impl/optional-is-some.mts +0 -27
- package/src/functional/optional/impl/optional-map.mts +0 -90
- package/src/functional/optional/impl/optional-match.mts +0 -108
- package/src/functional/optional/impl/optional-none.mts +0 -20
- package/src/functional/optional/impl/optional-or-else.mts +0 -83
- package/src/functional/optional/impl/optional-some.mts +0 -27
- package/src/functional/optional/impl/optional-to-nullable.mts +0 -34
- package/src/functional/optional/impl/optional-unwrap-or.mts +0 -70
- package/src/functional/optional/impl/optional-unwrap-throw.mts +0 -41
- package/src/functional/optional/impl/optional-unwrap.mts +0 -45
- package/src/functional/optional/impl/optional-zip.mts +0 -44
- package/src/functional/optional/impl/tag.mts +0 -8
- package/src/functional/optional/impl/types.mts +0 -31
- package/src/functional/optional/index.mts +0 -1
- package/src/functional/optional/optional.mts +0 -19
- package/src/functional/optional.test.mts +0 -883
- package/src/functional/pipe.mts +0 -180
- package/src/functional/pipe.test.mts +0 -155
- package/src/functional/result/impl/index.mts +0 -27
- package/src/functional/result/impl/result-err.mts +0 -33
- package/src/functional/result/impl/result-expect-to-be.mts +0 -73
- package/src/functional/result/impl/result-flat-map.mts +0 -88
- package/src/functional/result/impl/result-fold.mts +0 -102
- package/src/functional/result/impl/result-from-optional.mts +0 -80
- package/src/functional/result/impl/result-from-promise.mts +0 -51
- package/src/functional/result/impl/result-from-throwable.mts +0 -48
- package/src/functional/result/impl/result-is-err.mts +0 -26
- package/src/functional/result/impl/result-is-ok.mts +0 -26
- package/src/functional/result/impl/result-is-result.mts +0 -28
- package/src/functional/result/impl/result-map-err.mts +0 -96
- package/src/functional/result/impl/result-map.mts +0 -96
- package/src/functional/result/impl/result-match.mts +0 -108
- package/src/functional/result/impl/result-ok.mts +0 -33
- package/src/functional/result/impl/result-or-else.mts +0 -73
- package/src/functional/result/impl/result-safe-try.mts +0 -110
- package/src/functional/result/impl/result-safe-unwrap.mts +0 -50
- package/src/functional/result/impl/result-swap.mts +0 -31
- package/src/functional/result/impl/result-to-optional.mts +0 -37
- package/src/functional/result/impl/result-unwrap-err-or.mts +0 -66
- package/src/functional/result/impl/result-unwrap-err-throw.mts +0 -56
- package/src/functional/result/impl/result-unwrap-err.mts +0 -38
- package/src/functional/result/impl/result-unwrap-ok-or.mts +0 -66
- package/src/functional/result/impl/result-unwrap-ok.mts +0 -39
- package/src/functional/result/impl/result-unwrap-throw.mts +0 -46
- package/src/functional/result/impl/result-zip.mts +0 -42
- package/src/functional/result/impl/tag.mts +0 -8
- package/src/functional/result/impl/types.mts +0 -38
- package/src/functional/result/index.mts +0 -1
- package/src/functional/result/result.mts +0 -19
- package/src/functional/result.test.mts +0 -1349
- package/src/functional/ternary-result/impl/index.mts +0 -28
- package/src/functional/ternary-result/impl/tag.mts +0 -17
- package/src/functional/ternary-result/impl/ternary-result-err.mts +0 -21
- package/src/functional/ternary-result/impl/ternary-result-expect-to-be.mts +0 -65
- package/src/functional/ternary-result/impl/ternary-result-flat-map.mts +0 -112
- package/src/functional/ternary-result/impl/ternary-result-fold.mts +0 -102
- package/src/functional/ternary-result/impl/ternary-result-from-promise.mts +0 -30
- package/src/functional/ternary-result/impl/ternary-result-from-throwable.mts +0 -36
- package/src/functional/ternary-result/impl/ternary-result-is-err.mts +0 -24
- package/src/functional/ternary-result/impl/ternary-result-is-ok.mts +0 -26
- package/src/functional/ternary-result/impl/ternary-result-is-ternary-result.mts +0 -32
- package/src/functional/ternary-result/impl/ternary-result-is-warn.mts +0 -25
- package/src/functional/ternary-result/impl/ternary-result-map-err.mts +0 -74
- package/src/functional/ternary-result/impl/ternary-result-map-warn.mts +0 -79
- package/src/functional/ternary-result/impl/ternary-result-map.mts +0 -95
- package/src/functional/ternary-result/impl/ternary-result-ok.mts +0 -22
- package/src/functional/ternary-result/impl/ternary-result-or-else.mts +0 -72
- package/src/functional/ternary-result/impl/ternary-result-to-optional.mts +0 -31
- package/src/functional/ternary-result/impl/ternary-result-unwrap-err-or.mts +0 -54
- package/src/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mts +0 -42
- package/src/functional/ternary-result/impl/ternary-result-unwrap-err.mts +0 -25
- package/src/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mts +0 -51
- package/src/functional/ternary-result/impl/ternary-result-unwrap-ok.mts +0 -39
- package/src/functional/ternary-result/impl/ternary-result-unwrap-throw.mts +0 -48
- package/src/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mts +0 -48
- package/src/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mts +0 -40
- package/src/functional/ternary-result/impl/ternary-result-unwrap-warn.mts +0 -25
- package/src/functional/ternary-result/impl/ternary-result-warn.mts +0 -28
- package/src/functional/ternary-result/impl/ternary-result-zip.mts +0 -61
- package/src/functional/ternary-result/impl/types.mts +0 -46
- package/src/functional/ternary-result/impl/variant-name.mts +0 -18
- package/src/functional/ternary-result/index.mts +0 -1
- package/src/functional/ternary-result/ternary-result.mts +0 -50
- package/src/functional/ternary-result.test.mts +0 -310
- package/src/guard/has-key.test.mts +0 -111
- package/src/guard/is-non-null-object.test.mts +0 -109
- package/src/guard/is-record.test.mts +0 -195
- package/src/guard/key-is-in.test.mts +0 -21
- package/src/others/unknown-to-string.test.mts +0 -295
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { Result } from '../../result/index.mjs';
|
|
2
|
-
export function flatMap(...args) {
|
|
3
|
-
switch (args.length) {
|
|
4
|
-
case 2: {
|
|
5
|
-
|
|
6
|
-
const [asyncResult, flatMapFn] = args;
|
|
7
|
-
return flatMapImpl(asyncResult, flatMapFn);
|
|
8
|
-
}
|
|
9
|
-
case 1: {
|
|
10
|
-
|
|
11
|
-
const [flatMapFn] = args;
|
|
12
|
-
return (asyncResult) => flatMapImpl(asyncResult, flatMapFn);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
const flatMapImpl = async (asyncResult, flatMapFn) => {
|
|
17
|
-
const result = await asyncResult;
|
|
18
|
-
return Result.isErr(result)
|
|
19
|
-
? result
|
|
20
|
-
:
|
|
21
|
-
(await flatMapFn(result.value));
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=async-result-flat-map.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"async-result-flat-map.mjs","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/async-result-flat-map.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAsB,MAAM,wBAAwB,CAAC;AA6DpE,MAAM,UAAU,OAAO,CACrB,GAAG,IAEuC;IAM1C,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,CAAC,EAAE,CAAC;YACP,gDAAgD;YAChD,MAAM,CAAC,WAAW,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC;YAEtC,OAAO,WAAW,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QAC7C,CAAC;QAED,KAAK,CAAC,EAAE,CAAC;YACP,kBAAkB;YAClB,MAAM,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;YAEzB,OAAO,CAAC,WAA8B,EAAE,EAAE,CACxC,WAAW,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,WAAW,GAAG,KAAK,EACvB,WAA8B,EAC9B,SAA2B,EACmB,EAAE;IAChD,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC;IAEjC,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC;QACzB,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,oEAAoE;YACnE,CAAC,MAAM,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAyC,CAAC;AAC/E,CAAC,CAAC"}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { type AsyncResult } from '../async-result.mjs';
|
|
2
|
-
/**
|
|
3
|
-
* Converts a `Promise` into an `AsyncResult`. If the input Promise resolves,
|
|
4
|
-
* the `AsyncResult` resolves to `Ok` with the resolved value. If the input
|
|
5
|
-
* Promise rejects, the rejection reason is passed through `mapError` and the
|
|
6
|
-
* `AsyncResult` resolves to `Err` with the mapped error.
|
|
7
|
-
*
|
|
8
|
-
* Passing `mapError` is what gives the error channel a concrete type `E`.
|
|
9
|
-
* Omitting it carries the rejection reason through untouched, leaving the
|
|
10
|
-
* error channel as `unknown` — the same contract as `Result.fromPromise`.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
*
|
|
14
|
-
* ```ts
|
|
15
|
-
* const resolved = await AsyncResult.fromPromise(
|
|
16
|
-
* Promise.resolve('ok'),
|
|
17
|
-
* (error) => `failed: ${String(error)}`,
|
|
18
|
-
* );
|
|
19
|
-
*
|
|
20
|
-
* const rejected = await AsyncResult.fromPromise(
|
|
21
|
-
* Promise.reject(new Error('boom')),
|
|
22
|
-
* (error) => (isError(error) ? error.message : 'unknown'),
|
|
23
|
-
* );
|
|
24
|
-
*
|
|
25
|
-
* assert.deepStrictEqual(resolved, Result.ok('ok'));
|
|
26
|
-
*
|
|
27
|
-
* assert.deepStrictEqual(rejected, Result.err('boom'));
|
|
28
|
-
*
|
|
29
|
-
* // Without `mapError`, the rejection reason is carried as-is.
|
|
30
|
-
* const untyped = await AsyncResult.fromPromise(
|
|
31
|
-
* Promise.reject(new Error('boom')),
|
|
32
|
-
* );
|
|
33
|
-
*
|
|
34
|
-
* assert.isTrue(Result.isErr(untyped));
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
* @template S The type of the success value.
|
|
38
|
-
* @template E The type of the error value.
|
|
39
|
-
* @param promise The Promise to convert.
|
|
40
|
-
* @param mapError The function applied to the rejection reason to produce the
|
|
41
|
-
* error value. Omit it to carry the rejection reason as `unknown`.
|
|
42
|
-
* @returns An `AsyncResult<S, E>` that never rejects for the input Promise's
|
|
43
|
-
* failure.
|
|
44
|
-
*/
|
|
45
|
-
export declare function fromPromise<S>(promise: Promise<S>): AsyncResult<S, unknown>;
|
|
46
|
-
export declare function fromPromise<S, E>(promise: Promise<S>, mapError: (error: unknown) => E): AsyncResult<S, E>;
|
|
47
|
-
//# sourceMappingURL=async-result-from-promise.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"async-result-from-promise.d.mts","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/async-result-from-promise.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AAE7E,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAC9B,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,CAAC,GAC9B,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Result } from '../../result/index.mjs';
|
|
2
|
-
export function fromPromise(promise, mapError) {
|
|
3
|
-
return mapError === undefined
|
|
4
|
-
? fromPromiseImpl(promise, (error) => error)
|
|
5
|
-
: fromPromiseImpl(promise, mapError);
|
|
6
|
-
}
|
|
7
|
-
const fromPromiseImpl = (promise, mapError) => promise
|
|
8
|
-
.then((value) => Result.ok(value))
|
|
9
|
-
.catch((error) => Result.err(mapError(error)));
|
|
10
|
-
//# sourceMappingURL=async-result-from-promise.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"async-result-from-promise.mjs","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/async-result-from-promise.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAqDhD,MAAM,UAAU,WAAW,CACzB,OAAmB,EACnB,QAAgC;IAEhC,OAAO,QAAQ,KAAK,SAAS;QAC3B,CAAC,CAAC,eAAe,CAAC,OAAO,EAAE,CAAC,KAAc,EAAE,EAAE,CAAC,KAAK,CAAC;QACrD,CAAC,CAAC,eAAe,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,eAAe,GAAG,CACtB,OAAmB,EACnB,QAA+B,EACZ,EAAE,CACrB,OAAO;KACJ,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC;KACjC,KAAK,CAAC,CAAC,KAAc,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { type AsyncResult } from '../async-result.mjs';
|
|
2
|
-
/**
|
|
3
|
-
* Wraps a function returning a `Promise` in an `AsyncResult`. Both a
|
|
4
|
-
* synchronous `throw` while calling `fn` and an asynchronous rejection of the
|
|
5
|
-
* returned Promise are caught, passed through `mapError`, and carried as
|
|
6
|
-
* `Err`.
|
|
7
|
-
*
|
|
8
|
-
* Passing `mapError` is what gives the error channel a concrete type `E`.
|
|
9
|
-
* Omitting it carries the thrown value through untouched, leaving the error
|
|
10
|
-
* channel as `unknown`.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
*
|
|
14
|
-
* ```ts
|
|
15
|
-
* const success = await AsyncResult.fromThrowable(
|
|
16
|
-
* () => Promise.resolve(2),
|
|
17
|
-
* (error) => `failed: ${String(error)}`,
|
|
18
|
-
* );
|
|
19
|
-
*
|
|
20
|
-
* const failure = await AsyncResult.fromThrowable(
|
|
21
|
-
* (): Promise<number> => {
|
|
22
|
-
* throw new Error('boom');
|
|
23
|
-
* },
|
|
24
|
-
* (error) => (isError(error) ? error.message : 'unknown'),
|
|
25
|
-
* );
|
|
26
|
-
*
|
|
27
|
-
* assert.deepStrictEqual(success, Result.ok(2));
|
|
28
|
-
*
|
|
29
|
-
* assert.deepStrictEqual(failure, Result.err('boom'));
|
|
30
|
-
*
|
|
31
|
-
* // Without `mapError`, the thrown value is carried as-is.
|
|
32
|
-
* const untyped = await AsyncResult.fromThrowable(
|
|
33
|
-
* (): Promise<number> => {
|
|
34
|
-
* throw new Error('boom');
|
|
35
|
-
* },
|
|
36
|
-
* );
|
|
37
|
-
*
|
|
38
|
-
* assert.isTrue(Result.isErr(untyped));
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* @template S The type of the success value.
|
|
42
|
-
* @template E The type of the error value.
|
|
43
|
-
* @param fn The function to execute; it may throw synchronously or return a
|
|
44
|
-
* rejecting Promise.
|
|
45
|
-
* @param mapError The function applied to the thrown value or rejection
|
|
46
|
-
* reason to produce the error value. Omit it to carry the thrown value as
|
|
47
|
-
* `unknown`.
|
|
48
|
-
* @returns An `AsyncResult<S, E>` containing either the resolved value or the
|
|
49
|
-
* mapped error.
|
|
50
|
-
*/
|
|
51
|
-
export declare function fromThrowable<S>(fn: () => Promise<S>): AsyncResult<S, unknown>;
|
|
52
|
-
export declare function fromThrowable<S, E>(fn: () => Promise<S>, mapError: (error: unknown) => E): AsyncResult<S, E>;
|
|
53
|
-
//# sourceMappingURL=async-result-from-throwable.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"async-result-from-throwable.d.mts","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/async-result-from-throwable.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AAEhF,wBAAgB,aAAa,CAAC,CAAC,EAAE,CAAC,EAChC,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,QAAQ,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,CAAC,GAC9B,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Result } from '../../result/index.mjs';
|
|
2
|
-
export function fromThrowable(fn, mapError) {
|
|
3
|
-
return mapError === undefined
|
|
4
|
-
? fromThrowableImpl(fn, (error) => error)
|
|
5
|
-
: fromThrowableImpl(fn, mapError);
|
|
6
|
-
}
|
|
7
|
-
const fromThrowableImpl = async (fn, mapError) => {
|
|
8
|
-
try {
|
|
9
|
-
return Result.ok(await fn());
|
|
10
|
-
}
|
|
11
|
-
catch (error) {
|
|
12
|
-
return Result.err(mapError(error));
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=async-result-from-throwable.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"async-result-from-throwable.mjs","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/async-result-from-throwable.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AA2DhD,MAAM,UAAU,aAAa,CAC3B,EAAoB,EACpB,QAAgC;IAEhC,OAAO,QAAQ,KAAK,SAAS;QAC3B,CAAC,CAAC,iBAAiB,CAAC,EAAE,EAAE,CAAC,KAAc,EAAE,EAAE,CAAC,KAAK,CAAC;QAClD,CAAC,CAAC,iBAAiB,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,iBAAiB,GAAG,KAAK,EAC7B,EAAoB,EACpB,QAA+B,EACZ,EAAE;IACrB,IAAI,CAAC;QACH,OAAO,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC/B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC;IACrC,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { type AsyncResult } from '../async-result.mjs';
|
|
2
|
-
/**
|
|
3
|
-
* Maps an `AsyncResult<S, E>` to `AsyncResult<S, E2>` by applying a function
|
|
4
|
-
* to the error value. The mapping function may be synchronous or return a
|
|
5
|
-
* `Promise`; both are handled transparently. If the `AsyncResult` resolves to
|
|
6
|
-
* `Ok`, the original `Ok` is passed through and the function is not called.
|
|
7
|
-
*
|
|
8
|
-
* If `mapFn` throws or returns a rejecting Promise, the rejection propagates
|
|
9
|
-
* as-is — it is **not** caught and converted into an `Err`.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
*
|
|
13
|
-
* ```ts
|
|
14
|
-
* const errValue = AsyncResult.fromPromise(
|
|
15
|
-
* Promise.reject(new Error('boom')),
|
|
16
|
-
* () => 'failure',
|
|
17
|
-
* );
|
|
18
|
-
*
|
|
19
|
-
* const uppercased = await AsyncResult.mapErr(errValue, (error) =>
|
|
20
|
-
* error.toUpperCase(),
|
|
21
|
-
* );
|
|
22
|
-
*
|
|
23
|
-
* assert.deepStrictEqual(uppercased, Result.err('FAILURE'));
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* @template S The type of the success value.
|
|
27
|
-
* @template E The type of the error value of the input.
|
|
28
|
-
* @template E2 The type of the error value returned by the mapping function.
|
|
29
|
-
* @param asyncResult The `AsyncResult` to map.
|
|
30
|
-
* @param mapFn The function to apply to the error value if present.
|
|
31
|
-
* @returns A new `AsyncResult<S, E2>`.
|
|
32
|
-
*/
|
|
33
|
-
export declare function mapErr<S, E, E2>(asyncResult: AsyncResult<S, E>, mapFn: (error: E) => E2 | Promise<E2>): AsyncResult<S, E2>;
|
|
34
|
-
export declare function mapErr<E, E2>(mapFn: (error: E) => E2 | Promise<E2>): <S>(asyncResult: AsyncResult<S, E>) => AsyncResult<S, E2>;
|
|
35
|
-
//# sourceMappingURL=async-result-map-err.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"async-result-map-err.d.mts","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/async-result-map-err.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAC7B,WAAW,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EAC9B,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC,GACpC,WAAW,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAQtB,wBAAgB,MAAM,CAAC,CAAC,EAAE,EAAE,EAC1B,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC,GACpC,CAAC,CAAC,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Result } from '../../result/index.mjs';
|
|
2
|
-
export function mapErr(...args) {
|
|
3
|
-
switch (args.length) {
|
|
4
|
-
case 2: {
|
|
5
|
-
|
|
6
|
-
const [asyncResult, mapFn] = args;
|
|
7
|
-
return mapErrImpl(asyncResult, mapFn);
|
|
8
|
-
}
|
|
9
|
-
case 1: {
|
|
10
|
-
|
|
11
|
-
const [mapFn] = args;
|
|
12
|
-
return (asyncResult) => mapErrImpl(asyncResult, mapFn);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
const mapErrImpl = async (asyncResult, mapFn) => {
|
|
17
|
-
const result = await asyncResult;
|
|
18
|
-
return Result.isOk(result) ? result : Result.err(await mapFn(result.value));
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=async-result-map-err.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"async-result-map-err.mjs","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/async-result-map-err.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAiDhD,MAAM,UAAU,MAAM,CACpB,GAAG,IAKiD;IAIpD,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,CAAC,EAAE,CAAC;YACP,gDAAgD;YAChD,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;YAElC,OAAO,UAAU,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QACxC,CAAC;QAED,KAAK,CAAC,EAAE,CAAC;YACP,sDAAsD;YACtD,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;YAErB,OAAO,CAAC,WAA8B,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QAC5E,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,UAAU,GAAG,KAAK,EACtB,WAA8B,EAC9B,KAAqC,EACjB,EAAE;IACtB,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC;IAEjC,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9E,CAAC,CAAC"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { type AsyncResult } from '../async-result.mjs';
|
|
2
|
-
/**
|
|
3
|
-
* Maps an `AsyncResult<S, E>` to `AsyncResult<S2, E>` by applying a function
|
|
4
|
-
* to the success value. The mapping function may be synchronous or return a
|
|
5
|
-
* `Promise`; both are handled transparently. If the `AsyncResult` resolves to
|
|
6
|
-
* `Err`, the original `Err` is passed through and the function is not called.
|
|
7
|
-
*
|
|
8
|
-
* If `mapFn` throws or returns a rejecting Promise, the rejection propagates
|
|
9
|
-
* as-is — it is **not** caught and converted into an `Err`. `map` performs no
|
|
10
|
-
* implicit error conversion; write a fallible step as
|
|
11
|
-
* `AsyncResult.flatMap` combined with `AsyncResult.fromThrowable` instead, so
|
|
12
|
-
* that the error type stays explicit.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
*
|
|
16
|
-
* ```ts
|
|
17
|
-
* const okValue = AsyncResult.fromPromise(
|
|
18
|
-
* Promise.resolve(5),
|
|
19
|
-
* () => 'failed',
|
|
20
|
-
* );
|
|
21
|
-
*
|
|
22
|
-
* const doubled = await AsyncResult.map(okValue, (value) => value * 2);
|
|
23
|
-
*
|
|
24
|
-
* assert.deepStrictEqual(doubled, Result.ok(10));
|
|
25
|
-
*
|
|
26
|
-
* const double = AsyncResult.map((value: number) => value * 2);
|
|
27
|
-
*
|
|
28
|
-
* const curried = await double(
|
|
29
|
-
* AsyncResult.fromPromise(Promise.resolve(21), () => 'failed'),
|
|
30
|
-
* );
|
|
31
|
-
*
|
|
32
|
-
* assert.deepStrictEqual(curried, Result.ok(42));
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
|
-
* @template S The type of the success value of the input.
|
|
36
|
-
* @template S2 The type of the success value returned by the mapping
|
|
37
|
-
* function.
|
|
38
|
-
* @template E The type of the error value.
|
|
39
|
-
* @param asyncResult The `AsyncResult` to map.
|
|
40
|
-
* @param mapFn The function to apply to the success value if present.
|
|
41
|
-
* @returns A new `AsyncResult<S2, E>`.
|
|
42
|
-
*/
|
|
43
|
-
export declare function map<S, S2, E>(asyncResult: AsyncResult<S, E>, mapFn: (value: S) => Promise<S2> | S2): AsyncResult<S2, E>;
|
|
44
|
-
export declare function map<S, S2>(mapFn: (value: S) => Promise<S2> | S2): <E>(asyncResult: AsyncResult<S, E>) => AsyncResult<S2, E>;
|
|
45
|
-
//# sourceMappingURL=async-result-map.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"async-result-map.d.mts","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/async-result-map.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAC1B,WAAW,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EAC9B,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,GACpC,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;AAQtB,wBAAgB,GAAG,CAAC,CAAC,EAAE,EAAE,EACvB,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,GACpC,CAAC,CAAC,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,WAAW,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Result } from '../../result/index.mjs';
|
|
2
|
-
export function map(...args) {
|
|
3
|
-
switch (args.length) {
|
|
4
|
-
case 2: {
|
|
5
|
-
|
|
6
|
-
const [asyncResult, mapFn] = args;
|
|
7
|
-
return mapImpl(asyncResult, mapFn);
|
|
8
|
-
}
|
|
9
|
-
case 1: {
|
|
10
|
-
|
|
11
|
-
const [mapFn] = args;
|
|
12
|
-
return (asyncResult) => mapImpl(asyncResult, mapFn);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
const mapImpl = async (asyncResult, mapFn) => {
|
|
17
|
-
const result = await asyncResult;
|
|
18
|
-
return Result.isErr(result) ? result : Result.ok(await mapFn(result.value));
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=async-result-map.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"async-result-map.mjs","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/async-result-map.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AA2DhD,MAAM,UAAU,GAAG,CACjB,GAAG,IAKiD;IAIpD,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,CAAC,EAAE,CAAC;YACP,gDAAgD;YAChD,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;YAElC,OAAO,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QACrC,CAAC;QAED,KAAK,CAAC,EAAE,CAAC;YACP,kBAAkB;YAClB,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;YAErB,OAAO,CAAC,WAA8B,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,OAAO,GAAG,KAAK,EACnB,WAA8B,EAC9B,KAAqC,EACjB,EAAE;IACtB,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC;IAEjC,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;AAC9E,CAAC,CAAC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { type AsyncResult } from '../async-result.mjs';
|
|
2
|
-
/**
|
|
3
|
-
* Unwraps an `AsyncResult`, resolving to the success value or a default value
|
|
4
|
-
* if it resolves to `Err`.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
*
|
|
8
|
-
* ```ts
|
|
9
|
-
* const okValue = AsyncResult.fromPromise(
|
|
10
|
-
* Promise.resolve(10),
|
|
11
|
-
* () => 'failed',
|
|
12
|
-
* );
|
|
13
|
-
*
|
|
14
|
-
* const errValue = AsyncResult.fromPromise(
|
|
15
|
-
* Promise.reject(new Error('boom')),
|
|
16
|
-
* () => 'failed',
|
|
17
|
-
* );
|
|
18
|
-
*
|
|
19
|
-
* assert.isTrue((await AsyncResult.unwrapOr(okValue, 0)) === 10);
|
|
20
|
-
*
|
|
21
|
-
* assert.isTrue((await AsyncResult.unwrapOr(errValue, 0)) === 0);
|
|
22
|
-
* ```
|
|
23
|
-
*
|
|
24
|
-
* @template S The type of the success value.
|
|
25
|
-
* @template E The type of the error value.
|
|
26
|
-
* @template D The type of the default value.
|
|
27
|
-
* @param asyncResult The `AsyncResult` to unwrap.
|
|
28
|
-
* @param defaultValue The value to resolve to if `asyncResult` resolves to
|
|
29
|
-
* `Err`.
|
|
30
|
-
* @returns A Promise of the success value if `Ok`, otherwise of
|
|
31
|
-
* `defaultValue`.
|
|
32
|
-
*/
|
|
33
|
-
export declare const unwrapOr: <S, E, D>(asyncResult: AsyncResult<S, E>, defaultValue: D) => Promise<D | S>;
|
|
34
|
-
//# sourceMappingURL=async-result-unwrap-or.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"async-result-unwrap-or.d.mts","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/async-result-unwrap-or.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,QAAQ,GAAU,CAAC,EAAE,CAAC,EAAE,CAAC,eACvB,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,gBAChB,CAAC,KACd,OAAO,CAAC,CAAC,GAAG,CAAC,CAIf,CAAC"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Result } from '../../result/index.mjs';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
export const unwrapOr = async (asyncResult, defaultValue) => {
|
|
34
|
-
const result = await asyncResult;
|
|
35
|
-
return Result.isOk(result) ? result.value : defaultValue;
|
|
36
|
-
};
|
|
37
|
-
//# sourceMappingURL=async-result-unwrap-or.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"async-result-unwrap-or.mjs","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/async-result-unwrap-or.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAGhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAC3B,WAA8B,EAC9B,YAAe,EACC,EAAE;IAClB,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC;IAEjC,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,YAAY,CAAC;AAC3D,CAAC,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export * from './async-result-flat-map.mjs';
|
|
2
|
-
export * from './async-result-from-promise.mjs';
|
|
3
|
-
export * from './async-result-from-throwable.mjs';
|
|
4
|
-
export * from './async-result-map-err.mjs';
|
|
5
|
-
export * from './async-result-map.mjs';
|
|
6
|
-
export * from './async-result-unwrap-or.mjs';
|
|
7
|
-
export * from './types.mjs';
|
|
8
|
-
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/index.mts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,aAAa,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export * from './async-result-flat-map.mjs';
|
|
2
|
-
export * from './async-result-from-promise.mjs';
|
|
3
|
-
export * from './async-result-from-throwable.mjs';
|
|
4
|
-
export * from './async-result-map-err.mjs';
|
|
5
|
-
export * from './async-result-map.mjs';
|
|
6
|
-
export * from './async-result-unwrap-or.mjs';
|
|
7
|
-
export * from './types.mjs';
|
|
8
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/index.mts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,mCAAmC,CAAC;AAClD,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,aAAa,CAAC"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { type Err, type Ok } from '../../../types.mjs';
|
|
2
|
-
import { type UnknownResult } from '../../result/index.mjs';
|
|
3
|
-
import { type AsyncResult } from '../async-result.mjs';
|
|
4
|
-
/**
|
|
5
|
-
* Base type for any `AsyncResult`, used for generic constraints. Represents
|
|
6
|
-
* an `AsyncResult` with unknown success and error types.
|
|
7
|
-
*/
|
|
8
|
-
export type UnknownAsyncResult = AsyncResult<unknown, unknown>;
|
|
9
|
-
/**
|
|
10
|
-
* Extracts the success value type `S` from a `Result.Ok<S>`, or from an
|
|
11
|
-
* `AsyncResult` resolving to one. Distributes over unions, so an
|
|
12
|
-
* `Ok<S> | Err<E>` union resolves to `S`.
|
|
13
|
-
*
|
|
14
|
-
* @template R The `Result` or `AsyncResult` type to unwrap.
|
|
15
|
-
*/
|
|
16
|
-
export type UnwrapOk<R extends UnknownAsyncResult | UnknownResult> = UnwrapOkImpl<SyncResultOf<R>>;
|
|
17
|
-
/**
|
|
18
|
-
* Extracts the error value type `E` from a `Result.Err<E>`, or from an
|
|
19
|
-
* `AsyncResult` resolving to one. Distributes over unions, so an
|
|
20
|
-
* `Ok<S> | Err<E>` union resolves to `E`.
|
|
21
|
-
*
|
|
22
|
-
* @template R The `Result` or `AsyncResult` type to unwrap.
|
|
23
|
-
*/
|
|
24
|
-
export type UnwrapErr<R extends UnknownAsyncResult | UnknownResult> = UnwrapErrImpl<SyncResultOf<R>>;
|
|
25
|
-
/**
|
|
26
|
-
* @template R The `Result` or `AsyncResult` type.
|
|
27
|
-
* @internal
|
|
28
|
-
* Resolves an `AsyncResult` to its `Result`, leaving a plain `Result`
|
|
29
|
-
* unchanged. Distributive.
|
|
30
|
-
*/
|
|
31
|
-
type SyncResultOf<R> = R extends Promise<infer P> ? P : R;
|
|
32
|
-
/**
|
|
33
|
-
* @template R The `Result` type to unwrap.
|
|
34
|
-
* @internal
|
|
35
|
-
* Distributive extraction of the `Ok` value type.
|
|
36
|
-
*/
|
|
37
|
-
type UnwrapOkImpl<R> = R extends Ok<infer S> ? S : never;
|
|
38
|
-
/**
|
|
39
|
-
* @template R The `Result` type to unwrap.
|
|
40
|
-
* @internal
|
|
41
|
-
* Distributive extraction of the `Err` value type.
|
|
42
|
-
*/
|
|
43
|
-
type UnwrapErrImpl<R> = R extends Err<infer E> ? E : never;
|
|
44
|
-
export {};
|
|
45
|
-
//# sourceMappingURL=types.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/types.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,KAAK,EAAE,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;GAGG;AACH,MAAM,MAAM,kBAAkB,GAAG,WAAW,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAE/D;;;;;;GAMG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,kBAAkB,GAAG,aAAa,IAC/D,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;AAEhC;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,kBAAkB,GAAG,aAAa,IAChE,aAAa,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;AAEjC;;;;;GAKG;AACH,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAE1D;;;;GAIG;AACH,KAAK,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAEzD;;;;GAIG;AACH,KAAK,aAAa,CAAC,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../../src/functional/async-result/impl/types.mts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../src/functional/async-result/index.mts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/functional/async-result/index.mts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { type ReadonlyRecord, type RelaxedExclude, type TypeEq, type UnknownRecord, type ValueOf } from 'ts-type-forge';
|
|
2
|
-
/**
|
|
3
|
-
* Type-safe pattern matching function for string-based discriminated unions.
|
|
4
|
-
*
|
|
5
|
-
* Provides compile-time guarantees for exhaustive case handling when working
|
|
6
|
-
* with literal string unions. Automatically enforces completeness checking when
|
|
7
|
-
* all cases are covered, and requires a default value when cases are
|
|
8
|
-
* incomplete.
|
|
9
|
-
*
|
|
10
|
-
* ## Key Features:
|
|
11
|
-
*
|
|
12
|
-
* - **Exhaustive Matching**: When all cases of a literal union are handled, no
|
|
13
|
-
* default value is needed
|
|
14
|
-
* - **Partial Matching**: When cases are incomplete or working with general
|
|
15
|
-
* string types, a default value is required
|
|
16
|
-
* - **Type Safety**: Prevents extra cases and ensures only valid keys are used
|
|
17
|
-
* - **Strict Property Checking**: Rejects objects with unexpected properties
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
*
|
|
21
|
-
* ```ts
|
|
22
|
-
* type Status = 'draft' | 'review' | 'published';
|
|
23
|
-
*
|
|
24
|
-
* const status: Status = 'draft';
|
|
25
|
-
*
|
|
26
|
-
* const message = match<
|
|
27
|
-
* Status,
|
|
28
|
-
* Readonly<{ draft: string; review: string; published: string }>
|
|
29
|
-
* >(status, {
|
|
30
|
-
* draft: 'Work in progress',
|
|
31
|
-
* review: 'Awaiting feedback',
|
|
32
|
-
* published: 'Complete',
|
|
33
|
-
* });
|
|
34
|
-
*
|
|
35
|
-
* assert.isTrue(message === 'Work in progress');
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
* @param target - The value to match against
|
|
39
|
-
* @param cases - Object mapping possible values to their corresponding results
|
|
40
|
-
* @param defaultValue - Fallback value (required when not all cases are
|
|
41
|
-
* covered)
|
|
42
|
-
* @returns The matched result or default value
|
|
43
|
-
*/
|
|
44
|
-
export declare function match<const Case extends string, const R extends ReadonlyRecord<Case, unknown>>(target: Case, cases: StrictPropertyCheck<R, Case>): R[Case];
|
|
45
|
-
export declare function match<const Case extends string, const R extends UnknownRecord, const D>(target: Case, cases: StrictPropertyCheck<R, Case>, defaultValue: IsLiteralUnionFullyCovered<Case, R> extends true ? never : D): ValueOf<R> | D;
|
|
46
|
-
/**
|
|
47
|
-
* @template T The object type to check.
|
|
48
|
-
* @template ExpectedKeys The union of string literal types representing the
|
|
49
|
-
* allowed keys.
|
|
50
|
-
* @internal
|
|
51
|
-
* Helper type to ensure that an object `T` only contains keys specified in `ExpectedKeys`.
|
|
52
|
-
* If `T` has any keys not in `ExpectedKeys`, this type resolves to `never`.
|
|
53
|
-
*/
|
|
54
|
-
type StrictPropertyCheck<T, ExpectedKeys extends PropertyKey> = RelaxedExclude<keyof T, ExpectedKeys> extends never ? T : never;
|
|
55
|
-
/**
|
|
56
|
-
* @template Case A union of string literal types representing the possible
|
|
57
|
-
* cases.
|
|
58
|
-
* @template R A record type.
|
|
59
|
-
* @internal
|
|
60
|
-
* Helper type to check if all cases in `Case` union are fully covered by keys in `R`.
|
|
61
|
-
* This checks bidirectional coverage: all Case members are in R, and no extra keys.
|
|
62
|
-
*/
|
|
63
|
-
type AllCasesCovered<Case extends PropertyKey, R> = TypeEq<Case, keyof R> extends true ? true : false;
|
|
64
|
-
/**
|
|
65
|
-
* @template Case A union of string literal types.
|
|
66
|
-
* @template R A record type.
|
|
67
|
-
* @internal
|
|
68
|
-
* Helper type to check if Case is a literal union type and all cases are covered.
|
|
69
|
-
*/
|
|
70
|
-
type IsLiteralUnionFullyCovered<Case extends PropertyKey, R extends UnknownRecord> = TypeEq<IsLiteralType<Case>, true> extends true ? AllCasesCovered<Case, R> : false;
|
|
71
|
-
/**
|
|
72
|
-
* @template T The PropertyKey type to check.
|
|
73
|
-
* @returns `true` if `T` is a literal type, `false` otherwise.
|
|
74
|
-
* @internal
|
|
75
|
-
* Helper type to determine if a given PropertyKey `T` is a literal type (e.g., 'a', 1)
|
|
76
|
-
* or a general type (e.g., string, number).
|
|
77
|
-
*/
|
|
78
|
-
type IsLiteralType<T extends PropertyKey> = string extends T ? false : number extends T ? false : symbol extends T ? false : true;
|
|
79
|
-
export {};
|
|
80
|
-
//# sourceMappingURL=match.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"match.d.mts","sourceRoot":"","sources":["../../src/functional/match.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,OAAO,EACb,MAAM,eAAe,CAAC;AAIvB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,KAAK,CACnB,KAAK,CAAC,IAAI,SAAS,MAAM,EACzB,KAAK,CAAC,CAAC,SAAS,cAAc,CAAC,IAAI,EAAE,OAAO,CAAC,EAC7C,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;AAE9D,wBAAgB,KAAK,CACnB,KAAK,CAAC,IAAI,SAAS,MAAM,EACzB,KAAK,CAAC,CAAC,SAAS,aAAa,EAC7B,KAAK,CAAC,CAAC,EAEP,MAAM,EAAE,IAAI,EACZ,KAAK,EAAE,mBAAmB,CAAC,CAAC,EAAE,IAAI,CAAC,EACnC,YAAY,EAAE,0BAA0B,CAAC,IAAI,EAAE,CAAC,CAAC,SAAS,IAAI,GAAG,KAAK,GAAG,CAAC,GACzE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AA0BlB;;;;;;;GAOG;AACH,KAAK,mBAAmB,CAAC,CAAC,EAAE,YAAY,SAAS,WAAW,IAC1D,cAAc,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC,SAAS,KAAK,GAAG,CAAC,GAAG,KAAK,CAAC;AAElE;;;;;;;GAOG;AACH,KAAK,eAAe,CAAC,IAAI,SAAS,WAAW,EAAE,CAAC,IAC9C,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;AAcpD;;;;;GAKG;AACH,KAAK,0BAA0B,CAC7B,IAAI,SAAS,WAAW,EACxB,CAAC,SAAS,aAAa,IAEvB,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC,SAAS,IAAI,GAC1C,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC,GACxB,KAAK,CAAC;AA4BZ;;;;;;GAMG;AACH,KAAK,aAAa,CAAC,CAAC,SAAS,WAAW,IAAI,MAAM,SAAS,CAAC,GACxD,KAAK,GACL,MAAM,SAAS,CAAC,GACd,KAAK,GACL,MAAM,SAAS,CAAC,GACd,KAAK,GACL,IAAI,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { keyIsIn } from '../guard/index.mjs';
|
|
3
|
-
export function match(...args) {
|
|
4
|
-
switch (args.length) {
|
|
5
|
-
case 2: {
|
|
6
|
-
const [target, cases] = args;
|
|
7
|
-
return cases[target];
|
|
8
|
-
}
|
|
9
|
-
case 3: {
|
|
10
|
-
const [target, cases, defaultValue] = args;
|
|
11
|
-
return keyIsIn(target, cases) ? cases[target] : defaultValue;
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
//# sourceMappingURL=match.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"match.mjs","sourceRoot":"","sources":["../../src/functional/match.mts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AA2D7C,MAAM,UAAU,KAAK,CAKnB,GAAG,IAEmD;IAEtD,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,CAAC,EAAE,CAAC;YACP,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;YAE7B,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC;QACvB,CAAC;QAED,KAAK,CAAC,EAAE,CAAC;YACP,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,YAAY,CAAC,GAAG,IAAI,CAAC;YAE3C,OAAO,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;QAC/D,CAAC;IACH,CAAC;AACH,CAAC;AAwBD,UAAU,CAA6D,GAAG,CAAC,CAAC;AAE5E,UAAU,CACR,GAAG,CACJ,CAAC;AAEF,UAAU,CACR,GAAG,CACJ,CAAC;AAEF,UAAU,CAAgE,GAAG,CAAC,CAAC;AAgB/E,UAAU,CAGR,GAAG,CAAC,CAAC;AAEP,UAAU,CAGR,GAAG,CAAC,CAAC;AAEP,UAAU,CAGR,GAAG,CAAC,CAAC;AAEP,UAAU,CAGR,GAAG,CAAC,CAAC;AAEP,UAAU,CAIR,GAAG,CAAC,CAAC;AAiBP,UAAU,CAAiC,GAAG,CAAC,CAAC;AAEhD,UAAU,CAA2B,GAAG,CAAC,CAAC;AAE1C,UAAU,CAA+B,GAAG,CAAC,CAAC;AAE9C,UAAU,CAA+B,GAAG,CAAC,CAAC;AAE9C,UAAU,CAAyB,GAAG,CAAC,CAAC;AAExC,UAAU,CAAsC,GAAG,CAAC,CAAC;AAErD,UAAU,CAAiC,GAAG,CAAC,CAAC"}
|