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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-or-else.mjs","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-or-else.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAgD1C,MAAM,UAAU,MAAM,CACpB,GAAG,IAAwE;IAE3E,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,CAAC,EAAE,CAAC;YACP,2CAA2C;YAC3C,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,IAAI,CAAC;YAEnC,OAAO,UAAU,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QACzC,CAAC;QAED,KAAK,CAAC,EAAE,CAAC;YACP,kBAAkB;YAClB,MAAM,CAAC,WAAW,CAAC,GAAG,IAAI,CAAC;YAE3B,OAAO,CAAC,MAAS,EAAE,EAAE,CAAC,UAAU,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;QACxD,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,UAAU,GAAG,CACjB,MAAS,EACT,WAAe,EACK,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { type Err } from '../../../types.mjs';
|
|
2
|
-
import { type Result, type UnknownResult } from '../result.mjs';
|
|
3
|
-
import { type UnwrapErr, type UnwrapOk } from './types.mjs';
|
|
4
|
-
/**
|
|
5
|
-
* Runs a generator body in which `yield* Result.safeUnwrap(...)` unwraps `Ok`
|
|
6
|
-
* values and short-circuits on the first `Err`, emulating Rust's `?` operator
|
|
7
|
-
* (early-return error propagation).
|
|
8
|
-
*
|
|
9
|
-
* The body must return a `Result`. If every unwrapped `Result` is `Ok`, the
|
|
10
|
-
* returned value is the body's `Result`; otherwise it is the first `Err`
|
|
11
|
-
* encountered, and the rest of the body never runs — though the generator is
|
|
12
|
-
* closed rather than dropped, so `finally` blocks and `using` disposals
|
|
13
|
-
* pending in the body still run. An exception thrown by the body is not
|
|
14
|
-
* converted to an `Err`: it propagates out of `safeTry` (as a rejected
|
|
15
|
-
* `Promise` for an async body). Use {@link Result.fromThrowable} for that.
|
|
16
|
-
*
|
|
17
|
-
* Passing an async generator (`async function*`) returns a
|
|
18
|
-
* `Promise<Result<...>>` instead, so `await` can be used inside the body.
|
|
19
|
-
* Note that `yield*` inside an `async function*` awaits what it receives, so
|
|
20
|
-
* unwrapping an `Ok` whose value is itself a `Promise` yields the awaited
|
|
21
|
-
* value there while the static type still says `Promise<...>`; keep promises
|
|
22
|
-
* out of the `Ok` side of a `Result` unwrapped in an async body.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
*
|
|
26
|
-
* ```ts
|
|
27
|
-
* const parseTwo = (a: string, b: string): Result<number, Error> =>
|
|
28
|
-
* Result.safeTry(function* () {
|
|
29
|
-
* const x = yield* Result.safeUnwrap(Num.safeParseInt(a));
|
|
30
|
-
*
|
|
31
|
-
* const y = yield* Result.safeUnwrap(Num.safeParseInt(b));
|
|
32
|
-
*
|
|
33
|
-
* return Result.ok(x + y);
|
|
34
|
-
* });
|
|
35
|
-
*
|
|
36
|
-
* assert.deepStrictEqual(parseTwo('1', '2'), Result.ok(3));
|
|
37
|
-
*
|
|
38
|
-
* assert.isTrue(Result.isErr(parseTwo('1', 'not a number')));
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* @template Y The union of `Err` types unwrapped via
|
|
42
|
-
* {@link Result.safeUnwrap} (`never` if nothing is unwrapped).
|
|
43
|
-
* @template R2 The `Result` type returned by the body.
|
|
44
|
-
* @param body A generator function whose `yield*` expressions delegate to
|
|
45
|
-
* {@link Result.safeUnwrap} and whose return value is a `Result`.
|
|
46
|
-
* @returns The body's `Result`, or the first `Err` short-circuited out of it
|
|
47
|
-
* (wrapped in a `Promise` for an async generator body).
|
|
48
|
-
*/
|
|
49
|
-
export declare function safeTry<Y extends Err<unknown>, R2 extends UnknownResult>(body: () => Generator<Y, R2>): Result<UnwrapOk<R2>, UnwrapErr<R2> | UnwrapErr<Y>>;
|
|
50
|
-
export declare function safeTry<Y extends Err<unknown>, R2 extends UnknownResult>(body: () => AsyncGenerator<Y, R2>): Promise<Result<UnwrapOk<R2>, UnwrapErr<R2> | UnwrapErr<Y>>>;
|
|
51
|
-
//# sourceMappingURL=result-safe-try.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-safe-try.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-safe-try.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAChE,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,SAAS,aAAa,EACtE,IAAI,EAAE,MAAM,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,GAC3B,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AAEtD,wBAAgB,OAAO,CAAC,CAAC,SAAS,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,SAAS,aAAa,EACtE,IAAI,EAAE,MAAM,cAAc,CAAC,CAAC,EAAE,EAAE,CAAC,GAChC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { hasKey, isRecord } from '../../../guard/index.mjs';
|
|
2
|
-
export function safeTry(body) {
|
|
3
|
-
const generator = body();
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const step = generator.next();
|
|
8
|
-
if (isSyncStep(step)) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (step.done !== true && isSyncGenerator(generator, step)) {
|
|
14
|
-
generator.return(step.value);
|
|
15
|
-
}
|
|
16
|
-
return step.value;
|
|
17
|
-
}
|
|
18
|
-
return step.then(async (asyncStep) => {
|
|
19
|
-
if (asyncStep.done !== true) {
|
|
20
|
-
await generator.return(asyncStep.value);
|
|
21
|
-
}
|
|
22
|
-
return asyncStep.value;
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const isSyncStep = (value) => isRecord(value) && hasKey(value, 'done');
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const isSyncGenerator = (_generator, step) => isSyncStep(step);
|
|
35
|
-
//# sourceMappingURL=result-safe-try.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-safe-try.mjs","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-safe-try.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AA0D5D,MAAM,UAAU,OAAO,CACrB,IAEmD;IAEnD,MAAM,SAAS,GAAG,IAAI,EAAE,CAAC;IAEzB,qEAAqE;IACrE,wEAAwE;IACxE,0DAA0D;IAC1D,MAAM,IAAI,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;IAE9B,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACrB,qEAAqE;QACrE,oEAAoE;QACpE,wEAAwE;QACxE,yEAAyE;QACzE,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,IAAI,eAAe,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC;YAC3D,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC/B,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE;QACnC,IAAI,SAAS,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;YAC5B,MAAM,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC1C,CAAC;QAED,OAAO,SAAS,CAAC,KAAK,CAAC;IACzB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,4EAA4E;AAC5E,wEAAwE;AACxE,8EAA8E;AAC9E,OAAO;AACP,MAAM,UAAU,GAAG,CACjB,KAAc,EACyC,EAAE,CACzD,QAAQ,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAE3C,8EAA8E;AAC9E,wEAAwE;AACxE,6EAA6E;AAC7E,qBAAqB;AACrB,MAAM,eAAe,GAAG,CACtB,UAE2C,EAC3C,IAAa,EAC0C,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { type UnknownResult } from '../result.mjs';
|
|
2
|
-
import { type NarrowToErr, type UnwrapOk } from './types.mjs';
|
|
3
|
-
/**
|
|
4
|
-
* Unwraps a `Result` inside a {@link Result.safeTry} generator body via
|
|
5
|
-
* `yield*`, emulating Rust's `?` operator.
|
|
6
|
-
*
|
|
7
|
-
* If the `Result` is `Ok`, the `yield*` expression evaluates to the contained
|
|
8
|
-
* value and execution continues. If it is `Err`, the error is yielded to
|
|
9
|
-
* {@link Result.safeTry}, which returns it immediately — the rest of the
|
|
10
|
-
* generator body never runs.
|
|
11
|
-
*
|
|
12
|
-
* This generator must only be delegated to (`yield*`) inside a
|
|
13
|
-
* {@link Result.safeTry} body; resuming it after it has yielded an `Err`
|
|
14
|
-
* throws.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
*
|
|
18
|
-
* ```ts
|
|
19
|
-
* const result = Result.safeTry(function* () {
|
|
20
|
-
* const x = yield* Result.safeUnwrap(Result.ok(2));
|
|
21
|
-
*
|
|
22
|
-
* const y = yield* Result.safeUnwrap(Result.ok(3));
|
|
23
|
-
*
|
|
24
|
-
* return Result.ok(x + y);
|
|
25
|
-
* });
|
|
26
|
-
*
|
|
27
|
-
* assert.deepStrictEqual(result, Result.ok(5));
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* @template R The input `UnknownResult` type.
|
|
31
|
-
* @param result The `Result` to unwrap.
|
|
32
|
-
* @returns A generator that yields the `Err` (if any) and returns the `Ok`
|
|
33
|
-
* value.
|
|
34
|
-
*/
|
|
35
|
-
export declare function safeUnwrap<R extends UnknownResult>(result: R): Generator<NarrowToErr<R>, UnwrapOk<R>, unknown>;
|
|
36
|
-
//# sourceMappingURL=result-safe-unwrap.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-safe-unwrap.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-safe-unwrap.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAiB,UAAU,CAAC,CAAC,SAAS,aAAa,EACjD,MAAM,EAAE,CAAC,GACR,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAWjD"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { isErr } from './result-is-err.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
|
-
|
|
34
|
-
export function* safeUnwrap(result) {
|
|
35
|
-
if (isErr(result)) {
|
|
36
|
-
yield result;
|
|
37
|
-
throw new Error('`safeUnwrap()` generator was resumed after yielding an `Err`; it must only be used via `yield*` inside `safeTry()`');
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return result.value;
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=result-safe-unwrap.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-safe-unwrap.mjs","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-safe-unwrap.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAG5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,SAAS,CAAC,CAAC,UAAU,CACzB,MAAS;IAET,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;QAClB,MAAM,MAAM,CAAC;QAEb,MAAM,IAAI,KAAK,CACb,oHAAoH,CACrH,CAAC;IACJ,CAAC;IAED,oEAAoE;IACpE,OAAO,MAAM,CAAC,KAAoB,CAAC;AACrC,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { type Result, type UnknownResult } from '../result.mjs';
|
|
2
|
-
import { type UnwrapErr, type UnwrapOk } from './types.mjs';
|
|
3
|
-
/**
|
|
4
|
-
* Swaps the success and error values of a `Result`.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
*
|
|
8
|
-
* ```ts
|
|
9
|
-
* const okValue = Result.ok('value');
|
|
10
|
-
*
|
|
11
|
-
* const errValue = Result.err('error');
|
|
12
|
-
*
|
|
13
|
-
* assert.deepStrictEqual(Result.swap(okValue), Result.err('value'));
|
|
14
|
-
*
|
|
15
|
-
* assert.deepStrictEqual(Result.swap(errValue), Result.ok('error'));
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
* @template R The input `UnknownResult` type.
|
|
19
|
-
* @param result The `Result` to swap.
|
|
20
|
-
* @returns A new `Result` with success and error swapped.
|
|
21
|
-
*/
|
|
22
|
-
export declare const swap: <R extends UnknownResult>(result: R) => Result<UnwrapErr<R>, UnwrapOk<R>>;
|
|
23
|
-
//# sourceMappingURL=result-swap.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-swap.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-swap.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAKhE,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5D;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,SAAS,aAAa,UAClC,CAAC,KACR,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAEsC,CAAC"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { err } from './result-err.mjs';
|
|
2
|
-
import { isOk } from './result-is-ok.mjs';
|
|
3
|
-
import { ok } from './result-ok.mjs';
|
|
4
|
-
import { unwrapOk } from './result-unwrap-ok.mjs';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
export const swap = (result) =>
|
|
25
|
-
|
|
26
|
-
isOk(result) ? err(unwrapOk(result)) : ok(result.value);
|
|
27
|
-
//# sourceMappingURL=result-swap.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-swap.mjs","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-swap.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGlD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAClB,MAAS,EAC0B,EAAE;AACrC,oEAAoE;AACpE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,KAAqB,CAAC,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Optional } from '../../optional/index.mjs';
|
|
2
|
-
import { type UnknownResult } from '../result.mjs';
|
|
3
|
-
import { type UnwrapOk } from './types.mjs';
|
|
4
|
-
/**
|
|
5
|
-
* Converts a `Result` to an `Optional`.
|
|
6
|
-
*
|
|
7
|
-
* This conversion is useful when you want to discard error information and
|
|
8
|
-
* only care about whether an operation succeeded. The error information is
|
|
9
|
-
* lost in this conversion, so use it when error details are not needed.
|
|
10
|
-
*
|
|
11
|
-
* If the `Result` is `Ok`, returns `Some` with the value. If the `Result` is
|
|
12
|
-
* `Err`, returns `None`.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
*
|
|
16
|
-
* ```ts
|
|
17
|
-
* const okValue = Result.ok(7);
|
|
18
|
-
*
|
|
19
|
-
* const errValue = Result.err('fail');
|
|
20
|
-
*
|
|
21
|
-
* assert.deepStrictEqual(Result.toOptional(okValue), Optional.some(7));
|
|
22
|
-
*
|
|
23
|
-
* assert.deepStrictEqual(Result.toOptional(errValue), Optional.none);
|
|
24
|
-
* ```
|
|
25
|
-
*
|
|
26
|
-
* @template R The input `UnknownResult` type.
|
|
27
|
-
* @param result The `Result` to convert.
|
|
28
|
-
* @returns An `Optional<UnwrapOk<R>>` containing the success value or
|
|
29
|
-
* representing `None`.
|
|
30
|
-
*/
|
|
31
|
-
export declare const toOptional: <R extends UnknownResult>(result: R) => Optional<UnwrapOk<R>>;
|
|
32
|
-
//# sourceMappingURL=result-to-optional.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-to-optional.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-to-optional.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,SAAS,aAAa,UACxC,CAAC,KACR,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CACyC,CAAC"}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Optional } from '../../optional/index.mjs';
|
|
2
|
-
import { isOk } from './result-is-ok.mjs';
|
|
3
|
-
import { unwrapOk } from './result-unwrap-ok.mjs';
|
|
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
|
-
export const toOptional = (result) => isOk(result) ? Optional.some(unwrapOk(result)) : Optional.none;
|
|
32
|
-
//# sourceMappingURL=result-to-optional.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-to-optional.mjs","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-to-optional.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGlD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,MAAS,EACc,EAAE,CACzB,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { type UnknownResult } from '../result.mjs';
|
|
2
|
-
import { type UnwrapErr } from './types.mjs';
|
|
3
|
-
/**
|
|
4
|
-
* Unwraps a `Result`, returning the error value or a default value if it is
|
|
5
|
-
* `Result.Ok`.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
*
|
|
9
|
-
* ```ts
|
|
10
|
-
* const okResult = Result.ok('success');
|
|
11
|
-
*
|
|
12
|
-
* const errResult = Result.err('failure');
|
|
13
|
-
*
|
|
14
|
-
* assert.isTrue(Result.unwrapErrOr(okResult, 'default') === 'default');
|
|
15
|
-
*
|
|
16
|
-
* assert.isTrue(Result.unwrapErrOr(errResult, 'default') === 'failure');
|
|
17
|
-
*
|
|
18
|
-
* const unwrapError = Result.unwrapErrOr('fallback error');
|
|
19
|
-
*
|
|
20
|
-
* assert.isTrue(unwrapError(Result.err('boom')) === 'boom');
|
|
21
|
-
*
|
|
22
|
-
* assert.isTrue(unwrapError(Result.ok('no error')) === 'fallback error');
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* @template R The `UnknownResult` type to unwrap.
|
|
26
|
-
* @template D The type of the default value.
|
|
27
|
-
* @param result The `Result` to unwrap.
|
|
28
|
-
* @param defaultValue The value to return if `result` is `Result.Ok`.
|
|
29
|
-
* @returns The error value if `Result.Err`, otherwise `defaultValue`.
|
|
30
|
-
*/
|
|
31
|
-
export declare function unwrapErrOr<R extends UnknownResult, D>(result: R, defaultValue: D): D | UnwrapErr<R>;
|
|
32
|
-
export declare function unwrapErrOr<D>(defaultValue: D): <R extends UnknownResult>(result: R) => D | UnwrapErr<R>;
|
|
33
|
-
//# sourceMappingURL=result-unwrap-err-or.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-unwrap-err-or.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-unwrap-err-or.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,aAAa,EAAE,CAAC,EACpD,MAAM,EAAE,CAAC,EACT,YAAY,EAAE,CAAC,GACd,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAGpB,wBAAgB,WAAW,CAAC,CAAC,EAC3B,YAAY,EAAE,CAAC,GACd,CAAC,CAAC,SAAS,aAAa,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { unwrapErr } from './result-unwrap-err.mjs';
|
|
2
|
-
export function unwrapErrOr(...args) {
|
|
3
|
-
switch (args.length) {
|
|
4
|
-
case 2: {
|
|
5
|
-
|
|
6
|
-
const [result, defaultValue] = args;
|
|
7
|
-
return unwrapErrOrImpl(result, defaultValue);
|
|
8
|
-
}
|
|
9
|
-
case 1: {
|
|
10
|
-
|
|
11
|
-
const [defaultValue] = args;
|
|
12
|
-
return (result) => unwrapErrOrImpl(result, defaultValue);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
const unwrapErrOrImpl = (result, defaultValue) => unwrapErr(result) ?? defaultValue;
|
|
17
|
-
//# sourceMappingURL=result-unwrap-err-or.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-unwrap-err-or.mjs","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-unwrap-err-or.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAyCpD,MAAM,UAAU,WAAW,CACzB,GAAG,IAAwE;IAE3E,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,CAAC,EAAE,CAAC;YACP,2CAA2C;YAC3C,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,IAAI,CAAC;YAEpC,OAAO,eAAe,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QAC/C,CAAC;QAED,KAAK,CAAC,EAAE,CAAC;YACP,kBAAkB;YAClB,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;YAE5B,OAAO,CAAC,MAAS,EAAE,EAAE,CAAC,eAAe,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QAC9D,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,eAAe,GAAG,CACtB,MAAS,EACT,YAAe,EACG,EAAE,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,YAAY,CAAC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { type UnknownResult } from '../result.mjs';
|
|
2
|
-
import { type UnwrapErr, type UnwrapOk } from './types.mjs';
|
|
3
|
-
/**
|
|
4
|
-
* Unwraps a `Result`, returning the error value. Throws an error if the
|
|
5
|
-
* `Result` is `Result.Ok`.
|
|
6
|
-
*
|
|
7
|
-
* This function is used when you expect a Result to be an error and want to
|
|
8
|
-
* extract the error value. If the Result is unexpectedly Ok, it will throw an
|
|
9
|
-
* error with information about the unexpected success value.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
*
|
|
13
|
-
* ```ts
|
|
14
|
-
* const errResult = Result.err(new Error('broken'));
|
|
15
|
-
*
|
|
16
|
-
* const okResult = Result.ok('value');
|
|
17
|
-
*
|
|
18
|
-
* assert.isTrue(Result.unwrapErrThrow(errResult).message === 'broken');
|
|
19
|
-
*
|
|
20
|
-
* assert.throws(() => Result.unwrapErrThrow(okResult), /Expected Err/u);
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @template R The `UnknownResult` type to unwrap.
|
|
24
|
-
* @param result The `Result` to unwrap.
|
|
25
|
-
* @param toStr An optional function to convert the success value to a string
|
|
26
|
-
* for the error message when the Result is unexpectedly Ok. Defaults to
|
|
27
|
-
* `String`.
|
|
28
|
-
* @returns The error value if `Result.Err`.
|
|
29
|
-
* @throws {Error} Error with message "Expected Err but got Ok: {value}" if
|
|
30
|
-
* the `Result` is `Result.Ok`.
|
|
31
|
-
*/
|
|
32
|
-
export declare const unwrapErrThrow: <R extends UnknownResult>(result: R, toStr?: (v: UnwrapOk<R>) => string) => UnwrapErr<R>;
|
|
33
|
-
//# sourceMappingURL=result-unwrap-err-throw.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-unwrap-err-throw.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-unwrap-err-throw.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,cAAc,GAAI,CAAC,SAAS,aAAa,UAC5C,CAAC,UACF,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,MAAM,KAChC,SAAS,CAAC,CAAC,CAiBb,CAAC"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { unknownToString } from '../../../others/index.mjs';
|
|
2
|
-
import { match } from '../../match.mjs';
|
|
3
|
-
import { isErr } from './result-is-err.mjs';
|
|
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 unwrapErrThrow = (result, toStr = unknownToString) => {
|
|
34
|
-
if (isErr(result)) {
|
|
35
|
-
|
|
36
|
-
return result.value;
|
|
37
|
-
}
|
|
38
|
-
const variant = match(result.$$tag, {
|
|
39
|
-
'ts-data-forge::Result.ok': 'Ok',
|
|
40
|
-
'ts-data-forge::Result.err': 'Err',
|
|
41
|
-
});
|
|
42
|
-
throw new Error(`Expected Err but got ${variant}: ${toStr(
|
|
43
|
-
|
|
44
|
-
result.value)}`);
|
|
45
|
-
};
|
|
46
|
-
//# sourceMappingURL=result-unwrap-err-throw.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-unwrap-err-throw.mjs","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-unwrap-err-throw.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAExC,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAG5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,MAAS,EACT,KAAK,GAA+B,eAAe,EACrC,EAAE;IAChB,IAAI,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;QAClB,oEAAoE;QACpE,OAAO,MAAM,CAAC,KAAqB,CAAC;IACtC,CAAC;IAED,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE;QAClC,0BAA0B,EAAE,IAAI;QAChC,2BAA2B,EAAE,KAAK;KACnC,CAAC,CAAC;IAEH,MAAM,IAAI,KAAK,CACb,wBAAwB,OAAO,KAAK,KAAK;IACvC,oEAAoE;IACpE,MAAM,CAAC,KAAoB,CAC5B,EAAE,CACJ,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { type UnknownResult } from '../result.mjs';
|
|
2
|
-
import { type UnwrapErr } from './types.mjs';
|
|
3
|
-
/**
|
|
4
|
-
* Unwraps a `Result`, returning the error value or `undefined` if it is
|
|
5
|
-
* `Result.Ok`.
|
|
6
|
-
*
|
|
7
|
-
* This provides a safe way to extract error values from Results without
|
|
8
|
-
* throwing exceptions. Useful for error handling patterns where you want to
|
|
9
|
-
* check for specific error conditions.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
*
|
|
13
|
-
* ```ts
|
|
14
|
-
* const okResult = Result.ok('data');
|
|
15
|
-
*
|
|
16
|
-
* const errResult = Result.err('problem');
|
|
17
|
-
*
|
|
18
|
-
* // Result.unwrapErr returns undefined for Ok results
|
|
19
|
-
*
|
|
20
|
-
* // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
21
|
-
* assert.isTrue(Result.unwrapErr(okResult) === undefined);
|
|
22
|
-
*
|
|
23
|
-
* // Result.unwrapErr returns the error value for Err results
|
|
24
|
-
*
|
|
25
|
-
* assert.isTrue(Result.unwrapErr(errResult) === 'problem');
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @template R The `UnknownResult` type to unwrap.
|
|
29
|
-
* @param result The `Result` to unwrap.
|
|
30
|
-
* @returns The error value if `Result.Err`, otherwise `undefined`.
|
|
31
|
-
*/
|
|
32
|
-
export declare const unwrapErr: <R extends UnknownResult>(result: R) => UnwrapErr<R> | undefined;
|
|
33
|
-
//# sourceMappingURL=result-unwrap-err.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-unwrap-err.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-unwrap-err.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,SAAS,GAAI,CAAC,SAAS,aAAa,UACvC,CAAC,KACR,SAAS,CAAC,CAAC,CAAC,GAAG,SAE0C,CAAC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { isErr } from './result-is-err.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
|
-
export const unwrapErr = (result) =>
|
|
32
|
-
|
|
33
|
-
isErr(result) ? result.value : undefined;
|
|
34
|
-
//# sourceMappingURL=result-unwrap-err.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-unwrap-err.mjs","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-unwrap-err.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAG5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,MAAS,EACiB,EAAE;AAC5B,oEAAoE;AACpE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAE,MAAM,CAAC,KAAsB,CAAC,CAAC,CAAC,SAAS,CAAC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { type UnknownResult } from '../result.mjs';
|
|
2
|
-
import { type UnwrapOk } from './types.mjs';
|
|
3
|
-
/**
|
|
4
|
-
* Unwraps a `Result`, returning the success value or a default value if it is
|
|
5
|
-
* `Result.Err`.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
*
|
|
9
|
-
* ```ts
|
|
10
|
-
* const okValue = Result.ok(10);
|
|
11
|
-
*
|
|
12
|
-
* const errValue = Result.err('fail');
|
|
13
|
-
*
|
|
14
|
-
* assert.isTrue(Result.unwrapOkOr(okValue, 0) === 10);
|
|
15
|
-
*
|
|
16
|
-
* assert.isTrue(Result.unwrapOkOr(errValue, 0) === 0);
|
|
17
|
-
*
|
|
18
|
-
* const unwrapWithDefault = Result.unwrapOkOr(5);
|
|
19
|
-
*
|
|
20
|
-
* assert.isTrue(unwrapWithDefault(Result.ok(3)) === 3);
|
|
21
|
-
*
|
|
22
|
-
* assert.isTrue(unwrapWithDefault(Result.err('no data')) === 5);
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* @template R The `UnknownResult` type to unwrap.
|
|
26
|
-
* @template D The type of the default value.
|
|
27
|
-
* @param result The `Result` to unwrap.
|
|
28
|
-
* @param defaultValue The value to return if `result` is `Result.Err`.
|
|
29
|
-
* @returns The success value if `Result.Ok`, otherwise `defaultValue`.
|
|
30
|
-
*/
|
|
31
|
-
export declare function unwrapOkOr<R extends UnknownResult, D>(result: R, defaultValue: D): D | UnwrapOk<R>;
|
|
32
|
-
export declare function unwrapOkOr<D>(defaultValue: D): <R extends UnknownResult>(result: R) => D | UnwrapOk<R>;
|
|
33
|
-
//# sourceMappingURL=result-unwrap-ok-or.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-unwrap-ok-or.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-unwrap-ok-or.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,aAAa,EAAE,CAAC,EACnD,MAAM,EAAE,CAAC,EACT,YAAY,EAAE,CAAC,GACd,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;AAGnB,wBAAgB,UAAU,CAAC,CAAC,EAC1B,YAAY,EAAE,CAAC,GACd,CAAC,CAAC,SAAS,aAAa,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { unwrapOk } from './result-unwrap-ok.mjs';
|
|
2
|
-
export function unwrapOkOr(...args) {
|
|
3
|
-
switch (args.length) {
|
|
4
|
-
case 2: {
|
|
5
|
-
|
|
6
|
-
const [result, defaultValue] = args;
|
|
7
|
-
return unwrapOkOrImpl(result, defaultValue);
|
|
8
|
-
}
|
|
9
|
-
case 1: {
|
|
10
|
-
|
|
11
|
-
const [defaultValue] = args;
|
|
12
|
-
return (result) => unwrapOkOrImpl(result, defaultValue);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
const unwrapOkOrImpl = (result, defaultValue) => unwrapOk(result) ?? defaultValue;
|
|
17
|
-
//# sourceMappingURL=result-unwrap-ok-or.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-unwrap-ok-or.mjs","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-unwrap-ok-or.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAyClD,MAAM,UAAU,UAAU,CACxB,GAAG,IAAwE;IAE3E,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,CAAC,EAAE,CAAC;YACP,2CAA2C;YAC3C,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,IAAI,CAAC;YAEpC,OAAO,cAAc,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QAC9C,CAAC;QAED,KAAK,CAAC,EAAE,CAAC;YACP,kBAAkB;YAClB,MAAM,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC;YAE5B,OAAO,CAAC,MAAS,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;QAC7D,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,cAAc,GAAG,CACrB,MAAS,EACT,YAAe,EACE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,YAAY,CAAC"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { type Ok } from '../../../types.mjs';
|
|
2
|
-
import { type UnknownResult } from '../result.mjs';
|
|
3
|
-
import { type UnwrapOk } from './types.mjs';
|
|
4
|
-
/**
|
|
5
|
-
* Safely unwraps the success value, returning `undefined` for failures.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
*
|
|
9
|
-
* ```ts
|
|
10
|
-
* const okResult = Result.ok(42);
|
|
11
|
-
*
|
|
12
|
-
* const errResult = Result.err('oops');
|
|
13
|
-
*
|
|
14
|
-
* // Result.unwrapOk returns the value for Ok results
|
|
15
|
-
*
|
|
16
|
-
* assert.isTrue(Result.unwrapOk(okResult) === 42);
|
|
17
|
-
*
|
|
18
|
-
* // Result.unwrapOk returns undefined for Err results
|
|
19
|
-
*
|
|
20
|
-
* // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
21
|
-
* assert.isTrue(Result.unwrapOk(errResult) === undefined);
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
export declare function unwrapOk<R extends Ok<unknown>>(result: R): UnwrapOk<R>;
|
|
25
|
-
export declare function unwrapOk<R extends UnknownResult>(result: R): UnwrapOk<R> | undefined;
|
|
26
|
-
//# sourceMappingURL=result-unwrap-ok.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-unwrap-ok.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-unwrap-ok.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;AAExE,wBAAgB,QAAQ,CAAC,CAAC,SAAS,aAAa,EAC9C,MAAM,EAAE,CAAC,GACR,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC"}
|