ts-data-forge 3.3.1 → 4.1.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/dist/array/impl/array-utils-element-access.d.mts +3 -4
- package/dist/array/impl/array-utils-element-access.d.mts.map +1 -1
- package/dist/array/impl/array-utils-element-access.mjs +8 -8
- package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
- package/dist/array/impl/array-utils-reducing-value.d.mts +8 -9
- package/dist/array/impl/array-utils-reducing-value.d.mts.map +1 -1
- package/dist/array/impl/array-utils-reducing-value.mjs +9 -7
- package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
- package/dist/array/impl/array-utils-search.d.mts +0 -1
- package/dist/array/impl/array-utils-search.d.mts.map +1 -1
- package/dist/array/impl/array-utils-search.mjs +6 -6
- package/dist/array/impl/array-utils-search.mjs.map +1 -1
- package/dist/array/impl/array-utils-transformation.mjs +2 -4
- package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
- package/dist/collections/imap-mapped.d.mts +0 -1
- package/dist/collections/imap-mapped.d.mts.map +1 -1
- package/dist/collections/imap-mapped.mjs +7 -6
- package/dist/collections/imap-mapped.mjs.map +1 -1
- package/dist/collections/imap.d.mts +0 -1
- package/dist/collections/imap.d.mts.map +1 -1
- package/dist/collections/imap.mjs +11 -9
- package/dist/collections/imap.mjs.map +1 -1
- package/dist/collections/queue.d.mts +0 -1
- package/dist/collections/queue.d.mts.map +1 -1
- package/dist/collections/queue.mjs +4 -4
- package/dist/collections/queue.mjs.map +1 -1
- package/dist/collections/stack.d.mts +0 -1
- package/dist/collections/stack.d.mts.map +1 -1
- package/dist/collections/stack.mjs +4 -4
- package/dist/collections/stack.mjs.map +1 -1
- package/dist/entry-point.d.mts +1 -0
- package/dist/entry-point.d.mts.map +1 -1
- package/dist/entry-point.mjs +8 -4
- package/dist/entry-point.mjs.map +1 -1
- package/dist/functional/index.d.mts +3 -2
- package/dist/functional/index.d.mts.map +1 -1
- package/dist/functional/index.mjs +6 -2
- package/dist/functional/index.mjs.map +1 -1
- package/dist/functional/optional/impl/index.d.mts +18 -0
- package/dist/functional/optional/impl/index.d.mts.map +1 -0
- package/dist/functional/optional/impl/index.mjs +17 -0
- package/dist/functional/optional/impl/index.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-expect-to-be.d.mts +29 -0
- package/dist/functional/optional/impl/optional-expect-to-be.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-expect-to-be.mjs +25 -0
- package/dist/functional/optional/impl/optional-expect-to-be.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-filter.d.mts +29 -0
- package/dist/functional/optional/impl/optional-filter.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-filter.mjs +28 -0
- package/dist/functional/optional/impl/optional-filter.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-flat-map.d.mts +33 -0
- package/dist/functional/optional/impl/optional-flat-map.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-flat-map.mjs +21 -0
- package/dist/functional/optional/impl/optional-flat-map.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-from-nullable.d.mts +24 -0
- package/dist/functional/optional/impl/optional-from-nullable.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-from-nullable.mjs +29 -0
- package/dist/functional/optional/impl/optional-from-nullable.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-is-none.d.mts +22 -0
- package/dist/functional/optional/impl/optional-is-none.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-is-none.mjs +25 -0
- package/dist/functional/optional/impl/optional-is-none.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-is-optional.d.mts +18 -0
- package/dist/functional/optional/impl/optional-is-optional.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-is-optional.mjs +27 -0
- package/dist/functional/optional/impl/optional-is-optional.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-is-some.d.mts +22 -0
- package/dist/functional/optional/impl/optional-is-some.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-is-some.mjs +25 -0
- package/dist/functional/optional/impl/optional-is-some.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-map.d.mts +31 -0
- package/dist/functional/optional/impl/optional-map.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-map.mjs +25 -0
- package/dist/functional/optional/impl/optional-map.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-none.d.mts +16 -0
- package/dist/functional/optional/impl/optional-none.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-none.mjs +20 -0
- package/dist/functional/optional/impl/optional-none.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-or-else.d.mts +35 -0
- package/dist/functional/optional/impl/optional-or-else.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-or-else.mjs +19 -0
- package/dist/functional/optional/impl/optional-or-else.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-some.d.mts +19 -0
- package/dist/functional/optional/impl/optional-some.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-some.mjs +26 -0
- package/dist/functional/optional/impl/optional-some.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-to-nullable.d.mts +27 -0
- package/dist/functional/optional/impl/optional-to-nullable.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-to-nullable.mjs +31 -0
- package/dist/functional/optional/impl/optional-to-nullable.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-unwrap-or.d.mts +33 -0
- package/dist/functional/optional/impl/optional-unwrap-or.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-unwrap-or.mjs +19 -0
- package/dist/functional/optional/impl/optional-unwrap-or.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-unwrap-throw.d.mts +29 -0
- package/dist/functional/optional/impl/optional-unwrap-throw.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-unwrap-throw.mjs +38 -0
- package/dist/functional/optional/impl/optional-unwrap-throw.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-unwrap.d.mts +28 -0
- package/dist/functional/optional/impl/optional-unwrap.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-unwrap.mjs +11 -0
- package/dist/functional/optional/impl/optional-unwrap.mjs.map +1 -0
- package/dist/functional/optional/impl/optional-zip.d.mts +31 -0
- package/dist/functional/optional/impl/optional-zip.d.mts.map +1 -0
- package/dist/functional/optional/impl/optional-zip.mjs +39 -0
- package/dist/functional/optional/impl/optional-zip.mjs.map +1 -0
- package/dist/functional/optional/impl/tag.d.mts +5 -0
- package/dist/functional/optional/impl/tag.d.mts.map +1 -0
- package/dist/functional/optional/impl/tag.mjs +7 -0
- package/dist/functional/optional/impl/tag.mjs.map +1 -0
- package/dist/functional/optional/impl/types.d.mts +22 -0
- package/dist/functional/optional/impl/types.d.mts.map +1 -0
- package/dist/functional/optional/impl/types.mjs +2 -0
- package/dist/functional/optional/impl/types.mjs.map +1 -0
- package/dist/functional/optional/index.d.mts +2 -0
- package/dist/functional/optional/index.d.mts.map +1 -0
- package/dist/functional/optional/index.mjs +3 -0
- package/dist/functional/optional/index.mjs.map +1 -0
- package/dist/functional/pipe.d.mts +4 -4
- package/dist/functional/pipe.d.mts.map +1 -1
- package/dist/functional/pipe.mjs +4 -3
- package/dist/functional/pipe.mjs.map +1 -1
- package/dist/functional/result/impl/index.d.mts +24 -0
- package/dist/functional/result/impl/index.d.mts.map +1 -0
- package/dist/functional/result/impl/index.mjs +23 -0
- package/dist/functional/result/impl/index.mjs.map +1 -0
- package/dist/functional/result/impl/result-err.d.mts +25 -0
- package/dist/functional/result/impl/result-err.d.mts.map +1 -0
- package/dist/functional/result/impl/result-err.mjs +32 -0
- package/dist/functional/result/impl/result-err.mjs.map +1 -0
- package/dist/functional/result/impl/result-expect-to-be.d.mts +27 -0
- package/dist/functional/result/impl/result-expect-to-be.d.mts.map +1 -0
- package/dist/functional/result/impl/result-expect-to-be.mjs +26 -0
- package/dist/functional/result/impl/result-expect-to-be.mjs.map +1 -0
- package/dist/functional/result/impl/result-flat-map.d.mts +39 -0
- package/dist/functional/result/impl/result-flat-map.d.mts.map +1 -0
- package/dist/functional/result/impl/result-flat-map.mjs +24 -0
- package/dist/functional/result/impl/result-flat-map.mjs.map +1 -0
- package/dist/functional/result/impl/result-fold.d.mts +45 -0
- package/dist/functional/result/impl/result-fold.d.mts.map +1 -0
- package/dist/functional/result/impl/result-fold.mjs +26 -0
- package/dist/functional/result/impl/result-fold.mjs.map +1 -0
- package/dist/functional/result/impl/result-from-promise.d.mts +32 -0
- package/dist/functional/result/impl/result-from-promise.d.mts.map +1 -0
- package/dist/functional/result/impl/result-from-promise.mjs +32 -0
- package/dist/functional/result/impl/result-from-promise.mjs.map +1 -0
- package/dist/functional/result/impl/result-from-throwable.d.mts +29 -0
- package/dist/functional/result/impl/result-from-throwable.d.mts.map +1 -0
- package/dist/functional/result/impl/result-from-throwable.mjs +46 -0
- package/dist/functional/result/impl/result-from-throwable.mjs.map +1 -0
- package/dist/functional/result/impl/result-is-err.d.mts +20 -0
- package/dist/functional/result/impl/result-is-err.d.mts.map +1 -0
- package/dist/functional/result/impl/result-is-err.mjs +23 -0
- package/dist/functional/result/impl/result-is-err.mjs.map +1 -0
- package/dist/functional/result/impl/result-is-ok.d.mts +20 -0
- package/dist/functional/result/impl/result-is-ok.d.mts.map +1 -0
- package/dist/functional/result/impl/result-is-ok.mjs +23 -0
- package/dist/functional/result/impl/result-is-ok.mjs.map +1 -0
- package/dist/functional/result/impl/result-is-result.d.mts +17 -0
- package/dist/functional/result/impl/result-is-result.d.mts.map +1 -0
- package/dist/functional/result/impl/result-is-result.mjs +26 -0
- package/dist/functional/result/impl/result-is-result.mjs.map +1 -0
- package/dist/functional/result/impl/result-map-err.d.mts +33 -0
- package/dist/functional/result/impl/result-map-err.d.mts.map +1 -0
- package/dist/functional/result/impl/result-map-err.mjs +25 -0
- package/dist/functional/result/impl/result-map-err.mjs.map +1 -0
- package/dist/functional/result/impl/result-map.d.mts +34 -0
- package/dist/functional/result/impl/result-map.d.mts.map +1 -0
- package/dist/functional/result/impl/result-map.mjs +25 -0
- package/dist/functional/result/impl/result-map.mjs.map +1 -0
- package/dist/functional/result/impl/result-ok.d.mts +25 -0
- package/dist/functional/result/impl/result-ok.d.mts.map +1 -0
- package/dist/functional/result/impl/result-ok.mjs +32 -0
- package/dist/functional/result/impl/result-ok.mjs.map +1 -0
- package/dist/functional/result/impl/result-or-else.d.mts +32 -0
- package/dist/functional/result/impl/result-or-else.d.mts.map +1 -0
- package/dist/functional/result/impl/result-or-else.mjs +20 -0
- package/dist/functional/result/impl/result-or-else.mjs.map +1 -0
- package/dist/functional/result/impl/result-swap.d.mts +20 -0
- package/dist/functional/result/impl/result-swap.d.mts.map +1 -0
- package/dist/functional/result/impl/result-swap.mjs +28 -0
- package/dist/functional/result/impl/result-swap.mjs.map +1 -0
- package/dist/functional/result/impl/result-to-optional.d.mts +28 -0
- package/dist/functional/result/impl/result-to-optional.d.mts.map +1 -0
- package/dist/functional/result/impl/result-to-optional.mjs +34 -0
- package/dist/functional/result/impl/result-to-optional.mjs.map +1 -0
- package/dist/functional/result/impl/result-unwrap-err-or.d.mts +29 -0
- package/dist/functional/result/impl/result-unwrap-err-or.d.mts.map +1 -0
- package/dist/functional/result/impl/result-unwrap-err-or.mjs +20 -0
- package/dist/functional/result/impl/result-unwrap-err-or.mjs.map +1 -0
- package/dist/functional/result/impl/result-unwrap-err-throw.d.mts +30 -0
- package/dist/functional/result/impl/result-unwrap-err-throw.d.mts.map +1 -0
- package/dist/functional/result/impl/result-unwrap-err-throw.mjs +47 -0
- package/dist/functional/result/impl/result-unwrap-err-throw.mjs.map +1 -0
- package/dist/functional/result/impl/result-unwrap-err.d.mts +31 -0
- package/dist/functional/result/impl/result-unwrap-err.d.mts.map +1 -0
- package/dist/functional/result/impl/result-unwrap-err.mjs +36 -0
- package/dist/functional/result/impl/result-unwrap-err.mjs.map +1 -0
- package/dist/functional/result/impl/result-unwrap-ok-or.d.mts +29 -0
- package/dist/functional/result/impl/result-unwrap-ok-or.d.mts.map +1 -0
- package/dist/functional/result/impl/result-unwrap-ok-or.mjs +20 -0
- package/dist/functional/result/impl/result-unwrap-ok-or.mjs.map +1 -0
- package/dist/functional/result/impl/result-unwrap-ok.d.mts +23 -0
- package/dist/functional/result/impl/result-unwrap-ok.d.mts.map +1 -0
- package/dist/functional/result/impl/result-unwrap-ok.mjs +11 -0
- package/dist/functional/result/impl/result-unwrap-ok.mjs.map +1 -0
- package/dist/functional/result/impl/result-unwrap-throw.d.mts +30 -0
- package/dist/functional/result/impl/result-unwrap-throw.d.mts.map +1 -0
- package/dist/functional/result/impl/result-unwrap-throw.mjs +41 -0
- package/dist/functional/result/impl/result-unwrap-throw.mjs.map +1 -0
- package/dist/functional/result/impl/result-zip.d.mts +29 -0
- package/dist/functional/result/impl/result-zip.d.mts.map +1 -0
- package/dist/functional/result/impl/result-zip.mjs +38 -0
- package/dist/functional/result/impl/result-zip.mjs.map +1 -0
- package/dist/functional/result/impl/tag.d.mts +5 -0
- package/dist/functional/result/impl/tag.d.mts.map +1 -0
- package/dist/functional/result/impl/tag.mjs +7 -0
- package/dist/functional/result/impl/tag.mjs.map +1 -0
- package/dist/functional/result/impl/types.d.mts +29 -0
- package/dist/functional/result/impl/types.d.mts.map +1 -0
- package/dist/functional/result/impl/types.mjs +2 -0
- package/dist/functional/result/impl/types.mjs.map +1 -0
- package/dist/functional/result/index.d.mts +2 -0
- package/dist/functional/result/index.d.mts.map +1 -0
- package/dist/functional/result/index.mjs +3 -0
- package/dist/functional/result/index.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/index.d.mts +29 -0
- package/dist/functional/ternary-result/impl/index.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/index.mjs +28 -0
- package/dist/functional/ternary-result/impl/index.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/tag.d.mts +7 -0
- package/dist/functional/ternary-result/impl/tag.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/tag.mjs +9 -0
- package/dist/functional/ternary-result/impl/tag.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-err.d.mts +14 -0
- package/dist/functional/ternary-result/impl/ternary-result-err.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-err.mjs +21 -0
- package/dist/functional/ternary-result/impl/ternary-result-err.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.d.mts +18 -0
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs +24 -0
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.d.mts +29 -0
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs +41 -0
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-fold.d.mts +27 -0
- package/dist/functional/ternary-result/impl/ternary-result-fold.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-fold.mjs +36 -0
- package/dist/functional/ternary-result/impl/ternary-result-fold.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts +20 -0
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs +24 -0
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts +17 -0
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +33 -0
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-err.d.mts +20 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-err.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs +23 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts +21 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs +24 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts +17 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs +28 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.d.mts +21 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs +24 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-err.d.mts +23 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-err.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs +26 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.d.mts +21 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs +29 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-map.d.mts +29 -0
- package/dist/functional/ternary-result/impl/ternary-result-map.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-map.mjs +35 -0
- package/dist/functional/ternary-result/impl/ternary-result-map.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts +16 -0
- package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-ok.mjs +23 -0
- package/dist/functional/ternary-result/impl/ternary-result-ok.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-or-else.d.mts +26 -0
- package/dist/functional/ternary-result/impl/ternary-result-or-else.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs +19 -0
- package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.d.mts +16 -0
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs +25 -0
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.d.mts +22 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs +17 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.d.mts +18 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs +36 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.d.mts +17 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs +22 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.d.mts +22 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs +17 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.d.mts +17 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs +13 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts +18 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs +36 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.d.mts +19 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs +17 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.d.mts +18 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs +32 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.d.mts +17 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs +22 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts +18 -0
- package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-warn.mjs +26 -0
- package/dist/functional/ternary-result/impl/ternary-result-warn.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts +26 -0
- package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-zip.mjs +48 -0
- package/dist/functional/ternary-result/impl/ternary-result-zip.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/types.d.mts +25 -0
- package/dist/functional/ternary-result/impl/types.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/types.mjs +2 -0
- package/dist/functional/ternary-result/impl/types.mjs.map +1 -0
- package/dist/functional/ternary-result/impl/variant-name.d.mts +3 -0
- package/dist/functional/ternary-result/impl/variant-name.d.mts.map +1 -0
- package/dist/functional/ternary-result/impl/variant-name.mjs +16 -0
- package/dist/functional/ternary-result/impl/variant-name.mjs.map +1 -0
- package/dist/functional/ternary-result/index.d.mts +2 -0
- package/dist/functional/ternary-result/index.d.mts.map +1 -0
- package/dist/functional/ternary-result/index.mjs +3 -0
- package/dist/functional/ternary-result/index.mjs.map +1 -0
- package/dist/globals.d.mts +136 -0
- package/dist/index.d.mts +0 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +0 -4
- package/dist/index.mjs.map +1 -1
- package/dist/json/json.d.mts +0 -1
- package/dist/json/json.d.mts.map +1 -1
- package/dist/json/json.mjs +8 -8
- package/dist/json/json.mjs.map +1 -1
- package/dist/number/branded-types/finite-number.mjs +1 -1
- package/dist/number/branded-types/finite-number.mjs.map +1 -1
- package/dist/number/branded-types/int.mjs +1 -1
- package/dist/number/branded-types/int.mjs.map +1 -1
- package/dist/number/branded-types/int16.mjs +1 -1
- package/dist/number/branded-types/int16.mjs.map +1 -1
- package/dist/number/branded-types/int32.mjs +1 -1
- package/dist/number/branded-types/int32.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-finite-number.mjs +1 -1
- package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-int16.mjs +1 -1
- package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-int32.mjs +1 -1
- package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-finite-number.mjs +1 -1
- package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int.mjs +1 -1
- package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int16.mjs +1 -1
- package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int32.mjs +1 -1
- package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-safe-int.mjs +1 -1
- package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint16.mjs +1 -1
- package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint32.mjs +1 -1
- package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
- package/dist/number/branded-types/positive-finite-number.mjs +1 -1
- package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/positive-int.mjs +1 -1
- package/dist/number/branded-types/positive-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-int16.mjs +1 -1
- package/dist/number/branded-types/positive-int16.mjs.map +1 -1
- package/dist/number/branded-types/positive-int32.mjs +1 -1
- package/dist/number/branded-types/positive-int32.mjs.map +1 -1
- package/dist/number/branded-types/positive-safe-int.mjs +1 -1
- package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-uint16.mjs +1 -1
- package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
- package/dist/number/branded-types/positive-uint32.mjs +1 -1
- package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
- package/dist/number/branded-types/safe-int.mjs +1 -1
- package/dist/number/branded-types/safe-int.mjs.map +1 -1
- package/dist/number/branded-types/safe-uint.mjs +1 -1
- package/dist/number/branded-types/safe-uint.mjs.map +1 -1
- package/dist/number/branded-types/uint.mjs +1 -1
- package/dist/number/branded-types/uint.mjs.map +1 -1
- package/dist/number/branded-types/uint16.mjs +1 -1
- package/dist/number/branded-types/uint16.mjs.map +1 -1
- package/dist/number/branded-types/uint32.mjs +1 -1
- package/dist/number/branded-types/uint32.mjs.map +1 -1
- package/dist/number/enum/int8.mjs +1 -1
- package/dist/number/enum/int8.mjs.map +1 -1
- package/dist/number/enum/uint8.mjs +1 -1
- package/dist/number/enum/uint8.mjs.map +1 -1
- package/dist/number/refined-number-utils.mjs +0 -2
- package/dist/number/refined-number-utils.mjs.map +1 -1
- package/dist/promise/promise.d.mts +0 -1
- package/dist/promise/promise.d.mts.map +1 -1
- package/dist/promise/promise.mjs +2 -3
- package/dist/promise/promise.mjs.map +1 -1
- package/package.json +27 -21
- package/src/array/impl/array-utils-element-access.mts +6 -6
- package/src/array/impl/array-utils-element-access.test.mts +6 -6
- package/src/array/impl/array-utils-reducing-value.mts +8 -24
- package/src/array/impl/array-utils-reducing-value.test.mts +8 -8
- package/src/array/impl/array-utils-slice-clamped.test.mts +1 -1
- package/src/entry-point.mts +1 -0
- package/src/functional/index.mts +3 -2
- package/src/functional/optional/impl/index.mts +17 -0
- package/src/functional/optional/impl/optional-expect-to-be.mts +65 -0
- package/src/functional/optional/impl/optional-filter.mts +71 -0
- package/src/functional/optional/impl/optional-flat-map.mts +67 -0
- package/src/functional/optional/impl/optional-from-nullable.mts +28 -0
- package/src/functional/optional/impl/optional-is-none.mts +25 -0
- package/src/functional/optional/impl/optional-is-optional.mts +27 -0
- package/src/functional/optional/impl/optional-is-some.mts +25 -0
- package/src/functional/optional/impl/optional-map.mts +69 -0
- package/src/functional/optional/impl/optional-none.mts +17 -0
- package/src/functional/optional/impl/optional-or-else.mts +73 -0
- package/src/functional/optional/impl/optional-some.mts +23 -0
- package/src/functional/optional/impl/optional-to-nullable.mts +31 -0
- package/src/functional/optional/impl/optional-unwrap-or.mts +64 -0
- package/src/functional/optional/impl/optional-unwrap-throw.mts +39 -0
- package/src/functional/optional/impl/optional-unwrap.mts +41 -0
- package/src/functional/optional/impl/optional-zip.mts +40 -0
- package/src/functional/optional/impl/tag.mts +6 -0
- package/src/functional/optional/impl/types.mts +28 -0
- package/src/functional/optional/index.mts +1 -0
- package/src/functional/optional.test.mts +7 -8
- package/src/functional/pipe.mts +5 -5
- package/src/functional/pipe.test.mts +1 -1
- package/src/functional/result/impl/index.mts +23 -0
- package/src/functional/result/impl/result-err.mts +29 -0
- package/src/functional/result/impl/result-expect-to-be.mts +63 -0
- package/src/functional/result/impl/result-flat-map.mts +79 -0
- package/src/functional/result/impl/result-fold.mts +95 -0
- package/src/functional/result/impl/result-from-promise.mts +39 -0
- package/src/functional/result/impl/result-from-throwable.mts +42 -0
- package/src/functional/result/impl/result-is-err.mts +23 -0
- package/src/functional/result/impl/result-is-ok.mts +23 -0
- package/src/functional/result/impl/result-is-result.mts +23 -0
- package/src/functional/result/impl/result-map-err.mts +72 -0
- package/src/functional/result/impl/result-map.mts +73 -0
- package/src/functional/result/impl/result-ok.mts +29 -0
- package/src/functional/result/impl/result-or-else.mts +63 -0
- package/src/functional/result/impl/result-swap.mts +28 -0
- package/src/functional/result/impl/result-to-optional.mts +34 -0
- package/src/functional/result/impl/result-unwrap-err-or.mts +60 -0
- package/src/functional/result/impl/result-unwrap-err-throw.mts +53 -0
- package/src/functional/result/impl/result-unwrap-err.mts +36 -0
- package/src/functional/result/impl/result-unwrap-ok-or.mts +60 -0
- package/src/functional/result/impl/result-unwrap-ok.mts +35 -0
- package/src/functional/result/impl/result-unwrap-throw.mts +43 -0
- package/src/functional/result/impl/result-zip.mts +39 -0
- package/src/functional/result/impl/tag.mts +6 -0
- package/src/functional/result/impl/types.mts +35 -0
- package/src/functional/result/index.mts +1 -0
- package/src/functional/result.test.mts +5 -4
- package/src/functional/ternary-result/impl/index.mts +28 -0
- package/src/functional/ternary-result/impl/tag.mts +11 -0
- package/src/functional/ternary-result/impl/ternary-result-err.mts +18 -0
- package/src/functional/ternary-result/impl/ternary-result-expect-to-be.mts +53 -0
- package/src/functional/ternary-result/impl/ternary-result-flat-map.mts +95 -0
- package/src/functional/ternary-result/impl/ternary-result-fold.mts +93 -0
- package/src/functional/ternary-result/impl/ternary-result-from-promise.mts +27 -0
- package/src/functional/ternary-result/impl/ternary-result-from-throwable.mts +31 -0
- package/src/functional/ternary-result/impl/ternary-result-is-err.mts +23 -0
- package/src/functional/ternary-result/impl/ternary-result-is-ok.mts +24 -0
- package/src/functional/ternary-result/impl/ternary-result-is-ternary-result.mts +27 -0
- package/src/functional/ternary-result/impl/ternary-result-is-warn.mts +24 -0
- package/src/functional/ternary-result/impl/ternary-result-map-err.mts +64 -0
- package/src/functional/ternary-result/impl/ternary-result-map-warn.mts +66 -0
- package/src/functional/ternary-result/impl/ternary-result-map.mts +81 -0
- package/src/functional/ternary-result/impl/ternary-result-ok.mts +20 -0
- package/src/functional/ternary-result/impl/ternary-result-or-else.mts +66 -0
- package/src/functional/ternary-result/impl/ternary-result-to-optional.mts +25 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-err-or.mts +45 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mts +40 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-err.mts +22 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mts +45 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-ok.mts +32 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-throw.mts +45 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mts +42 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mts +38 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-warn.mts +22 -0
- package/src/functional/ternary-result/impl/ternary-result-warn.mts +23 -0
- package/src/functional/ternary-result/impl/ternary-result-zip.mts +53 -0
- package/src/functional/ternary-result/impl/types.mts +39 -0
- package/src/functional/ternary-result/impl/variant-name.mts +17 -0
- package/src/functional/ternary-result/index.mts +1 -0
- package/src/functional/ternary-result.test.mts +198 -0
- package/src/globals.d.mts +136 -0
- package/src/guard/is-non-empty-string.test.mts +1 -1
- package/src/guard/is-non-null-object.test.mts +3 -3
- package/src/guard/is-primitive.test.mts +3 -3
- package/src/guard/is-type.test.mts +3 -3
- package/src/index.mts +0 -1
- package/src/number/branded-types/finite-number.mts +7 -7
- package/src/number/branded-types/int.mts +7 -7
- package/src/number/branded-types/int16.mts +9 -9
- package/src/number/branded-types/int32.mts +9 -9
- package/src/number/branded-types/non-negative-finite-number.mts +8 -8
- package/src/number/branded-types/non-negative-int16.mts +9 -9
- package/src/number/branded-types/non-negative-int32.mts +9 -9
- package/src/number/branded-types/non-zero-finite-number.mts +7 -7
- package/src/number/branded-types/non-zero-int.mts +7 -7
- package/src/number/branded-types/non-zero-int16.mts +9 -9
- package/src/number/branded-types/non-zero-int32.mts +9 -9
- package/src/number/branded-types/non-zero-safe-int.mts +9 -9
- package/src/number/branded-types/non-zero-uint16.mts +9 -9
- package/src/number/branded-types/non-zero-uint32.mts +9 -9
- package/src/number/branded-types/positive-finite-number.mts +8 -8
- package/src/number/branded-types/positive-int.mts +8 -8
- package/src/number/branded-types/positive-int16.mts +9 -9
- package/src/number/branded-types/positive-int32.mts +9 -9
- package/src/number/branded-types/positive-safe-int.mts +9 -9
- package/src/number/branded-types/positive-uint16.mts +9 -9
- package/src/number/branded-types/positive-uint32.mts +9 -9
- package/src/number/branded-types/safe-int.mts +9 -9
- package/src/number/branded-types/safe-uint.mts +9 -9
- package/src/number/branded-types/uint.mts +8 -8
- package/src/number/branded-types/uint16.mts +9 -9
- package/src/number/branded-types/uint32.mts +9 -9
- package/src/number/enum/int8.mts +3 -3
- package/src/number/enum/int8.test.mts +9 -9
- package/src/number/enum/uint8.mts +3 -3
- package/src/number/enum/uint8.test.mts +8 -8
- package/dist/functional/optional.d.mts +0 -482
- package/dist/functional/optional.d.mts.map +0 -1
- package/dist/functional/optional.mjs +0 -328
- package/dist/functional/optional.mjs.map +0 -1
- package/dist/functional/result.d.mts +0 -712
- package/dist/functional/result.d.mts.map +0 -1
- package/dist/functional/result.mjs +0 -539
- package/dist/functional/result.mjs.map +0 -1
- package/src/functional/optional.mts +0 -713
- package/src/functional/result.mts +0 -1087
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
import { isRecord } from '../guard/is-record.mjs';
|
|
2
|
-
|
|
3
|
-
/** @internal String literal tag to identify the 'Some' variant of Optional. */
|
|
4
|
-
const SomeTypeTagName = 'ts-data-forge::Optional.some';
|
|
5
|
-
/** @internal String literal tag to identify the 'None' variant of Optional. */
|
|
6
|
-
const NoneTypeTagName = 'ts-data-forge::Optional.none';
|
|
7
|
-
/**
|
|
8
|
-
* Namespace for the {@link Optional} type and related functions. Provides
|
|
9
|
-
* utilities to handle values that might be absent, similar to Option types in
|
|
10
|
-
* other languages.
|
|
11
|
-
*/
|
|
12
|
-
var Optional;
|
|
13
|
-
(function (Optional) {
|
|
14
|
-
/**
|
|
15
|
-
* Checks if the given value is an {@link Optional}.
|
|
16
|
-
*
|
|
17
|
-
* @example
|
|
18
|
-
*
|
|
19
|
-
* ```ts
|
|
20
|
-
* const maybeOptional = Optional.some('value');
|
|
21
|
-
* const notOptional = { $$tag: 'ts-data-forge::Optional.some' };
|
|
22
|
-
*
|
|
23
|
-
* assert.ok(Optional.isOptional(maybeOptional));
|
|
24
|
-
* assert.notOk(Optional.isOptional(notOptional));
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* @param maybeOptional The value to check.
|
|
28
|
-
* @returns `true` if the value is an {@link Optional}, otherwise `false`.
|
|
29
|
-
*/
|
|
30
|
-
Optional.isOptional = (maybeOptional) => isRecord(maybeOptional) &&
|
|
31
|
-
Object.hasOwn(maybeOptional, '$$tag') &&
|
|
32
|
-
((maybeOptional['$$tag'] === SomeTypeTagName &&
|
|
33
|
-
Object.hasOwn(maybeOptional, 'value')) ||
|
|
34
|
-
maybeOptional['$$tag'] === NoneTypeTagName);
|
|
35
|
-
/**
|
|
36
|
-
* Creates an {@link Optional.Some} containing the given value.
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
*
|
|
40
|
-
* ```ts
|
|
41
|
-
* const someValue = Optional.some({ id: 1 });
|
|
42
|
-
* const noneValue = Optional.none;
|
|
43
|
-
*
|
|
44
|
-
* assert.ok(Optional.isSome(someValue));
|
|
45
|
-
* assert.ok(Optional.isNone(noneValue));
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
|
-
* @template S The type of the value.
|
|
49
|
-
* @param value The value to wrap in an {@link Optional.Some}.
|
|
50
|
-
* @returns An {@link Optional.Some}<S> containing the value.
|
|
51
|
-
*/
|
|
52
|
-
Optional.some = (value) => ({
|
|
53
|
-
$$tag: SomeTypeTagName,
|
|
54
|
-
value,
|
|
55
|
-
});
|
|
56
|
-
/**
|
|
57
|
-
* The singleton instance representing {@link Optional.None} (an empty
|
|
58
|
-
* Optional).
|
|
59
|
-
*
|
|
60
|
-
* @example
|
|
61
|
-
*
|
|
62
|
-
* ```ts
|
|
63
|
-
* const someValue = Optional.some({ id: 1 });
|
|
64
|
-
* const noneValue = Optional.none;
|
|
65
|
-
*
|
|
66
|
-
* assert.ok(Optional.isSome(someValue));
|
|
67
|
-
* assert.ok(Optional.isNone(noneValue));
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
Optional.none = { $$tag: NoneTypeTagName };
|
|
71
|
-
/**
|
|
72
|
-
* Checks if an {@link Optional} is {@link Optional.Some}. Acts as a type guard.
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
*
|
|
76
|
-
* ```ts
|
|
77
|
-
* const optionalNumber = Optional.some(42);
|
|
78
|
-
*
|
|
79
|
-
* if (Optional.isSome(optionalNumber)) {
|
|
80
|
-
* const value: number = optionalNumber.value;
|
|
81
|
-
* assert(value === 42);
|
|
82
|
-
* }
|
|
83
|
-
* ```
|
|
84
|
-
*
|
|
85
|
-
* @template O The {@link Optional.Base} type to check.
|
|
86
|
-
* @param optional The {@link Optional} to check.
|
|
87
|
-
* @returns `true` if the {@link Optional} is {@link Optional.Some}, `false`
|
|
88
|
-
* otherwise.
|
|
89
|
-
*/
|
|
90
|
-
Optional.isSome = (optional) => optional.$$tag === SomeTypeTagName;
|
|
91
|
-
/**
|
|
92
|
-
* Checks if an {@link Optional} is {@link Optional.None}. Acts as a type guard.
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
*
|
|
96
|
-
* ```ts
|
|
97
|
-
* const optionalValue = Optional.none as Optional<number>;
|
|
98
|
-
*
|
|
99
|
-
* if (Optional.isNone(optionalValue)) {
|
|
100
|
-
* // Type narrowed to None
|
|
101
|
-
* assert.ok(true); // optionalValue is None
|
|
102
|
-
* }
|
|
103
|
-
* ```
|
|
104
|
-
*
|
|
105
|
-
* @template O The {@link Optional.Base} type to check.
|
|
106
|
-
* @param optional The {@link Optional} to check.
|
|
107
|
-
* @returns `true` if the {@link Optional} is {@link Optional.None}, `false`
|
|
108
|
-
* otherwise.
|
|
109
|
-
*/
|
|
110
|
-
Optional.isNone = (optional) => optional.$$tag === NoneTypeTagName;
|
|
111
|
-
/**
|
|
112
|
-
* Unwraps an `Optional`, returning the contained value. Throws an error if
|
|
113
|
-
* the `Optional` is `Optional.None`.
|
|
114
|
-
*
|
|
115
|
-
* This is a safer alternative to direct value access when you know the
|
|
116
|
-
* Optional should contain a value. Use this method when an empty Optional
|
|
117
|
-
* represents a programming error or unexpected condition.
|
|
118
|
-
*
|
|
119
|
-
* @example
|
|
120
|
-
*
|
|
121
|
-
* ```ts
|
|
122
|
-
* const present = Optional.some('available');
|
|
123
|
-
*
|
|
124
|
-
* assert(Optional.unwrapThrow(present) === 'available');
|
|
125
|
-
* assert.throws(
|
|
126
|
-
* () => Optional.unwrapThrow(Optional.none),
|
|
127
|
-
* /has failed because it is `None`/u,
|
|
128
|
-
* );
|
|
129
|
-
* ```
|
|
130
|
-
*
|
|
131
|
-
* @template O The `Optional.Base` type to unwrap.
|
|
132
|
-
* @param optional The `Optional` to unwrap.
|
|
133
|
-
* @returns The contained value if `Optional.Some`.
|
|
134
|
-
* @throws {Error} Error with message "`unwrapThrow()` has failed because it
|
|
135
|
-
* is `None`" if the `Optional` is `Optional.None`.
|
|
136
|
-
*/
|
|
137
|
-
Optional.unwrapThrow = (optional) => {
|
|
138
|
-
if (Optional.isSome(optional)) {
|
|
139
|
-
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
140
|
-
return optional.value;
|
|
141
|
-
}
|
|
142
|
-
throw new Error('`unwrapThrow()` has failed because it is `None`');
|
|
143
|
-
};
|
|
144
|
-
function unwrap(optional) {
|
|
145
|
-
return Optional.isSome(optional)
|
|
146
|
-
? // eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
147
|
-
optional.value
|
|
148
|
-
: undefined;
|
|
149
|
-
}
|
|
150
|
-
Optional.unwrap = unwrap;
|
|
151
|
-
function unwrapOr(...args) {
|
|
152
|
-
switch (args.length) {
|
|
153
|
-
case 2: {
|
|
154
|
-
const [optional, defaultValue] = args;
|
|
155
|
-
return Optional.isSome(optional)
|
|
156
|
-
? // eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
157
|
-
optional.value
|
|
158
|
-
: defaultValue;
|
|
159
|
-
}
|
|
160
|
-
case 1: {
|
|
161
|
-
// Curried version: first argument is default value
|
|
162
|
-
const [defaultValue] = args;
|
|
163
|
-
return (optional) => unwrapOr(optional, defaultValue);
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
Optional.unwrapOr = unwrapOr;
|
|
168
|
-
function orElse(...args) {
|
|
169
|
-
switch (args.length) {
|
|
170
|
-
case 2: {
|
|
171
|
-
const [optional, alternative] = args;
|
|
172
|
-
return Optional.isNone(optional) ? alternative : optional;
|
|
173
|
-
}
|
|
174
|
-
case 1: {
|
|
175
|
-
const [alternative] = args;
|
|
176
|
-
return (optional) => orElse(optional, alternative);
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
Optional.orElse = orElse;
|
|
181
|
-
function map(...args) {
|
|
182
|
-
switch (args.length) {
|
|
183
|
-
case 2: {
|
|
184
|
-
const [optional, mapFn] = args;
|
|
185
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
186
|
-
return Optional.isSome(optional) ? Optional.some(mapFn(unwrap(optional))) : Optional.none;
|
|
187
|
-
}
|
|
188
|
-
case 1: {
|
|
189
|
-
// Curried version: first argument is mapping function
|
|
190
|
-
const [mapFn] = args;
|
|
191
|
-
return (optional) => map(optional, mapFn);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
Optional.map = map;
|
|
196
|
-
function flatMap(...args) {
|
|
197
|
-
switch (args.length) {
|
|
198
|
-
case 2: {
|
|
199
|
-
const [optional, flatMapFn] = args;
|
|
200
|
-
return Optional.isSome(optional) ? flatMapFn(unwrap(optional)) : Optional.none;
|
|
201
|
-
}
|
|
202
|
-
case 1: {
|
|
203
|
-
const [flatMapFn] = args;
|
|
204
|
-
return (optional) => flatMap(optional, flatMapFn);
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
Optional.flatMap = flatMap;
|
|
209
|
-
function filter(...args) {
|
|
210
|
-
switch (args.length) {
|
|
211
|
-
case 2: {
|
|
212
|
-
const [optional, predicate] = args;
|
|
213
|
-
if (Optional.isSome(optional)) {
|
|
214
|
-
const value = unwrap(optional);
|
|
215
|
-
return predicate(value) ? Optional.some(value) : Optional.none;
|
|
216
|
-
}
|
|
217
|
-
// If the optional is None, return None
|
|
218
|
-
return Optional.none;
|
|
219
|
-
}
|
|
220
|
-
case 1: {
|
|
221
|
-
// Curried version: first argument is predicate function
|
|
222
|
-
const [predicate] = args;
|
|
223
|
-
return (optional) => filter(optional, predicate);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
Optional.filter = filter;
|
|
228
|
-
function expectToBe(...args) {
|
|
229
|
-
switch (args.length) {
|
|
230
|
-
case 2: {
|
|
231
|
-
const [optional, message] = args;
|
|
232
|
-
if (Optional.isSome(optional)) {
|
|
233
|
-
return unwrap(optional);
|
|
234
|
-
}
|
|
235
|
-
throw new Error(message);
|
|
236
|
-
}
|
|
237
|
-
case 1: {
|
|
238
|
-
// Curried version: first argument is message
|
|
239
|
-
const [message] = args;
|
|
240
|
-
return (optional) => expectToBe(optional, message);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
Optional.expectToBe = expectToBe;
|
|
245
|
-
/**
|
|
246
|
-
* Combines two `Optional` values into a single `Optional` containing a tuple.
|
|
247
|
-
* If either `Optional` is `None`, returns `None`.
|
|
248
|
-
*
|
|
249
|
-
* @example
|
|
250
|
-
*
|
|
251
|
-
* ```ts
|
|
252
|
-
* const zipped = Optional.zip(Optional.some('left'), Optional.some(1));
|
|
253
|
-
*
|
|
254
|
-
* assert.ok(Optional.isSome(zipped));
|
|
255
|
-
* if (Optional.isSome(zipped)) {
|
|
256
|
-
* const expected: readonly [string, number] = ['left', 1];
|
|
257
|
-
* assert.deepStrictEqual(zipped.value, expected);
|
|
258
|
-
* }
|
|
259
|
-
*
|
|
260
|
-
* const missing = Optional.zip(
|
|
261
|
-
* Optional.some('value'),
|
|
262
|
-
* Optional.none as Optional<number>,
|
|
263
|
-
* );
|
|
264
|
-
*
|
|
265
|
-
* assert.deepStrictEqual(missing, Optional.none);
|
|
266
|
-
* ```
|
|
267
|
-
*
|
|
268
|
-
* @template A The value type of the first `Optional`.
|
|
269
|
-
* @template B The value type of the second `Optional`.
|
|
270
|
-
* @param optionalA The first `Optional`.
|
|
271
|
-
* @param optionalB The second `Optional`.
|
|
272
|
-
* @returns An `Optional` containing a tuple of both values, or `None`.
|
|
273
|
-
*/
|
|
274
|
-
Optional.zip = (optionalA, optionalB) => Optional.isSome(optionalA) && Optional.isSome(optionalB)
|
|
275
|
-
? Optional.some([optionalA.value, optionalB.value])
|
|
276
|
-
: Optional.none;
|
|
277
|
-
/**
|
|
278
|
-
* Converts a nullable value to an `Optional`.
|
|
279
|
-
*
|
|
280
|
-
* This is the primary way to lift nullable values (null or undefined) into
|
|
281
|
-
* the Optional type system. The function treats both `null` and `undefined`
|
|
282
|
-
* as empty values, converting them to `Optional.None`.
|
|
283
|
-
*
|
|
284
|
-
* @example
|
|
285
|
-
*
|
|
286
|
-
* ```ts
|
|
287
|
-
* const present = Optional.fromNullable('hello');
|
|
288
|
-
* const absent = Optional.fromNullable<string | null>(null);
|
|
289
|
-
*
|
|
290
|
-
* assert.deepStrictEqual(present, Optional.some('hello'));
|
|
291
|
-
* assert.deepStrictEqual(absent, Optional.none);
|
|
292
|
-
* ```
|
|
293
|
-
*
|
|
294
|
-
* @template T The type of the nullable value.
|
|
295
|
-
* @param value The nullable value to convert.
|
|
296
|
-
* @returns `Optional.Some<NonNullable<T>>` if the value is not null or
|
|
297
|
-
* undefined, otherwise `Optional.None`.
|
|
298
|
-
*/
|
|
299
|
-
Optional.fromNullable = (value) => (value == null ? Optional.none : Optional.some(value));
|
|
300
|
-
/**
|
|
301
|
-
* Converts an `Optional` to a nullable value.
|
|
302
|
-
*
|
|
303
|
-
* This function extracts the value from an Optional, returning `undefined`
|
|
304
|
-
* for empty Optionals. This is useful when interfacing with APIs or systems
|
|
305
|
-
* that expect nullable values rather than Optional types.
|
|
306
|
-
*
|
|
307
|
-
* Note: This returns `undefined` (not `null`) for consistency with
|
|
308
|
-
* JavaScript's undefined semantics and TypeScript's optional properties.
|
|
309
|
-
*
|
|
310
|
-
* @example
|
|
311
|
-
*
|
|
312
|
-
* ```ts
|
|
313
|
-
* const someNumber = Optional.some(42);
|
|
314
|
-
* const noneNumber = Optional.none as Optional<number>;
|
|
315
|
-
*
|
|
316
|
-
* assert(Optional.toNullable(someNumber) === 42);
|
|
317
|
-
* assert(Optional.toNullable(noneNumber) === undefined);
|
|
318
|
-
* ```
|
|
319
|
-
*
|
|
320
|
-
* @template O The `Optional.Base` type to convert.
|
|
321
|
-
* @param optional The `Optional` to convert.
|
|
322
|
-
* @returns The contained value if `Some`, otherwise `undefined`.
|
|
323
|
-
*/
|
|
324
|
-
Optional.toNullable = (optional) => (Optional.isSome(optional) ? unwrap(optional) : undefined);
|
|
325
|
-
})(Optional || (Optional = {}));
|
|
326
|
-
|
|
327
|
-
export { Optional };
|
|
328
|
-
//# sourceMappingURL=optional.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"optional.mjs","sources":["../../src/functional/optional.mts"],"sourcesContent":[null],"names":[],"mappings":";;AAEA;AACA,MAAM,eAAe,GAAG,8BAA8B;AAEtD;AACA,MAAM,eAAe,GAAG,8BAA8B;AAsCtD;;;;AAIG;AACG,IAAW;AAAjB,CAAA,UAAiB,QAAQ,EAAA;AACvB;;;;;;;;;;;;;;;AAeG;IACU,QAAA,CAAA,UAAU,GAAG,CACxB,aAAsB,KAEtB,QAAQ,CAAC,aAAa,CAAC;AACvB,QAAA,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC;AACrC,SAAC,CAAC,aAAa,CAAC,OAAO,CAAC,KAAK,eAAe;AAC1C,YAAA,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,OAAO,CAAC;AACrC,YAAA,aAAa,CAAC,OAAO,CAAC,KAAK,eAAe,CAAC;AA4C/C;;;;;;;;;;;;;;;;AAgBG;AACU,IAAA,QAAA,CAAA,IAAI,GAAG,CAAK,KAAQ,MAAe;AAC9C,QAAA,KAAK,EAAE,eAAe;QACtB,KAAK;AACN,KAAA,CAAC;AAEF;;;;;;;;;;;;;AAaG;AACU,IAAA,QAAA,CAA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