ts-data-forge 14.6.4 → 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/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 +5 -5
- 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,102 +0,0 @@
|
|
|
1
|
-
import { Optional, type UnknownOptional } from './optional/index.mjs';
|
|
2
|
-
/**
|
|
3
|
-
* Creates a new pipe object that allows for chaining operations on a value.
|
|
4
|
-
*
|
|
5
|
-
* This function provides a fluent interface for applying transformations to
|
|
6
|
-
* values, with intelligent method selection based on the input type:
|
|
7
|
-
*
|
|
8
|
-
* - For `Optional` values: Provides `mapOptional` for safe Optional
|
|
9
|
-
* transformations
|
|
10
|
-
* - For other values: Provides `mapNullable` for null-safe transformations
|
|
11
|
-
* - All types get the basic `map` method for general transformations
|
|
12
|
-
*
|
|
13
|
-
* The pipe maintains type safety throughout the chain, automatically selecting
|
|
14
|
-
* the appropriate overload based on the current value type.
|
|
15
|
-
*
|
|
16
|
-
* @template A The type of the initial value to wrap in a pipe.
|
|
17
|
-
* @param a The initial value to wrap in a pipe.
|
|
18
|
-
* @returns A pipe object with chaining methods appropriate for the value type.
|
|
19
|
-
*/
|
|
20
|
-
export declare const pipe: <const A>(a: A) => Pipe<A>;
|
|
21
|
-
export type Pipe<A> = PipeBase<A> & PipeMapNullable<A> & ([A] extends [UnknownOptional] ? PipeMapOptional<A> : unknown);
|
|
22
|
-
type PipeBase<A> = Readonly<{
|
|
23
|
-
/** The current value being piped. */
|
|
24
|
-
value: A;
|
|
25
|
-
/**
|
|
26
|
-
* Maps the current value to a new value using the provided function.
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
*
|
|
30
|
-
* ```ts
|
|
31
|
-
* const result = pipe(2)
|
|
32
|
-
* .map((value) => value * 3)
|
|
33
|
-
* .map((value) => `value: ${value}`);
|
|
34
|
-
*
|
|
35
|
-
* assert.deepStrictEqual(result.value, 'value: 6');
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
* @template B The type of the new value.
|
|
39
|
-
* @param fn Function to transform the current value.
|
|
40
|
-
* @returns A new pipe containing the transformed value.
|
|
41
|
-
*/
|
|
42
|
-
map: <B>(fn: (a: A) => B) => Pipe<B>;
|
|
43
|
-
}>;
|
|
44
|
-
type PipeMapNullable<A> = Readonly<{
|
|
45
|
-
/**
|
|
46
|
-
* Maps the current value only if it's not null or undefined. If the current
|
|
47
|
-
* value is null/undefined, the transformation is skipped and undefined is
|
|
48
|
-
* propagated through the pipe.
|
|
49
|
-
*
|
|
50
|
-
* @example
|
|
51
|
-
*
|
|
52
|
-
* ```ts
|
|
53
|
-
* const result = pipe<string | undefined>('hello')
|
|
54
|
-
* .mapNullable((value) => value.toUpperCase())
|
|
55
|
-
* .mapNullable((value) => value.slice(0, 2));
|
|
56
|
-
*
|
|
57
|
-
* assert.deepStrictEqual(result.value, 'HE');
|
|
58
|
-
*
|
|
59
|
-
* const empty = pipe<string | undefined>(undefined).mapNullable((value) =>
|
|
60
|
-
* value.toUpperCase(),
|
|
61
|
-
* );
|
|
62
|
-
*
|
|
63
|
-
* assert.isTrue(empty.value === undefined);
|
|
64
|
-
* ```
|
|
65
|
-
*
|
|
66
|
-
* @template B The type of the transformed value.
|
|
67
|
-
* @param fn Function to transform the non-null value.
|
|
68
|
-
* @returns A new pipe containing the transformed value or undefined.
|
|
69
|
-
*/
|
|
70
|
-
mapNullable: <B>(fn: (a: NonNullable<A>) => B) => Pipe<B | undefined>;
|
|
71
|
-
}>;
|
|
72
|
-
type PipeMapOptional<A extends UnknownOptional> = Readonly<{
|
|
73
|
-
/**
|
|
74
|
-
* Maps the value inside an Optional using Optional.map semantics. If the
|
|
75
|
-
* Optional is None, the transformation is skipped and None is propagated.
|
|
76
|
-
* If the Optional is Some, the transformation is applied to the inner
|
|
77
|
-
* value.
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
*
|
|
81
|
-
* ```ts
|
|
82
|
-
* const result = pipe(Optional.some(10))
|
|
83
|
-
* .mapOptional((value) => value * 2)
|
|
84
|
-
* .mapOptional((value) => value + 5);
|
|
85
|
-
*
|
|
86
|
-
* assert.deepStrictEqual(result.value, Optional.some(25));
|
|
87
|
-
*
|
|
88
|
-
* const empty = pipe(Optional.none as Optional<number>).mapOptional(
|
|
89
|
-
* (value) => value * 2,
|
|
90
|
-
* );
|
|
91
|
-
*
|
|
92
|
-
* assert.isTrue(Optional.isNone(empty.value));
|
|
93
|
-
* ```
|
|
94
|
-
*
|
|
95
|
-
* @template B The type of the transformed inner value.
|
|
96
|
-
* @param fn Function to transform the inner value of the Optional.
|
|
97
|
-
* @returns A new pipe containing an Optional with the transformed value.
|
|
98
|
-
*/
|
|
99
|
-
mapOptional: <B>(fn: (a: Optional.Unwrap<A>) => B) => Pipe<Optional<B>>;
|
|
100
|
-
}>;
|
|
101
|
-
export {};
|
|
102
|
-
//# sourceMappingURL=pipe.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pipe.d.mts","sourceRoot":"","sources":["../../src/functional/pipe.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEtE;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,IAAI,GAAI,KAAK,CAAC,CAAC,KAAM,CAAC,KAAG,IAAI,CAAC,CAAC,CAYI,CAAC;AAkBjD,MAAM,MAAM,IAAI,CAAC,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,GAC/B,eAAe,CAAC,CAAC,CAAC,GAClB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,eAAe,CAAC,GAAG,eAAe,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC;AAgCjE,KAAK,QAAQ,CAAC,CAAC,IAAI,QAAQ,CAAC;IAC1B,qCAAqC;IACrC,KAAK,EAAE,CAAC,CAAC;IAET;;;;;;;;;;;;;;;;OAgBG;IACH,GAAG,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC;CACtC,CAAC,CAAC;AAEH,KAAK,eAAe,CAAC,CAAC,IAAI,QAAQ,CAAC;IACjC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;CACvE,CAAC,CAAC;AAEH,KAAK,eAAe,CAAC,CAAC,SAAS,eAAe,IAAI,QAAQ,CAAC;IACzD;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;CACzE,CAAC,CAAC"}
|
package/dist/functional/pipe.mjs
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
import { Optional } from './optional/index.mjs';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export const pipe = (a) =>
|
|
22
|
-
|
|
23
|
-
({
|
|
24
|
-
value: a,
|
|
25
|
-
map: (fn) => pipe(fn(a)),
|
|
26
|
-
mapNullable: (fn) => pipe(a == null ? undefined : fn(a)),
|
|
27
|
-
...(Optional.isOptional(a)
|
|
28
|
-
? {
|
|
29
|
-
mapOptional: (fn) => pipe(Optional.map(a, fn)),
|
|
30
|
-
}
|
|
31
|
-
: {}),
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
//# sourceMappingURL=pipe.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pipe.mjs","sourceRoot":"","sources":["../../src/functional/pipe.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAwB,MAAM,sBAAsB,CAAC;AAEtE;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAAW,CAAI,EAAW,EAAE;AAC9C,oEAAoE;AACpE,CAAC;IACC,KAAK,EAAE,CAAC;IACR,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACxB,WAAW,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAExD,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC;QACxB,CAAC,CAAC;YACE,WAAW,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;SAC/C;QACH,CAAC,CAAC,EAAE,CAAC;CACR,CAA6C,CAAC;AAsBjD,6DAA6D;AAC7D,gFAAgF;AAChF,sCAAsC;AACtC,qEAAqE;AACrE,+DAA+D;AAC/D,yDAAyD;AAEzD,UAAU,CAAoC,IAAI,CAAC,CAAC;AAEpD,UAAU,CAAgC,IAAI,CAAC,CAAC;AAEhD,UAAU,CACR,GAAG,CACJ,CAAC;AAEF,UAAU,CAGR,GAAG,CAAC,CAAC;AAEP,UAAU,CAGR,GAAG,CAAC,CAAC;AAEP,UAAU,CAGR,GAAG,CAAC,CAAC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export * from './result-err.mjs';
|
|
2
|
-
export * from './result-expect-to-be.mjs';
|
|
3
|
-
export * from './result-flat-map.mjs';
|
|
4
|
-
export * from './result-fold.mjs';
|
|
5
|
-
export * from './result-from-optional.mjs';
|
|
6
|
-
export * from './result-from-promise.mjs';
|
|
7
|
-
export * from './result-from-throwable.mjs';
|
|
8
|
-
export * from './result-is-err.mjs';
|
|
9
|
-
export * from './result-is-ok.mjs';
|
|
10
|
-
export * from './result-is-result.mjs';
|
|
11
|
-
export * from './result-map-err.mjs';
|
|
12
|
-
export * from './result-map.mjs';
|
|
13
|
-
export * from './result-match.mjs';
|
|
14
|
-
export * from './result-ok.mjs';
|
|
15
|
-
export * from './result-or-else.mjs';
|
|
16
|
-
export * from './result-safe-try.mjs';
|
|
17
|
-
export * from './result-safe-unwrap.mjs';
|
|
18
|
-
export * from './result-swap.mjs';
|
|
19
|
-
export * from './result-to-optional.mjs';
|
|
20
|
-
export * from './result-unwrap-err-or.mjs';
|
|
21
|
-
export * from './result-unwrap-err-throw.mjs';
|
|
22
|
-
export * from './result-unwrap-err.mjs';
|
|
23
|
-
export * from './result-unwrap-ok-or.mjs';
|
|
24
|
-
export * from './result-unwrap-ok.mjs';
|
|
25
|
-
export * from './result-unwrap-throw.mjs';
|
|
26
|
-
export * from './result-zip.mjs';
|
|
27
|
-
export * from './types.mjs';
|
|
28
|
-
//# sourceMappingURL=index.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/index.mts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export * from './result-err.mjs';
|
|
2
|
-
export * from './result-expect-to-be.mjs';
|
|
3
|
-
export * from './result-flat-map.mjs';
|
|
4
|
-
export * from './result-fold.mjs';
|
|
5
|
-
export * from './result-from-optional.mjs';
|
|
6
|
-
export * from './result-from-promise.mjs';
|
|
7
|
-
export * from './result-from-throwable.mjs';
|
|
8
|
-
export * from './result-is-err.mjs';
|
|
9
|
-
export * from './result-is-ok.mjs';
|
|
10
|
-
export * from './result-is-result.mjs';
|
|
11
|
-
export * from './result-map-err.mjs';
|
|
12
|
-
export * from './result-map.mjs';
|
|
13
|
-
export * from './result-match.mjs';
|
|
14
|
-
export * from './result-ok.mjs';
|
|
15
|
-
export * from './result-or-else.mjs';
|
|
16
|
-
export * from './result-safe-try.mjs';
|
|
17
|
-
export * from './result-safe-unwrap.mjs';
|
|
18
|
-
export * from './result-swap.mjs';
|
|
19
|
-
export * from './result-to-optional.mjs';
|
|
20
|
-
export * from './result-unwrap-err-or.mjs';
|
|
21
|
-
export * from './result-unwrap-err-throw.mjs';
|
|
22
|
-
export * from './result-unwrap-err.mjs';
|
|
23
|
-
export * from './result-unwrap-ok-or.mjs';
|
|
24
|
-
export * from './result-unwrap-ok.mjs';
|
|
25
|
-
export * from './result-unwrap-throw.mjs';
|
|
26
|
-
export * from './result-zip.mjs';
|
|
27
|
-
export * from './types.mjs';
|
|
28
|
-
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../../src/functional/result/impl/index.mts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,qBAAqB,CAAC;AACpC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC"}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { type Err } from '../../../types.mjs';
|
|
2
|
-
/**
|
|
3
|
-
* Creates a `Result.Err` containing the given error value.
|
|
4
|
-
*
|
|
5
|
-
* Use this constructor when an operation fails and you want to wrap the error
|
|
6
|
-
* information in a Result type for consistent error handling.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
*
|
|
10
|
-
* ```ts
|
|
11
|
-
* const success = Result.ok({ id: 1 });
|
|
12
|
-
*
|
|
13
|
-
* const failure = Result.err(new Error('missing data'));
|
|
14
|
-
*
|
|
15
|
-
* assert.deepStrictEqual(success, {
|
|
16
|
-
* $$tag: 'ts-data-forge::Result.ok',
|
|
17
|
-
* value: { id: 1 },
|
|
18
|
-
* });
|
|
19
|
-
*
|
|
20
|
-
* assert.isTrue(Result.isErr(failure));
|
|
21
|
-
* ```
|
|
22
|
-
*
|
|
23
|
-
* @template E The type of the error value.
|
|
24
|
-
* @param value The error value.
|
|
25
|
-
* @returns A `Result.Err<E>` containing the value.
|
|
26
|
-
*/
|
|
27
|
-
export declare const err: <const E>(value: E) => Err<E>;
|
|
28
|
-
//# sourceMappingURL=result-err.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-err.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-err.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAG9C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,GAAG,GAAI,KAAK,CAAC,CAAC,SAAU,CAAC,KAAG,GAAG,CAAC,CAAC,CAIjC,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { ErrTypeTagName } from './tag.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
|
-
export const err = (value) => ({
|
|
28
|
-
$$tag: ErrTypeTagName,
|
|
29
|
-
value,
|
|
30
|
-
});
|
|
31
|
-
//# sourceMappingURL=result-err.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-err.mjs","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-err.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3C;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,CAAW,KAAQ,EAAU,EAAE,CAChD,CAAC;IACC,KAAK,EAAE,cAAc;IACrB,KAAK;CACN,CAAU,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 throwing an error with
|
|
5
|
-
* the provided message.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
*
|
|
9
|
-
* ```ts
|
|
10
|
-
* const okValue = Result.ok('data');
|
|
11
|
-
*
|
|
12
|
-
* assert.isTrue(Result.expectToBe(okValue, 'should have value') === 'data');
|
|
13
|
-
*
|
|
14
|
-
* const expectResult = Result.expectToBe('missing result');
|
|
15
|
-
*
|
|
16
|
-
* const throwTest = (): void => {
|
|
17
|
-
* expectResult(Result.err('boom'));
|
|
18
|
-
* };
|
|
19
|
-
*
|
|
20
|
-
* assert.throws(throwTest, /missing result/u);
|
|
21
|
-
*
|
|
22
|
-
* assert.isTrue(expectResult(Result.ok('value')) === 'value');
|
|
23
|
-
* ```
|
|
24
|
-
*
|
|
25
|
-
* @template R The `UnknownResult` type to unwrap.
|
|
26
|
-
* @param result The `Result` to unwrap.
|
|
27
|
-
* @param message The error message to throw if the `Result` is `Result.Err`.
|
|
28
|
-
* @returns The success value if `Result.Ok`.
|
|
29
|
-
* @throws Error with the provided message if the `Result` is `Result.Err`.
|
|
30
|
-
*/
|
|
31
|
-
export declare function expectToBe<R extends UnknownResult>(result: R, message: string): UnwrapOk<R>;
|
|
32
|
-
export declare function expectToBe(message: string): <R extends UnknownResult>(result: R) => UnwrapOk<R>;
|
|
33
|
-
//# sourceMappingURL=result-expect-to-be.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-expect-to-be.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-expect-to-be.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,aAAa,EAChD,MAAM,EAAE,CAAC,EACT,OAAO,EAAE,MAAM,GACd,QAAQ,CAAC,CAAC,CAAC,CAAC;AAGf,wBAAgB,UAAU,CACxB,OAAO,EAAE,MAAM,GACd,CAAC,CAAC,SAAS,aAAa,EAAE,MAAM,EAAE,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { isOk } from './result-is-ok.mjs';
|
|
2
|
-
import { unwrapOk } from './result-unwrap-ok.mjs';
|
|
3
|
-
export function expectToBe(...args) {
|
|
4
|
-
switch (args.length) {
|
|
5
|
-
case 2: {
|
|
6
|
-
|
|
7
|
-
const [result, message] = args;
|
|
8
|
-
return expectToBeImpl(result, message);
|
|
9
|
-
}
|
|
10
|
-
case 1: {
|
|
11
|
-
|
|
12
|
-
const [message] = args;
|
|
13
|
-
return (result) => expectToBeImpl(result, message);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
const expectToBeImpl = (result, message) => {
|
|
18
|
-
if (isOk(result)) {
|
|
19
|
-
return unwrapOk(result);
|
|
20
|
-
}
|
|
21
|
-
throw new Error(message);
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=result-expect-to-be.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-expect-to-be.mjs","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-expect-to-be.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAC1C,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,OAAO,CAAC,GAAG,IAAI,CAAC;YAE/B,OAAO,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACzC,CAAC;QAED,KAAK,CAAC,EAAE,CAAC;YACP,6CAA6C;YAC7C,MAAM,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;YAEvB,OAAO,CAAC,MAAS,EAAe,EAAE,CAAC,cAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACrE,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,cAAc,GAAG,CACrB,MAAS,EACT,OAAe,EACF,EAAE;IACf,IAAI,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QACjB,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;AAC3B,CAAC,CAAC"}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { type Result, type UnknownResult } from '../result.mjs';
|
|
2
|
-
import { type UnwrapErr, type UnwrapOk } from './types.mjs';
|
|
3
|
-
/**
|
|
4
|
-
* Applies a function that returns a `Result` to the success value of a
|
|
5
|
-
* `Result`. If the input is `Err`, returns the original `Err`. This is the
|
|
6
|
-
* monadic bind operation for `Result`.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
*
|
|
10
|
-
* ```ts
|
|
11
|
-
* const parseNumber = (input: string): Result<number, string> => {
|
|
12
|
-
* const num = Num.safeParseInt(input);
|
|
13
|
-
*
|
|
14
|
-
* return Result.mapErr(num, () => 'not a number');
|
|
15
|
-
* };
|
|
16
|
-
*
|
|
17
|
-
* const parsed = Result.flatMap(Result.ok('42'), parseNumber);
|
|
18
|
-
*
|
|
19
|
-
* const failure = Result.flatMap(Result.ok('abc'), parseNumber);
|
|
20
|
-
*
|
|
21
|
-
* const passthrough = Result.flatMap(Result.err('fail'), parseNumber);
|
|
22
|
-
*
|
|
23
|
-
* assert.deepStrictEqual(parsed, Result.ok(42));
|
|
24
|
-
*
|
|
25
|
-
* assert.deepStrictEqual(failure, Result.err('not a number'));
|
|
26
|
-
*
|
|
27
|
-
* assert.deepStrictEqual(passthrough, Result.err('fail'));
|
|
28
|
-
*
|
|
29
|
-
* const parseThenDouble = Result.flatMap((input: string) =>
|
|
30
|
-
* Result.map(parseNumber(input), (value) => value * 2),
|
|
31
|
-
* );
|
|
32
|
-
*
|
|
33
|
-
* assert.deepStrictEqual(parseThenDouble(Result.ok('10')), Result.ok(20));
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* @template R The input `UnknownResult` type.
|
|
37
|
-
* @template S2 The success type of the `Result` returned by the function.
|
|
38
|
-
* @template E2 The error type of the `Result` returned by the function.
|
|
39
|
-
* @param result The `Result` to flat map.
|
|
40
|
-
* @param flatMapFn The function to apply that returns a `Result`.
|
|
41
|
-
* @returns The result of applying the function, or the original `Err`.
|
|
42
|
-
*/
|
|
43
|
-
export declare function flatMap<R extends UnknownResult, S2, E2>(result: R, flatMapFn: (value: UnwrapOk<R>) => Result<S2, E2>): Result<S2, E2 | UnwrapErr<R>>;
|
|
44
|
-
export declare function flatMap<S, S2, E2>(flatMapFn: (value: S) => Result<S2, E2>): <E>(result: Result<S, E>) => Result<S2, E | E2>;
|
|
45
|
-
//# sourceMappingURL=result-flat-map.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-flat-map.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-flat-map.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAEhE,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,aAAa,EAAE,EAAE,EAAE,EAAE,EACrD,MAAM,EAAE,CAAC,EACT,SAAS,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,GAChD,MAAM,CAAC,EAAE,EAAE,EAAE,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AAGjC,wBAAgB,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAC/B,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,GACtC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { isErr } from './result-is-err.mjs';
|
|
2
|
-
export function flatMap(...args) {
|
|
3
|
-
switch (args.length) {
|
|
4
|
-
case 2: {
|
|
5
|
-
|
|
6
|
-
const [result, flatMapFn] = args;
|
|
7
|
-
return flatMapImpl(result, flatMapFn);
|
|
8
|
-
}
|
|
9
|
-
case 1: {
|
|
10
|
-
|
|
11
|
-
const [flatMapFn] = args;
|
|
12
|
-
return (result) => flatMapImpl(result, flatMapFn);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
const flatMapImpl = (result, flatMapFn) => isErr(result)
|
|
17
|
-
?
|
|
18
|
-
result
|
|
19
|
-
:
|
|
20
|
-
flatMapFn(result.value);
|
|
21
|
-
//# sourceMappingURL=result-flat-map.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-flat-map.mjs","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-flat-map.mts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAqD5C,MAAM,UAAU,OAAO,CACrB,GAAG,IAE6D;IAIhE,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,CAAC,EAAE,CAAC;YACP,2CAA2C;YAC3C,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI,CAAC;YAEjC,OAAO,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QACxC,CAAC;QAED,KAAK,CAAC,EAAE,CAAC;YACP,kBAAkB;YAClB,MAAM,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC;YAEzB,OAAO,CAAC,MAAS,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,WAAW,GAAG,CAClB,MAAS,EACT,SAAiD,EAClB,EAAE,CACjC,KAAK,CAAC,MAAM,CAAC;IACX,CAAC,CAAC,oEAAoE;QACnE,MAA4B;IAC/B,CAAC,CAAC,oEAAoE;QACpE,SAAS,CAAC,MAAM,CAAC,KAAoB,CAAC,CAAC"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { type Result, type UnknownResult } from '../result.mjs';
|
|
2
|
-
import { type UnwrapErr, type UnwrapOk } from './types.mjs';
|
|
3
|
-
/**
|
|
4
|
-
* Applies one of two functions depending on whether the `Result` is `Ok` or
|
|
5
|
-
* `Err`.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
*
|
|
9
|
-
* ```ts
|
|
10
|
-
* const okValue = Result.ok(2);
|
|
11
|
-
*
|
|
12
|
-
* const errValue = Result.err('bad');
|
|
13
|
-
*
|
|
14
|
-
* const foldedOk = Result.fold(
|
|
15
|
-
* okValue,
|
|
16
|
-
* (value) => value * 2,
|
|
17
|
-
* (error) => error,
|
|
18
|
-
* );
|
|
19
|
-
*
|
|
20
|
-
* const foldedErr = Result.fold(
|
|
21
|
-
* errValue,
|
|
22
|
-
* (value: number) => value * 2,
|
|
23
|
-
* (error) => error.toUpperCase(),
|
|
24
|
-
* );
|
|
25
|
-
*
|
|
26
|
-
* assert.deepStrictEqual(foldedOk, Result.ok(4));
|
|
27
|
-
*
|
|
28
|
-
* assert.deepStrictEqual(foldedErr, Result.err('BAD'));
|
|
29
|
-
*
|
|
30
|
-
* const foldNumbers = Result.fold(
|
|
31
|
-
* (value: number) => value * 3,
|
|
32
|
-
* (error: string) => error.length,
|
|
33
|
-
* );
|
|
34
|
-
*
|
|
35
|
-
* assert.deepStrictEqual(foldNumbers(Result.ok(3)), Result.ok(9));
|
|
36
|
-
*
|
|
37
|
-
* assert.deepStrictEqual(foldNumbers(Result.err('oops')), Result.err(4));
|
|
38
|
-
* ```
|
|
39
|
-
*
|
|
40
|
-
* @template R The input `UnknownResult` type.
|
|
41
|
-
* @template S2 The type of the success value returned by `mapFn`.
|
|
42
|
-
* @template E2 The type of the error value returned by `mapErrFn`.
|
|
43
|
-
* @param result The `Result` to fold.
|
|
44
|
-
* @param mapFn The function to apply if `result` is `Ok`.
|
|
45
|
-
* @param mapErrFn The function to apply if `result` is `Err`.
|
|
46
|
-
* @returns A new `Result<S2, E2>` based on the applied function.
|
|
47
|
-
*/
|
|
48
|
-
export declare function fold<R extends UnknownResult, S2, E2>(result: R, mapFn: (value: UnwrapOk<R>) => S2, mapErrFn: (error: UnwrapErr<R>) => E2): Result<S2, E2>;
|
|
49
|
-
export declare function fold<S, E, S2, E2>(mapFn: (value: S) => S2, mapErrFn: (error: E) => E2): (result: Result<S, E>) => Result<S2, E2>;
|
|
50
|
-
//# sourceMappingURL=result-fold.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-fold.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-fold.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AAIhE,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,aAAa,EAAE,EAAE,EAAE,EAAE,EAClD,MAAM,EAAE,CAAC,EACT,KAAK,EAAE,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,EAAE,EACjC,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,KAAK,EAAE,GACpC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAGlB,wBAAgB,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAC/B,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,EACvB,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE,GACzB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC"}
|
|
@@ -1,23 +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
|
-
export function fold(...args) {
|
|
5
|
-
switch (args.length) {
|
|
6
|
-
case 3: {
|
|
7
|
-
|
|
8
|
-
const [result, mapFn, mapErrFn] = args;
|
|
9
|
-
return foldImpl(result, mapFn, mapErrFn);
|
|
10
|
-
}
|
|
11
|
-
case 2: {
|
|
12
|
-
|
|
13
|
-
const [mapFn, mapErrFn] = args;
|
|
14
|
-
return (result) => foldImpl(result, mapFn, mapErrFn);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
const foldImpl = (result, mapFn, mapErrFn) => isOk(result)
|
|
19
|
-
?
|
|
20
|
-
ok(mapFn(result.value))
|
|
21
|
-
:
|
|
22
|
-
err(mapErrFn(result.value));
|
|
23
|
-
//# sourceMappingURL=result-fold.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-fold.mjs","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-fold.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;AA4DrC,MAAM,UAAU,IAAI,CAClB,GAAG,IASE;IAEL,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,CAAC,EAAE,CAAC;YACP,2CAA2C;YAC3C,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC;YAEvC,OAAO,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC3C,CAAC;QAED,KAAK,CAAC,EAAE,CAAC;YACP,kBAAkB;YAClB,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAI,CAAC;YAE/B,OAAO,CAAC,MAAS,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QAC1D,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,QAAQ,GAAG,CACf,MAAS,EACT,KAAiC,EACjC,QAAqC,EACrB,EAAE,CAClB,IAAI,CAAC,MAAM,CAAC;IACV,CAAC,CAAC,oEAAoE;QACpE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,KAAoB,CAAC,CAAC;IACxC,CAAC,CAAC,oEAAoE;QACpE,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAqB,CAAC,CAAC,CAAC"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Optional, type UnknownOptional } from '../../optional/index.mjs';
|
|
2
|
-
import { type Result } from '../result.mjs';
|
|
3
|
-
/**
|
|
4
|
-
* Converts an {@link Optional} to a `Result` (the inverse of
|
|
5
|
-
* {@link Result.toOptional}, and the equivalent of Rust's `Option::ok_or`).
|
|
6
|
-
*
|
|
7
|
-
* If the {@link Optional} is `Some`, returns `Ok` with the contained value.
|
|
8
|
-
* If it is `None`, returns `Err` with the provided error value.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
*
|
|
12
|
-
* ```ts
|
|
13
|
-
* assert.deepStrictEqual(
|
|
14
|
-
* Result.fromOptional(Optional.some(42), 'missing'),
|
|
15
|
-
* Result.ok(42),
|
|
16
|
-
* );
|
|
17
|
-
*
|
|
18
|
-
* assert.deepStrictEqual(
|
|
19
|
-
* Result.fromOptional(Optional.none, 'missing'),
|
|
20
|
-
* Result.err('missing'),
|
|
21
|
-
* );
|
|
22
|
-
*
|
|
23
|
-
* const withMissingError = Result.fromOptional('missing');
|
|
24
|
-
*
|
|
25
|
-
* assert.deepStrictEqual(withMissingError(Optional.some(1)), Result.ok(1));
|
|
26
|
-
*
|
|
27
|
-
* assert.deepStrictEqual(
|
|
28
|
-
* withMissingError(Optional.none),
|
|
29
|
-
* Result.err('missing'),
|
|
30
|
-
* );
|
|
31
|
-
* ```
|
|
32
|
-
*
|
|
33
|
-
* @template O The input `UnknownOptional` type.
|
|
34
|
-
* @template E The type of the error value used for the `None` case.
|
|
35
|
-
* @param optional The `Optional` to convert.
|
|
36
|
-
* @param error The error value to use if the `Optional` is `None`.
|
|
37
|
-
* @returns `Ok` with the contained value, or `Err` with `error`.
|
|
38
|
-
*/
|
|
39
|
-
export declare function fromOptional<O extends UnknownOptional, const E>(optional: O, error: E): Result<Optional.Unwrap<O>, E>;
|
|
40
|
-
export declare function fromOptional<const E>(error: E): <O extends UnknownOptional>(optional: O) => Result<Optional.Unwrap<O>, E>;
|
|
41
|
-
//# sourceMappingURL=result-from-optional.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-from-optional.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-from-optional.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAI5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,eAAe,EAAE,KAAK,CAAC,CAAC,EAC7D,QAAQ,EAAE,CAAC,EACX,KAAK,EAAE,CAAC,GACP,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAGjC,wBAAgB,YAAY,CAAC,KAAK,CAAC,CAAC,EAClC,KAAK,EAAE,CAAC,GACP,CAAC,CAAC,SAAS,eAAe,EAAE,QAAQ,EAAE,CAAC,KAAK,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Optional } from '../../optional/index.mjs';
|
|
2
|
-
import { err } from './result-err.mjs';
|
|
3
|
-
import { ok } from './result-ok.mjs';
|
|
4
|
-
export function fromOptional(...args) {
|
|
5
|
-
switch (args.length) {
|
|
6
|
-
case 2: {
|
|
7
|
-
const [optional, error] = args;
|
|
8
|
-
return fromOptionalImpl(optional, error);
|
|
9
|
-
}
|
|
10
|
-
case 1: {
|
|
11
|
-
|
|
12
|
-
const [error] = args;
|
|
13
|
-
return (optional) => fromOptionalImpl(optional, error);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
const fromOptionalImpl = (optional, error) => Optional.isSome(optional)
|
|
18
|
-
?
|
|
19
|
-
ok(Optional.unwrap(optional))
|
|
20
|
-
: err(error);
|
|
21
|
-
//# sourceMappingURL=result-from-optional.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-from-optional.mjs","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-from-optional.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAwB,MAAM,0BAA0B,CAAC;AAE1E,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAgDrC,MAAM,UAAU,YAAY,CAC1B,GAAG,IAA4D;IAI/D,QAAQ,IAAI,CAAC,MAAM,EAAE,CAAC;QACpB,KAAK,CAAC,EAAE,CAAC;YACP,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;YAE/B,OAAO,gBAAgB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC3C,CAAC;QAED,KAAK,CAAC,EAAE,CAAC;YACP,wDAAwD;YACxD,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC;YAErB,OAAO,CAAC,QAAW,EAAE,EAAE,CAAC,gBAAgB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,gBAAgB,GAAG,CACvB,QAAW,EACX,KAAQ,EACuB,EAAE,CACjC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC;IACvB,CAAC,CAAC,oEAAoE;QACpE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAE,CAAC;IAChC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC"}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { type Result } from '../result.mjs';
|
|
2
|
-
/**
|
|
3
|
-
* @template P The Promise type.
|
|
4
|
-
* @internal
|
|
5
|
-
* Utility type to extract the resolved value type from a Promise.
|
|
6
|
-
*/
|
|
7
|
-
type UnwrapPromise<P extends Promise<unknown>> = P extends Promise<infer V> ? V : never;
|
|
8
|
-
/**
|
|
9
|
-
* Converts a Promise into a Promise that resolves to a `Result`. If the input
|
|
10
|
-
* Promise resolves, the `Result` will be `Ok` with the resolved value. If the
|
|
11
|
-
* input Promise rejects, the `Result` will be `Err` with the rejection
|
|
12
|
-
* reason.
|
|
13
|
-
*
|
|
14
|
-
* The error channel is `unknown`, since the rejection reason is carried
|
|
15
|
-
* through untouched. For a concrete error type, use `AsyncResult.fromPromise`
|
|
16
|
-
* with a `mapError` function; called without one it behaves exactly as this
|
|
17
|
-
* function does.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
*
|
|
21
|
-
* ```ts
|
|
22
|
-
* const successPromise = Result.fromPromise(Promise.resolve('ok'));
|
|
23
|
-
*
|
|
24
|
-
* const failurePromise = Result.fromPromise(
|
|
25
|
-
* Promise.reject(new Error('fail')),
|
|
26
|
-
* );
|
|
27
|
-
*
|
|
28
|
-
* const resolved = await successPromise;
|
|
29
|
-
*
|
|
30
|
-
* const rejected = await failurePromise;
|
|
31
|
-
*
|
|
32
|
-
* assert.deepStrictEqual(resolved, Result.ok('ok'));
|
|
33
|
-
*
|
|
34
|
-
* assert.isTrue(Result.isErr(rejected));
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
* @template P The type of the input Promise.
|
|
38
|
-
* @param promise The Promise to convert.
|
|
39
|
-
* @returns A Promise that resolves to `Result<UnwrapPromise<P>, unknown>`.
|
|
40
|
-
*/
|
|
41
|
-
export declare const fromPromise: <P extends Promise<unknown>>(promise: P) => Promise<Result<UnwrapPromise<P>, unknown>>;
|
|
42
|
-
export {};
|
|
43
|
-
//# sourceMappingURL=result-from-promise.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"result-from-promise.d.mts","sourceRoot":"","sources":["../../../../src/functional/result/impl/result-from-promise.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAI5C;;;;GAIG;AACH,KAAK,aAAa,CAAC,CAAC,SAAS,OAAO,CAAC,OAAO,CAAC,IAC3C,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,OAAO,CAAC,OAAO,CAAC,WAC3C,CAAC,KACT,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAEmB,CAAC"}
|