ts-data-forge 5.0.0 → 5.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/README.md +55 -6
- package/dist/array/impl/array-utils-creation.d.mts +14 -0
- package/dist/array/impl/array-utils-creation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-creation.mjs +12 -0
- package/dist/array/impl/array-utils-creation.mjs.map +1 -1
- package/dist/array/impl/array-utils-element-access.d.mts +10 -0
- package/dist/array/impl/array-utils-element-access.d.mts.map +1 -1
- package/dist/array/impl/array-utils-element-access.mjs +7 -0
- package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
- package/dist/array/impl/array-utils-modification.d.mts +14 -0
- package/dist/array/impl/array-utils-modification.d.mts.map +1 -1
- package/dist/array/impl/array-utils-modification.mjs +1 -0
- package/dist/array/impl/array-utils-modification.mjs.map +1 -1
- package/dist/array/impl/array-utils-reducing-value.d.mts +26 -2
- package/dist/array/impl/array-utils-reducing-value.d.mts.map +1 -1
- package/dist/array/impl/array-utils-reducing-value.mjs +2 -1
- package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
- package/dist/array/impl/array-utils-search.d.mts +30 -0
- package/dist/array/impl/array-utils-search.d.mts.map +1 -1
- package/dist/array/impl/array-utils-search.mjs +1 -0
- package/dist/array/impl/array-utils-search.mjs.map +1 -1
- package/dist/array/impl/array-utils-set-op.d.mts +13 -0
- package/dist/array/impl/array-utils-set-op.d.mts.map +1 -1
- package/dist/array/impl/array-utils-set-op.mjs +13 -0
- package/dist/array/impl/array-utils-set-op.mjs.map +1 -1
- package/dist/array/impl/array-utils-size.d.mts +3 -0
- package/dist/array/impl/array-utils-size.d.mts.map +1 -1
- package/dist/array/impl/array-utils-size.mjs +3 -0
- package/dist/array/impl/array-utils-size.mjs.map +1 -1
- package/dist/array/impl/array-utils-slice-clamped.d.mts +2 -0
- package/dist/array/impl/array-utils-slice-clamped.d.mts.map +1 -1
- package/dist/array/impl/array-utils-slice-clamped.mjs.map +1 -1
- package/dist/array/impl/array-utils-slicing.d.mts +15 -0
- package/dist/array/impl/array-utils-slicing.d.mts.map +1 -1
- package/dist/array/impl/array-utils-slicing.mjs +7 -0
- package/dist/array/impl/array-utils-slicing.mjs.map +1 -1
- package/dist/array/impl/array-utils-transformation.d.mts +27 -0
- package/dist/array/impl/array-utils-transformation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-transformation.mjs +7 -0
- package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
- package/dist/array/impl/array-utils-validation.d.mts +17 -0
- package/dist/array/impl/array-utils-validation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-validation.mjs +11 -0
- package/dist/array/impl/array-utils-validation.mjs.map +1 -1
- package/dist/collections/imap-mapped.mjs +1 -0
- package/dist/collections/imap-mapped.mjs.map +1 -1
- package/dist/collections/imap.d.mts +20 -0
- package/dist/collections/imap.d.mts.map +1 -1
- package/dist/collections/imap.mjs +3 -0
- package/dist/collections/imap.mjs.map +1 -1
- package/dist/collections/iset-mapped.d.mts +27 -0
- package/dist/collections/iset-mapped.d.mts.map +1 -1
- package/dist/collections/iset-mapped.mjs +7 -0
- package/dist/collections/iset-mapped.mjs.map +1 -1
- package/dist/collections/iset.d.mts +29 -0
- package/dist/collections/iset.d.mts.map +1 -1
- package/dist/collections/iset.mjs +7 -0
- package/dist/collections/iset.mjs.map +1 -1
- package/dist/collections/queue.d.mts +40 -0
- package/dist/collections/queue.d.mts.map +1 -1
- package/dist/collections/queue.mjs +9 -0
- package/dist/collections/queue.mjs.map +1 -1
- package/dist/collections/stack.d.mts +35 -0
- package/dist/collections/stack.d.mts.map +1 -1
- package/dist/collections/stack.mjs +8 -0
- package/dist/collections/stack.mjs.map +1 -1
- package/dist/entry-point.mjs +1 -1
- package/dist/functional/match.d.mts.map +1 -1
- package/dist/functional/match.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-expect-to-be.d.mts +1 -0
- package/dist/functional/optional/impl/optional-expect-to-be.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-expect-to-be.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-filter.d.mts +3 -0
- package/dist/functional/optional/impl/optional-filter.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-filter.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-flat-map.d.mts +2 -0
- package/dist/functional/optional/impl/optional-flat-map.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-flat-map.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-from-nullable.d.mts +2 -0
- package/dist/functional/optional/impl/optional-from-nullable.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-from-nullable.mjs +2 -0
- package/dist/functional/optional/impl/optional-from-nullable.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-is-optional.d.mts +2 -0
- package/dist/functional/optional/impl/optional-is-optional.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-is-optional.mjs +2 -0
- package/dist/functional/optional/impl/optional-is-optional.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-is-some.d.mts +1 -0
- package/dist/functional/optional/impl/optional-is-some.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-is-some.mjs +1 -0
- package/dist/functional/optional/impl/optional-is-some.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-map.d.mts +2 -0
- package/dist/functional/optional/impl/optional-map.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-map.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-none.d.mts +2 -0
- package/dist/functional/optional/impl/optional-none.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-none.mjs +2 -0
- package/dist/functional/optional/impl/optional-none.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-or-else.d.mts +4 -0
- package/dist/functional/optional/impl/optional-or-else.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-or-else.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-some.d.mts +3 -1
- package/dist/functional/optional/impl/optional-some.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-some.mjs +2 -0
- package/dist/functional/optional/impl/optional-some.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-to-nullable.d.mts +2 -0
- package/dist/functional/optional/impl/optional-to-nullable.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-to-nullable.mjs +2 -0
- package/dist/functional/optional/impl/optional-to-nullable.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap-or.d.mts +3 -0
- package/dist/functional/optional/impl/optional-unwrap-or.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap-or.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap-throw.d.mts +1 -0
- package/dist/functional/optional/impl/optional-unwrap-throw.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap-throw.mjs +1 -0
- package/dist/functional/optional/impl/optional-unwrap-throw.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap.d.mts +2 -0
- package/dist/functional/optional/impl/optional-unwrap.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-zip.d.mts +2 -0
- package/dist/functional/optional/impl/optional-zip.d.mts.map +1 -1
- package/dist/functional/optional/impl/optional-zip.mjs +2 -0
- package/dist/functional/optional/impl/optional-zip.mjs.map +1 -1
- package/dist/functional/result/impl/result-err.d.mts +3 -1
- package/dist/functional/result/impl/result-err.d.mts.map +1 -1
- package/dist/functional/result/impl/result-err.mjs +2 -0
- package/dist/functional/result/impl/result-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-expect-to-be.d.mts +1 -0
- package/dist/functional/result/impl/result-expect-to-be.d.mts.map +1 -1
- package/dist/functional/result/impl/result-expect-to-be.mjs.map +1 -1
- package/dist/functional/result/impl/result-flat-map.d.mts +5 -0
- package/dist/functional/result/impl/result-flat-map.d.mts.map +1 -1
- package/dist/functional/result/impl/result-flat-map.mjs.map +1 -1
- package/dist/functional/result/impl/result-fold.d.mts +4 -0
- package/dist/functional/result/impl/result-fold.d.mts.map +1 -1
- package/dist/functional/result/impl/result-fold.mjs.map +1 -1
- package/dist/functional/result/impl/result-from-promise.d.mts +3 -0
- package/dist/functional/result/impl/result-from-promise.d.mts.map +1 -1
- package/dist/functional/result/impl/result-from-promise.mjs +3 -0
- package/dist/functional/result/impl/result-from-promise.mjs.map +1 -1
- package/dist/functional/result/impl/result-from-throwable.d.mts +2 -0
- package/dist/functional/result/impl/result-from-throwable.d.mts.map +1 -1
- package/dist/functional/result/impl/result-from-throwable.mjs +4 -1
- package/dist/functional/result/impl/result-from-throwable.mjs.map +1 -1
- package/dist/functional/result/impl/result-is-err.d.mts +2 -0
- package/dist/functional/result/impl/result-is-err.d.mts.map +1 -1
- package/dist/functional/result/impl/result-is-err.mjs +2 -0
- package/dist/functional/result/impl/result-is-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-is-ok.d.mts +2 -0
- package/dist/functional/result/impl/result-is-ok.d.mts.map +1 -1
- package/dist/functional/result/impl/result-is-ok.mjs +2 -0
- package/dist/functional/result/impl/result-is-ok.mjs.map +1 -1
- package/dist/functional/result/impl/result-is-result.d.mts +4 -0
- package/dist/functional/result/impl/result-is-result.d.mts.map +1 -1
- package/dist/functional/result/impl/result-is-result.mjs +4 -0
- package/dist/functional/result/impl/result-is-result.mjs.map +1 -1
- package/dist/functional/result/impl/result-map-err.d.mts +3 -0
- package/dist/functional/result/impl/result-map-err.d.mts.map +1 -1
- package/dist/functional/result/impl/result-map-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-map.d.mts +4 -0
- package/dist/functional/result/impl/result-map.d.mts.map +1 -1
- package/dist/functional/result/impl/result-map.mjs.map +1 -1
- package/dist/functional/result/impl/result-ok.d.mts +3 -1
- package/dist/functional/result/impl/result-ok.d.mts.map +1 -1
- package/dist/functional/result/impl/result-ok.mjs +2 -0
- package/dist/functional/result/impl/result-ok.mjs.map +1 -1
- package/dist/functional/result/impl/result-or-else.d.mts +4 -0
- package/dist/functional/result/impl/result-or-else.d.mts.map +1 -1
- package/dist/functional/result/impl/result-or-else.mjs.map +1 -1
- package/dist/functional/result/impl/result-swap.d.mts +2 -0
- package/dist/functional/result/impl/result-swap.d.mts.map +1 -1
- package/dist/functional/result/impl/result-swap.mjs +2 -0
- package/dist/functional/result/impl/result-swap.mjs.map +1 -1
- package/dist/functional/result/impl/result-to-optional.d.mts +2 -0
- package/dist/functional/result/impl/result-to-optional.d.mts.map +1 -1
- package/dist/functional/result/impl/result-to-optional.mjs +2 -0
- package/dist/functional/result/impl/result-to-optional.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err-or.d.mts +3 -0
- package/dist/functional/result/impl/result-unwrap-err-or.d.mts.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err-or.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err-throw.d.mts +2 -0
- package/dist/functional/result/impl/result-unwrap-err-throw.d.mts.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err-throw.mjs +2 -0
- package/dist/functional/result/impl/result-unwrap-err-throw.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err.d.mts +1 -0
- package/dist/functional/result/impl/result-unwrap-err.d.mts.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err.mjs +1 -0
- package/dist/functional/result/impl/result-unwrap-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-ok-or.d.mts +3 -0
- package/dist/functional/result/impl/result-unwrap-ok-or.d.mts.map +1 -1
- package/dist/functional/result/impl/result-unwrap-ok-or.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-ok.d.mts +1 -0
- package/dist/functional/result/impl/result-unwrap-ok.d.mts.map +1 -1
- package/dist/functional/result/impl/result-unwrap-ok.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-throw.d.mts +2 -0
- package/dist/functional/result/impl/result-unwrap-throw.d.mts.map +1 -1
- package/dist/functional/result/impl/result-unwrap-throw.mjs +2 -0
- package/dist/functional/result/impl/result-unwrap-throw.mjs.map +1 -1
- package/dist/functional/result/impl/result-zip.d.mts +3 -1
- package/dist/functional/result/impl/result-zip.d.mts.map +1 -1
- package/dist/functional/result/impl/result-zip.mjs +3 -1
- package/dist/functional/result/impl/result-zip.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-err.d.mts +2 -1
- package/dist/functional/ternary-result/impl/ternary-result-err.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-err.mjs +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-err.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.d.mts +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.d.mts +4 -0
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-fold.d.mts +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-fold.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-fold.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +4 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts +4 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs +4 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-ternary-result.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.d.mts +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map-err.d.mts +3 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-err.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.d.mts +3 -0
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map.d.mts +6 -0
- package/dist/functional/ternary-result/impl/ternary-result-map.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-ok.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-ok.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-or-else.d.mts +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-or-else.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.d.mts +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.d.mts +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-or.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.d.mts +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.d.mts +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-err.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.d.mts +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.d.mts +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.d.mts +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.d.mts +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs +1 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.d.mts +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs +2 -0
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-warn.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-warn.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts +4 -0
- package/dist/functional/ternary-result/impl/ternary-result-zip.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-zip.mjs +4 -0
- package/dist/functional/ternary-result/impl/ternary-result-zip.mjs.map +1 -1
- package/dist/globals.d.mts +10 -0
- package/dist/guard/index.mjs +1 -1
- package/dist/guard/is-record.d.mts +31 -0
- package/dist/guard/is-record.d.mts.map +1 -1
- package/dist/guard/is-record.mjs +32 -1
- package/dist/guard/is-record.mjs.map +1 -1
- package/dist/guard/is-type.d.mts +3 -0
- package/dist/guard/is-type.d.mts.map +1 -1
- package/dist/guard/is-type.mjs +3 -0
- package/dist/guard/is-type.mjs.map +1 -1
- package/dist/guard/key-is-in.d.mts +1 -0
- package/dist/guard/key-is-in.d.mts.map +1 -1
- package/dist/guard/key-is-in.mjs +1 -0
- package/dist/guard/key-is-in.mjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/iterator/range.d.mts +4 -0
- package/dist/iterator/range.d.mts.map +1 -1
- package/dist/iterator/range.mjs +1 -0
- package/dist/iterator/range.mjs.map +1 -1
- package/dist/json/json.d.mts +21 -0
- package/dist/json/json.d.mts.map +1 -1
- package/dist/json/json.mjs +22 -0
- package/dist/json/json.mjs.map +1 -1
- package/dist/number/branded-types/int.d.mts +14 -0
- package/dist/number/branded-types/int.d.mts.map +1 -1
- package/dist/number/branded-types/int.mjs +14 -0
- package/dist/number/branded-types/int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-safe-int.mjs +2 -2
- package/dist/number/branded-types/positive-int.d.mts +14 -0
- package/dist/number/branded-types/positive-int.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int.mjs +14 -0
- package/dist/number/branded-types/positive-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-safe-int.d.mts +21 -0
- package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/positive-safe-int.mjs +22 -1
- package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/safe-int.d.mts +21 -0
- package/dist/number/branded-types/safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/safe-int.mjs +23 -2
- 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/uint.d.mts +12 -0
- package/dist/number/branded-types/uint.d.mts.map +1 -1
- package/dist/number/branded-types/uint.mjs +12 -0
- package/dist/number/branded-types/uint.mjs.map +1 -1
- package/dist/number/num.d.mts +9 -0
- package/dist/number/num.d.mts.map +1 -1
- package/dist/number/num.mjs +8 -1
- package/dist/number/num.mjs.map +1 -1
- package/dist/number/refined-number-utils.d.mts +22 -0
- package/dist/number/refined-number-utils.d.mts.map +1 -1
- package/dist/number/refined-number-utils.mjs +23 -0
- package/dist/number/refined-number-utils.mjs.map +1 -1
- package/dist/object/object.d.mts +9 -0
- package/dist/object/object.d.mts.map +1 -1
- package/dist/object/object.mjs +7 -0
- package/dist/object/object.mjs.map +1 -1
- package/dist/others/map-nullable.mjs.map +1 -1
- package/dist/others/tuple.d.mts +11 -0
- package/dist/others/tuple.d.mts.map +1 -1
- package/dist/others/tuple.mjs +11 -0
- package/dist/others/tuple.mjs.map +1 -1
- package/dist/others/unknown-to-string.d.mts.map +1 -1
- package/dist/others/unknown-to-string.mjs +2 -1
- package/dist/others/unknown-to-string.mjs.map +1 -1
- package/dist/promise/promise.d.mts +4 -0
- package/dist/promise/promise.d.mts.map +1 -1
- package/dist/promise/promise.mjs +5 -0
- package/dist/promise/promise.mjs.map +1 -1
- package/package.json +20 -24
- package/src/array/impl/array-utils-creation.mts +20 -0
- package/src/array/impl/array-utils-creation.test.mts +71 -0
- package/src/array/impl/array-utils-element-access.mts +13 -0
- package/src/array/impl/array-utils-element-access.test.mts +21 -0
- package/src/array/impl/array-utils-iterators.test.mts +17 -0
- package/src/array/impl/array-utils-modification.mts +40 -0
- package/src/array/impl/array-utils-modification.test.mts +75 -0
- package/src/array/impl/array-utils-overload-type-error.test.mts +19 -0
- package/src/array/impl/array-utils-reducing-value.mts +55 -9
- package/src/array/impl/array-utils-reducing-value.test.mts +90 -0
- package/src/array/impl/array-utils-search.mts +53 -0
- package/src/array/impl/array-utils-search.test.mts +51 -0
- package/src/array/impl/array-utils-set-op.mts +19 -0
- package/src/array/impl/array-utils-set-op.test.mts +116 -0
- package/src/array/impl/array-utils-size.mts +3 -0
- package/src/array/impl/array-utils-size.test.mts +1 -0
- package/src/array/impl/array-utils-slice-clamped.mts +7 -0
- package/src/array/impl/array-utils-slice-clamped.test.mts +20 -0
- package/src/array/impl/array-utils-slicing.mts +27 -0
- package/src/array/impl/array-utils-slicing.test.mts +57 -0
- package/src/array/impl/array-utils-transformation.mts +58 -0
- package/src/array/impl/array-utils-transformation.test.mts +113 -1
- package/src/array/impl/array-utils-validation.mts +23 -0
- package/src/array/impl/array-utils-validation.test.mts +96 -0
- package/src/array/impl/array.test.mts +12 -0
- package/src/collections/imap-mapped.mts +11 -0
- package/src/collections/imap-mapped.test.mts +70 -0
- package/src/collections/imap.mts +32 -0
- package/src/collections/imap.test.mts +106 -0
- package/src/collections/iset-mapped.mts +35 -0
- package/src/collections/iset-mapped.test.mts +111 -0
- package/src/collections/iset.mts +34 -0
- package/src/collections/iset.test.mts +193 -0
- package/src/collections/queue.mts +53 -0
- package/src/collections/queue.test.mts +32 -0
- package/src/collections/stack.mts +42 -0
- package/src/collections/stack.test.mts +44 -0
- package/src/functional/match.mts +16 -0
- package/src/functional/match.test.mts +2 -0
- package/src/functional/optional/impl/optional-expect-to-be.mts +3 -0
- package/src/functional/optional/impl/optional-filter.mts +6 -0
- package/src/functional/optional/impl/optional-flat-map.mts +4 -0
- package/src/functional/optional/impl/optional-from-nullable.mts +2 -0
- package/src/functional/optional/impl/optional-is-optional.mts +2 -0
- package/src/functional/optional/impl/optional-is-some.mts +1 -0
- package/src/functional/optional/impl/optional-map.mts +5 -0
- package/src/functional/optional/impl/optional-none.mts +2 -0
- package/src/functional/optional/impl/optional-or-else.mts +6 -0
- package/src/functional/optional/impl/optional-some.mts +3 -1
- package/src/functional/optional/impl/optional-to-nullable.mts +2 -0
- package/src/functional/optional/impl/optional-unwrap-or.mts +5 -0
- package/src/functional/optional/impl/optional-unwrap-throw.mts +1 -0
- package/src/functional/optional/impl/optional-unwrap.mts +2 -0
- package/src/functional/optional/impl/optional-zip.mts +2 -0
- package/src/functional/optional.test.mts +73 -0
- package/src/functional/pipe.test.mts +3 -0
- package/src/functional/result/impl/result-err.mts +3 -1
- package/src/functional/result/impl/result-expect-to-be.mts +3 -0
- package/src/functional/result/impl/result-flat-map.mts +7 -0
- package/src/functional/result/impl/result-fold.mts +6 -0
- package/src/functional/result/impl/result-from-promise.mts +3 -0
- package/src/functional/result/impl/result-from-throwable.mts +6 -1
- package/src/functional/result/impl/result-is-err.mts +2 -0
- package/src/functional/result/impl/result-is-ok.mts +2 -0
- package/src/functional/result/impl/result-is-result.mts +4 -0
- package/src/functional/result/impl/result-map-err.mts +5 -0
- package/src/functional/result/impl/result-map.mts +6 -0
- package/src/functional/result/impl/result-ok.mts +3 -1
- package/src/functional/result/impl/result-or-else.mts +6 -0
- package/src/functional/result/impl/result-swap.mts +2 -0
- package/src/functional/result/impl/result-to-optional.mts +2 -0
- package/src/functional/result/impl/result-unwrap-err-or.mts +5 -0
- package/src/functional/result/impl/result-unwrap-err-throw.mts +2 -0
- package/src/functional/result/impl/result-unwrap-err.mts +1 -0
- package/src/functional/result/impl/result-unwrap-ok-or.mts +5 -0
- package/src/functional/result/impl/result-unwrap-ok.mts +2 -0
- package/src/functional/result/impl/result-unwrap-throw.mts +2 -0
- package/src/functional/result/impl/result-zip.mts +3 -1
- package/src/functional/result.test.mts +88 -0
- package/src/functional/ternary-result/impl/ternary-result-err.mts +2 -1
- package/src/functional/ternary-result/impl/ternary-result-expect-to-be.mts +4 -0
- package/src/functional/ternary-result/impl/ternary-result-flat-map.mts +7 -0
- package/src/functional/ternary-result/impl/ternary-result-fold.mts +5 -0
- package/src/functional/ternary-result/impl/ternary-result-from-promise.mts +2 -0
- package/src/functional/ternary-result/impl/ternary-result-from-throwable.mts +5 -1
- package/src/functional/ternary-result/impl/ternary-result-is-ok.mts +1 -0
- package/src/functional/ternary-result/impl/ternary-result-is-ternary-result.mts +4 -0
- package/src/functional/ternary-result/impl/ternary-result-is-warn.mts +1 -0
- package/src/functional/ternary-result/impl/ternary-result-map-err.mts +6 -0
- package/src/functional/ternary-result/impl/ternary-result-map-warn.mts +6 -0
- package/src/functional/ternary-result/impl/ternary-result-map.mts +9 -0
- package/src/functional/ternary-result/impl/ternary-result-ok.mts +1 -1
- package/src/functional/ternary-result/impl/ternary-result-or-else.mts +5 -0
- package/src/functional/ternary-result/impl/ternary-result-to-optional.mts +2 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-err-or.mts +5 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-err-throw.mts +1 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-err.mts +2 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-ok-or.mts +5 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-ok.mts +3 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-throw.mts +1 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-warn-or.mts +5 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mts +1 -0
- package/src/functional/ternary-result/impl/ternary-result-unwrap-warn.mts +2 -0
- package/src/functional/ternary-result/impl/ternary-result-warn.mts +4 -1
- package/src/functional/ternary-result/impl/ternary-result-zip.mts +4 -0
- package/src/functional/ternary-result.test.mts +91 -0
- package/src/globals.d.mts +10 -0
- package/src/guard/has-key.test.mts +9 -0
- package/src/guard/is-non-empty-string.test.mts +20 -0
- package/src/guard/is-non-null-object.test.mts +19 -0
- package/src/guard/is-primitive.test.mts +23 -0
- package/src/guard/is-record.mts +34 -0
- package/src/guard/is-record.test.mts +21 -0
- package/src/guard/is-type.mts +3 -0
- package/src/guard/is-type.test.mts +134 -0
- package/src/guard/key-is-in.mts +1 -0
- package/src/iterator/range.mts +9 -0
- package/src/json/json.mts +29 -0
- package/src/json/json.test.mts +87 -0
- package/src/number/branded-types/finite-number.test.mts +38 -0
- package/src/number/branded-types/int.mts +14 -0
- package/src/number/branded-types/int.test.mts +42 -0
- package/src/number/branded-types/int16.test.mts +47 -0
- package/src/number/branded-types/int32.test.mts +47 -0
- package/src/number/branded-types/non-negative-finite-number.test.mts +40 -0
- package/src/number/branded-types/non-negative-int16.test.mts +43 -0
- package/src/number/branded-types/non-negative-int32.test.mts +43 -0
- package/src/number/branded-types/non-zero-finite-number.test.mts +51 -0
- package/src/number/branded-types/non-zero-int.test.mts +53 -0
- package/src/number/branded-types/non-zero-int16.test.mts +44 -0
- package/src/number/branded-types/non-zero-int32.test.mts +44 -0
- package/src/number/branded-types/non-zero-safe-int.mts +2 -2
- package/src/number/branded-types/non-zero-safe-int.test.mts +62 -0
- package/src/number/branded-types/non-zero-uint16.test.mts +37 -0
- package/src/number/branded-types/non-zero-uint32.test.mts +37 -0
- package/src/number/branded-types/positive-finite-number.test.mts +45 -0
- package/src/number/branded-types/positive-int.mts +14 -0
- package/src/number/branded-types/positive-int.test.mts +47 -0
- package/src/number/branded-types/positive-int16.test.mts +35 -0
- package/src/number/branded-types/positive-int32.test.mts +35 -0
- package/src/number/branded-types/positive-safe-int.mts +22 -1
- package/src/number/branded-types/positive-safe-int.test.mts +49 -0
- package/src/number/branded-types/positive-uint16.test.mts +37 -0
- package/src/number/branded-types/positive-uint32.test.mts +37 -0
- package/src/number/branded-types/safe-int.mts +23 -2
- package/src/number/branded-types/safe-int.test.mts +52 -0
- package/src/number/branded-types/safe-uint.mts +1 -1
- package/src/number/branded-types/safe-uint.test.mts +48 -0
- package/src/number/branded-types/uint.mts +12 -0
- package/src/number/branded-types/uint.test.mts +43 -0
- package/src/number/branded-types/uint16.test.mts +41 -0
- package/src/number/branded-types/uint32.test.mts +41 -0
- package/src/number/enum/int8.test.mts +6 -0
- package/src/number/enum/uint8.test.mts +6 -0
- package/src/number/num.mts +12 -1
- package/src/number/num.test.mts +62 -0
- package/src/number/refined-number-utils.mts +25 -0
- package/src/object/object.mts +15 -0
- package/src/object/object.test.mts +10 -0
- package/src/others/cast-mutable.test.mts +7 -0
- package/src/others/cast-readonly.test.mts +17 -0
- package/src/others/if-then.test.mts +16 -0
- package/src/others/map-nullable.mts +3 -0
- package/src/others/map-nullable.test.mts +27 -0
- package/src/others/memoize-function.test.mts +41 -0
- package/src/others/tuple.mts +11 -0
- package/src/others/unknown-to-string.mts +4 -1
- package/src/others/unknown-to-string.test.mts +10 -0
- package/src/promise/promise.mts +4 -0
- package/src/promise/promise.test.mts +1 -0
package/src/json/json.test.mts
CHANGED
|
@@ -6,18 +6,24 @@ import { Json } from './json.mjs';
|
|
|
6
6
|
describe('parse', () => {
|
|
7
7
|
test('should parse primitive values', () => {
|
|
8
8
|
assert.deepStrictEqual(Json.parse('"hello"'), Result.ok('hello'));
|
|
9
|
+
|
|
9
10
|
assert.deepStrictEqual(Json.parse('42'), Result.ok(42));
|
|
11
|
+
|
|
10
12
|
assert.deepStrictEqual(Json.parse('true'), Result.ok(true));
|
|
13
|
+
|
|
11
14
|
assert.deepStrictEqual(Json.parse('false'), Result.ok(false));
|
|
15
|
+
|
|
12
16
|
assert.deepStrictEqual(Json.parse('null'), Result.ok(null));
|
|
13
17
|
});
|
|
14
18
|
|
|
15
19
|
test('should parse arrays', () => {
|
|
16
20
|
assert.deepStrictEqual(Json.parse('[1,2,3]'), Result.ok([1, 2, 3]));
|
|
21
|
+
|
|
17
22
|
assert.deepStrictEqual(
|
|
18
23
|
Json.parse('["a","b","c"]'),
|
|
19
24
|
Result.ok(['a', 'b', 'c']),
|
|
20
25
|
);
|
|
26
|
+
|
|
21
27
|
assert.deepStrictEqual(
|
|
22
28
|
Json.parse('[1,"two",true,null]'),
|
|
23
29
|
Result.ok([1, 'two', true, null]),
|
|
@@ -29,6 +35,7 @@ describe('parse', () => {
|
|
|
29
35
|
Json.parse('{"a":1,"b":2}'),
|
|
30
36
|
Result.ok({ a: 1, b: 2 }),
|
|
31
37
|
);
|
|
38
|
+
|
|
32
39
|
assert.deepStrictEqual(
|
|
33
40
|
Json.parse('{"name":"test","value":42}'),
|
|
34
41
|
Result.ok({
|
|
@@ -40,6 +47,7 @@ describe('parse', () => {
|
|
|
40
47
|
|
|
41
48
|
test('should parse nested structures', () => {
|
|
42
49
|
const json = '{"level1":{"level2":{"array":[1,2,{"level3":"deep"}]}}}';
|
|
50
|
+
|
|
43
51
|
const expected = {
|
|
44
52
|
level1: {
|
|
45
53
|
level2: {
|
|
@@ -56,6 +64,7 @@ describe('parse', () => {
|
|
|
56
64
|
Json.parse(' { "a" : 1 , "b" : 2 } '),
|
|
57
65
|
Result.ok({ a: 1, b: 2 }),
|
|
58
66
|
);
|
|
67
|
+
|
|
59
68
|
assert.deepStrictEqual(
|
|
60
69
|
Json.parse('\n[\n 1,\n 2,\n 3\n]\n'),
|
|
61
70
|
Result.ok([1, 2, 3]),
|
|
@@ -64,37 +73,53 @@ describe('parse', () => {
|
|
|
64
73
|
|
|
65
74
|
test('should return error for invalid JSON', () => {
|
|
66
75
|
expect(Result.isErr(Json.parse('invalid'))).toBe(true);
|
|
76
|
+
|
|
67
77
|
expect(Result.isErr(Json.parse('{missing quotes: true}'))).toBe(true);
|
|
78
|
+
|
|
68
79
|
expect(Result.isErr(Json.parse('[1,2,]'))).toBe(true); // Trailing comma
|
|
80
|
+
|
|
69
81
|
expect(Result.isErr(Json.parse('undefined'))).toBe(true);
|
|
70
82
|
});
|
|
71
83
|
|
|
72
84
|
test('should return parsed value for valid JSON', () => {
|
|
73
85
|
assert.deepStrictEqual(Json.parse('{"a":1}'), Result.ok({ a: 1 }));
|
|
86
|
+
|
|
74
87
|
assert.deepStrictEqual(Json.parse('[1,2,3]'), Result.ok([1, 2, 3]));
|
|
88
|
+
|
|
75
89
|
assert.deepStrictEqual(Json.parse('"string"'), Result.ok('string'));
|
|
90
|
+
|
|
76
91
|
assert.deepStrictEqual(Json.parse('42'), Result.ok(42));
|
|
92
|
+
|
|
77
93
|
assert.deepStrictEqual(Json.parse('true'), Result.ok(true));
|
|
94
|
+
|
|
78
95
|
assert.deepStrictEqual(Json.parse('null'), Result.ok(null));
|
|
79
96
|
});
|
|
80
97
|
|
|
81
98
|
test('should return error for invalid JSON cases', () => {
|
|
82
99
|
expect(Result.isErr(Json.parse('invalid'))).toBe(true);
|
|
100
|
+
|
|
83
101
|
expect(Result.isErr(Json.parse('{bad json}'))).toBe(true);
|
|
102
|
+
|
|
84
103
|
expect(Result.isErr(Json.parse('[1,2,]'))).toBe(true);
|
|
104
|
+
|
|
85
105
|
expect(Result.isErr(Json.parse('undefined'))).toBe(true);
|
|
106
|
+
|
|
86
107
|
expect(Result.isErr(Json.parse(''))).toBe(true);
|
|
87
108
|
});
|
|
88
109
|
|
|
89
110
|
test('should handle edge cases', () => {
|
|
90
111
|
assert.deepStrictEqual(Json.parse('0'), Result.ok(0));
|
|
112
|
+
|
|
91
113
|
assert.deepStrictEqual(Json.parse('""'), Result.ok(''));
|
|
114
|
+
|
|
92
115
|
assert.deepStrictEqual(Json.parse('[]'), Result.ok([]));
|
|
116
|
+
|
|
93
117
|
assert.deepStrictEqual(Json.parse('{}'), Result.ok({}));
|
|
94
118
|
});
|
|
95
119
|
|
|
96
120
|
test('should not throw errors', () => {
|
|
97
121
|
expect(() => Json.parse('{{{')).not.toThrow();
|
|
122
|
+
|
|
98
123
|
expect(() => Json.parse('null null')).not.toThrow();
|
|
99
124
|
|
|
100
125
|
expect(() => Json.parse(String(undefined))).not.toThrow();
|
|
@@ -105,10 +130,12 @@ describe('parse', () => {
|
|
|
105
130
|
if (typeof value === 'string' && /^\d{4}-\d{2}-\d{2}T/u.test(value)) {
|
|
106
131
|
return new Date(value);
|
|
107
132
|
}
|
|
133
|
+
|
|
108
134
|
return value;
|
|
109
135
|
};
|
|
110
136
|
|
|
111
137
|
const jsonString = '{"name":"test","created":"2023-12-01T10:00:00.000Z"}';
|
|
138
|
+
|
|
112
139
|
const result = Json.parse(jsonString, dateReviver);
|
|
113
140
|
|
|
114
141
|
expect(Result.isOk(result)).toBe(true);
|
|
@@ -120,6 +147,7 @@ describe('parse', () => {
|
|
|
120
147
|
hasKey(result.value, 'created')
|
|
121
148
|
) {
|
|
122
149
|
expect(result.value.name).toBe('test');
|
|
150
|
+
|
|
123
151
|
expect(result.value.created).toBeInstanceOf(Date);
|
|
124
152
|
}
|
|
125
153
|
});
|
|
@@ -129,6 +157,7 @@ describe('parse', () => {
|
|
|
129
157
|
if (key === 'number' && typeof value === 'string') {
|
|
130
158
|
return Number.parseInt(value, 10);
|
|
131
159
|
}
|
|
160
|
+
|
|
132
161
|
return value;
|
|
133
162
|
};
|
|
134
163
|
|
|
@@ -141,6 +170,7 @@ describe('parse', () => {
|
|
|
141
170
|
|
|
142
171
|
if (Result.isOk(result)) {
|
|
143
172
|
expect(result.value).toHaveProperty('number');
|
|
173
|
+
|
|
144
174
|
expect(result.value).toHaveProperty('text');
|
|
145
175
|
|
|
146
176
|
if (
|
|
@@ -149,6 +179,7 @@ describe('parse', () => {
|
|
|
149
179
|
hasKey(result.value, 'text')
|
|
150
180
|
) {
|
|
151
181
|
expect(result.value.number).toBe(42);
|
|
182
|
+
|
|
152
183
|
expect(result.value.text).toBe('hello');
|
|
153
184
|
}
|
|
154
185
|
}
|
|
@@ -158,17 +189,22 @@ describe('parse', () => {
|
|
|
158
189
|
describe('stringify', () => {
|
|
159
190
|
test('should stringify primitive values', () => {
|
|
160
191
|
assert.deepStrictEqual(Json.stringify('hello'), Result.ok('"hello"'));
|
|
192
|
+
|
|
161
193
|
assert.deepStrictEqual(Json.stringify(42), Result.ok('42'));
|
|
194
|
+
|
|
162
195
|
assert.deepStrictEqual(Json.stringify(true), Result.ok('true'));
|
|
196
|
+
|
|
163
197
|
assert.deepStrictEqual(Json.stringify(null), Result.ok('null'));
|
|
164
198
|
});
|
|
165
199
|
|
|
166
200
|
test('should stringify arrays', () => {
|
|
167
201
|
assert.deepStrictEqual(Json.stringify([1, 2, 3]), Result.ok('[1,2,3]'));
|
|
202
|
+
|
|
168
203
|
assert.deepStrictEqual(
|
|
169
204
|
Json.stringify(['a', 'b', 'c']),
|
|
170
205
|
Result.ok('["a","b","c"]'),
|
|
171
206
|
);
|
|
207
|
+
|
|
172
208
|
assert.deepStrictEqual(
|
|
173
209
|
Json.stringify([1, 'two', true, null]),
|
|
174
210
|
Result.ok('[1,"two",true,null]'),
|
|
@@ -180,6 +216,7 @@ describe('stringify', () => {
|
|
|
180
216
|
Json.stringify({ a: 1, b: 2 }),
|
|
181
217
|
Result.ok('{"a":1,"b":2}'),
|
|
182
218
|
);
|
|
219
|
+
|
|
183
220
|
assert.deepStrictEqual(
|
|
184
221
|
Json.stringify({ name: 'test', value: 42 }),
|
|
185
222
|
Result.ok('{"name":"test","value":42}'),
|
|
@@ -203,6 +240,7 @@ describe('stringify', () => {
|
|
|
203
240
|
|
|
204
241
|
test('should handle empty structures', () => {
|
|
205
242
|
assert.deepStrictEqual(Json.stringify({}), Result.ok('{}'));
|
|
243
|
+
|
|
206
244
|
assert.deepStrictEqual(Json.stringify([]), Result.ok('[]'));
|
|
207
245
|
});
|
|
208
246
|
|
|
@@ -211,10 +249,12 @@ describe('stringify', () => {
|
|
|
211
249
|
Json.stringify('with "quotes"'),
|
|
212
250
|
Result.ok(String.raw`"with \"quotes\""`),
|
|
213
251
|
);
|
|
252
|
+
|
|
214
253
|
assert.deepStrictEqual(
|
|
215
254
|
Json.stringify('with\nnewline'),
|
|
216
255
|
Result.ok(String.raw`"with\nnewline"`),
|
|
217
256
|
);
|
|
257
|
+
|
|
218
258
|
assert.deepStrictEqual(
|
|
219
259
|
Json.stringify('with\ttab'),
|
|
220
260
|
Result.ok(String.raw`"with\ttab"`),
|
|
@@ -223,19 +263,26 @@ describe('stringify', () => {
|
|
|
223
263
|
|
|
224
264
|
test('should return stringified value for valid JSON values', () => {
|
|
225
265
|
assert.deepStrictEqual(Json.stringify({ a: 1 }), Result.ok('{"a":1}'));
|
|
266
|
+
|
|
226
267
|
assert.deepStrictEqual(Json.stringify([1, 2, 3]), Result.ok('[1,2,3]'));
|
|
268
|
+
|
|
227
269
|
assert.deepStrictEqual(Json.stringify('string'), Result.ok('"string"'));
|
|
270
|
+
|
|
228
271
|
assert.deepStrictEqual(Json.stringify(42), Result.ok('42'));
|
|
272
|
+
|
|
229
273
|
assert.deepStrictEqual(Json.stringify(true), Result.ok('true'));
|
|
274
|
+
|
|
230
275
|
assert.deepStrictEqual(Json.stringify(null), Result.ok('null'));
|
|
231
276
|
});
|
|
232
277
|
|
|
233
278
|
test('should handle non-serializable values', () => {
|
|
234
279
|
assert.deepStrictEqual(Json.stringify(undefined), Result.ok(undefined));
|
|
280
|
+
|
|
235
281
|
assert.deepStrictEqual(
|
|
236
282
|
Json.stringify(Symbol('test')),
|
|
237
283
|
Result.ok(undefined),
|
|
238
284
|
);
|
|
285
|
+
|
|
239
286
|
assert.deepStrictEqual(
|
|
240
287
|
Json.stringify(() => {}),
|
|
241
288
|
Result.ok(undefined),
|
|
@@ -247,6 +294,7 @@ describe('stringify', () => {
|
|
|
247
294
|
|
|
248
295
|
test('should handle circular references', () => {
|
|
249
296
|
const mut_obj: any = { a: 1 };
|
|
297
|
+
|
|
250
298
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
|
|
251
299
|
mut_obj.circular = mut_obj;
|
|
252
300
|
|
|
@@ -275,9 +323,11 @@ describe('stringify', () => {
|
|
|
275
323
|
|
|
276
324
|
test('should not throw errors', () => {
|
|
277
325
|
const mut_circularArray: any[] = [];
|
|
326
|
+
|
|
278
327
|
mut_circularArray.push(mut_circularArray);
|
|
279
328
|
|
|
280
329
|
expect(() => Json.stringify(mut_circularArray)).not.toThrow();
|
|
330
|
+
|
|
281
331
|
expect(() => Json.stringify({ fn: () => {} })).not.toThrow();
|
|
282
332
|
});
|
|
283
333
|
|
|
@@ -290,6 +340,7 @@ describe('stringify', () => {
|
|
|
290
340
|
|
|
291
341
|
const secureReplacer = (key: string, value: unknown): unknown => {
|
|
292
342
|
if (key === 'password') return '[REDACTED]';
|
|
343
|
+
|
|
293
344
|
return value;
|
|
294
345
|
};
|
|
295
346
|
|
|
@@ -299,30 +350,35 @@ describe('stringify', () => {
|
|
|
299
350
|
|
|
300
351
|
if (Result.isOk(result)) {
|
|
301
352
|
expect(result.value).toContain('[REDACTED]');
|
|
353
|
+
|
|
302
354
|
expect(result.value).not.toContain('secret123');
|
|
303
355
|
}
|
|
304
356
|
});
|
|
305
357
|
|
|
306
358
|
test('should format output with space parameter (number)', () => {
|
|
307
359
|
const data = { a: 1, b: 2 };
|
|
360
|
+
|
|
308
361
|
const result = Json.stringify(data, undefined, 2);
|
|
309
362
|
|
|
310
363
|
expect(Result.isOk(result)).toBe(true);
|
|
311
364
|
|
|
312
365
|
if (Result.isOk(result)) {
|
|
313
366
|
expect(result.value).toContain('\n');
|
|
367
|
+
|
|
314
368
|
expect(result.value).toContain(' '); // 2 spaces indentation
|
|
315
369
|
}
|
|
316
370
|
});
|
|
317
371
|
|
|
318
372
|
test('should format output with space parameter (string)', () => {
|
|
319
373
|
const data = { a: 1, b: 2 };
|
|
374
|
+
|
|
320
375
|
const result = Json.stringify(data, undefined, '\t');
|
|
321
376
|
|
|
322
377
|
expect(Result.isOk(result)).toBe(true);
|
|
323
378
|
|
|
324
379
|
if (Result.isOk(result)) {
|
|
325
380
|
expect(result.value).toContain('\n');
|
|
381
|
+
|
|
326
382
|
expect(result.value).toContain('\t'); // tab indentation
|
|
327
383
|
}
|
|
328
384
|
});
|
|
@@ -354,6 +410,7 @@ describe('stringifySelected', () => {
|
|
|
354
410
|
});
|
|
355
411
|
|
|
356
412
|
expect(parsed).not.toHaveProperty('password');
|
|
413
|
+
|
|
357
414
|
expect(parsed).not.toHaveProperty('lastLogin');
|
|
358
415
|
}
|
|
359
416
|
});
|
|
@@ -379,9 +436,12 @@ describe('stringifySelected', () => {
|
|
|
379
436
|
|
|
380
437
|
if (Result.isOk(result)) {
|
|
381
438
|
assert(isString(result.value));
|
|
439
|
+
|
|
382
440
|
const parsed: unknown = JSON.parse(result.value);
|
|
441
|
+
|
|
383
442
|
if (isRecord(parsed) && hasKey(parsed, 'users')) {
|
|
384
443
|
expect(isRecord(parsed.users)).toBe(false);
|
|
444
|
+
|
|
385
445
|
expect(parsed.users).toHaveLength(2);
|
|
386
446
|
|
|
387
447
|
if (Arr.isArray(parsed.users)) {
|
|
@@ -389,10 +449,12 @@ describe('stringifySelected', () => {
|
|
|
389
449
|
|
|
390
450
|
expect(parsed.users[0]).not.toHaveProperty('secret');
|
|
391
451
|
}
|
|
452
|
+
|
|
392
453
|
if (isRecord(parsed) && hasKey(parsed, 'metadata')) {
|
|
393
454
|
assert.deepStrictEqual(parsed.metadata, { total: 2 });
|
|
394
455
|
|
|
395
456
|
expect(parsed.metadata).not.toHaveProperty('page');
|
|
457
|
+
|
|
396
458
|
expect(parsed.metadata).not.toHaveProperty('internal');
|
|
397
459
|
}
|
|
398
460
|
}
|
|
@@ -412,29 +474,34 @@ describe('stringifySelected', () => {
|
|
|
412
474
|
|
|
413
475
|
if (Result.isOk(result)) {
|
|
414
476
|
assert(isString(result.value));
|
|
477
|
+
|
|
415
478
|
const parsed: unknown = JSON.parse(result.value);
|
|
416
479
|
|
|
417
480
|
// Note: stringifySelected works with JSON.stringify's replacer parameter
|
|
418
481
|
// which may not work as expected with arrays
|
|
419
482
|
expect(Array.isArray(parsed)).toBe(true);
|
|
483
|
+
|
|
420
484
|
expect(parsed).toHaveLength(3);
|
|
421
485
|
}
|
|
422
486
|
});
|
|
423
487
|
|
|
424
488
|
test('should handle formatting with space parameter', () => {
|
|
425
489
|
const data = { a: 1, b: { c: 2 } };
|
|
490
|
+
|
|
426
491
|
const result = Json.stringifySelected(data, ['a', 'b', 'c'], 2);
|
|
427
492
|
|
|
428
493
|
expect(Result.isOk(result)).toBe(true);
|
|
429
494
|
|
|
430
495
|
if (Result.isOk(result)) {
|
|
431
496
|
expect(result.value).toContain('\n');
|
|
497
|
+
|
|
432
498
|
expect(result.value).toContain(' ');
|
|
433
499
|
}
|
|
434
500
|
});
|
|
435
501
|
|
|
436
502
|
test('should handle empty selection array', () => {
|
|
437
503
|
const data = { a: 1, b: 2, c: 3 };
|
|
504
|
+
|
|
438
505
|
const result = Json.stringifySelected(data, []);
|
|
439
506
|
|
|
440
507
|
expect(Result.isOk(result)).toBe(true);
|
|
@@ -446,12 +513,14 @@ describe('stringifySelected', () => {
|
|
|
446
513
|
|
|
447
514
|
test('should handle undefined properties parameter', () => {
|
|
448
515
|
const data = { a: 1, b: 2 };
|
|
516
|
+
|
|
449
517
|
const result = Json.stringifySelected(data, undefined);
|
|
450
518
|
|
|
451
519
|
expect(Result.isOk(result)).toBe(true);
|
|
452
520
|
|
|
453
521
|
if (Result.isOk(result)) {
|
|
454
522
|
assert(isString(result.value));
|
|
523
|
+
|
|
455
524
|
const parsed: unknown = JSON.parse(result.value);
|
|
456
525
|
|
|
457
526
|
assert.deepStrictEqual(parsed, { a: 1, b: 2 });
|
|
@@ -460,7 +529,9 @@ describe('stringifySelected', () => {
|
|
|
460
529
|
|
|
461
530
|
test('should handle circular references with error', () => {
|
|
462
531
|
type CircularType = { name: string; self?: CircularType };
|
|
532
|
+
|
|
463
533
|
const mut_circular: CircularType = { name: 'test' };
|
|
534
|
+
|
|
464
535
|
mut_circular.self = mut_circular;
|
|
465
536
|
|
|
466
537
|
const result = Json.stringifySelected(mut_circular, ['name', 'self']);
|
|
@@ -517,7 +588,9 @@ describe('stringifySortedKey', () => {
|
|
|
517
588
|
|
|
518
589
|
if (Result.isOk(result)) {
|
|
519
590
|
assert(isString(result.value));
|
|
591
|
+
|
|
520
592
|
const parsed: unknown = JSON.parse(result.value);
|
|
593
|
+
|
|
521
594
|
if (isRecord(parsed)) {
|
|
522
595
|
const keys = Object.keys(parsed);
|
|
523
596
|
|
|
@@ -557,6 +630,7 @@ describe('stringifySortedKey', () => {
|
|
|
557
630
|
|
|
558
631
|
if (Result.isOk(result)) {
|
|
559
632
|
assert(isString(result.value));
|
|
633
|
+
|
|
560
634
|
const parsed: unknown = JSON.parse(result.value);
|
|
561
635
|
|
|
562
636
|
if (isRecord(parsed)) {
|
|
@@ -583,6 +657,7 @@ describe('stringifySortedKey', () => {
|
|
|
583
657
|
Arr.isNonEmpty(parsed.users)
|
|
584
658
|
) {
|
|
585
659
|
const firstUser = parsed.users[0];
|
|
660
|
+
|
|
586
661
|
if (isRecord(firstUser)) {
|
|
587
662
|
const userKeys = Object.keys(firstUser);
|
|
588
663
|
|
|
@@ -595,25 +670,31 @@ describe('stringifySortedKey', () => {
|
|
|
595
670
|
|
|
596
671
|
test('should handle formatting with space parameter', () => {
|
|
597
672
|
const obj = { b: 2, a: 1 };
|
|
673
|
+
|
|
598
674
|
const result = Json.stringifySortedKey(obj, 2);
|
|
599
675
|
|
|
600
676
|
expect(Result.isOk(result)).toBe(true);
|
|
601
677
|
|
|
602
678
|
if (Result.isOk(result)) {
|
|
603
679
|
expect(result.value).toContain('\n');
|
|
680
|
+
|
|
604
681
|
expect(result.value).toContain(' ');
|
|
682
|
+
|
|
605
683
|
expect(result.value).toMatch(/\{\s+"a": 1,\s+"b": 2\s+\}/u);
|
|
606
684
|
}
|
|
607
685
|
});
|
|
608
686
|
|
|
609
687
|
test('should produce deterministic output', () => {
|
|
610
688
|
const obj1 = { c: 3, a: 1, b: 2 };
|
|
689
|
+
|
|
611
690
|
const obj2 = { b: 2, a: 1, c: 3 };
|
|
612
691
|
|
|
613
692
|
const result1 = Json.stringifySortedKey(obj1);
|
|
693
|
+
|
|
614
694
|
const result2 = Json.stringifySortedKey(obj2);
|
|
615
695
|
|
|
616
696
|
expect(Result.isOk(result1)).toBe(true);
|
|
697
|
+
|
|
617
698
|
expect(Result.isOk(result2)).toBe(true);
|
|
618
699
|
|
|
619
700
|
if (Result.isOk(result1) && Result.isOk(result2)) {
|
|
@@ -627,10 +708,12 @@ describe('stringifySortedKey', () => {
|
|
|
627
708
|
normal: string;
|
|
628
709
|
circular: { self?: CircularObj };
|
|
629
710
|
};
|
|
711
|
+
|
|
630
712
|
const mut_problematicObj: CircularObj = {
|
|
631
713
|
normal: 'value',
|
|
632
714
|
circular: {},
|
|
633
715
|
};
|
|
716
|
+
|
|
634
717
|
mut_problematicObj.circular.self = mut_problematicObj;
|
|
635
718
|
|
|
636
719
|
const result = Json.stringifySortedKey(mut_problematicObj);
|
|
@@ -676,9 +759,12 @@ describe('stringifySortedKey', () => {
|
|
|
676
759
|
|
|
677
760
|
if (Result.isOk(result)) {
|
|
678
761
|
assert(isString(result.value));
|
|
762
|
+
|
|
679
763
|
const parsed: unknown = JSON.parse(result.value);
|
|
764
|
+
|
|
680
765
|
if (isRecord(parsed) && hasKey(parsed, 'level1')) {
|
|
681
766
|
const level1 = parsed.level1;
|
|
767
|
+
|
|
682
768
|
if (isRecord(level1)) {
|
|
683
769
|
assert.deepStrictEqual(Object.keys(level1), ['a', 'z']);
|
|
684
770
|
|
|
@@ -688,6 +774,7 @@ describe('stringifySortedKey', () => {
|
|
|
688
774
|
hasKey(level1.a, 'nested')
|
|
689
775
|
) {
|
|
690
776
|
const nested = level1.a.nested;
|
|
777
|
+
|
|
691
778
|
if (isRecord(nested)) {
|
|
692
779
|
assert.deepStrictEqual(Object.keys(nested), ['x', 'y']);
|
|
693
780
|
}
|
|
@@ -7,23 +7,33 @@ describe('FiniteNumber test', () => {
|
|
|
7
7
|
describe(asFiniteNumber, () => {
|
|
8
8
|
test('accepts valid finite numbers', () => {
|
|
9
9
|
expect(() => asFiniteNumber(0)).not.toThrow();
|
|
10
|
+
|
|
10
11
|
expect(() => asFiniteNumber(1)).not.toThrow();
|
|
12
|
+
|
|
11
13
|
expect(() => asFiniteNumber(-1)).not.toThrow();
|
|
14
|
+
|
|
12
15
|
expect(() => asFiniteNumber(3.14)).not.toThrow();
|
|
16
|
+
|
|
13
17
|
expect(() => asFiniteNumber(-2.5)).not.toThrow();
|
|
18
|
+
|
|
14
19
|
expect(() => asFiniteNumber(Number.MAX_VALUE)).not.toThrow();
|
|
20
|
+
|
|
15
21
|
expect(() => asFiniteNumber(-Number.MAX_VALUE)).not.toThrow();
|
|
16
22
|
});
|
|
17
23
|
|
|
18
24
|
test('rejects non-finite numbers', () => {
|
|
19
25
|
expect(() => asFiniteNumber(Number.NaN)).toThrow(TypeError);
|
|
26
|
+
|
|
20
27
|
expect(() => asFiniteNumber(Number.POSITIVE_INFINITY)).toThrow(TypeError);
|
|
28
|
+
|
|
21
29
|
expect(() => asFiniteNumber(Number.NEGATIVE_INFINITY)).toThrow(TypeError);
|
|
22
30
|
});
|
|
23
31
|
|
|
24
32
|
test('returns the same value for valid inputs', () => {
|
|
25
33
|
expect(asFiniteNumber(5.5)).toBe(5.5);
|
|
34
|
+
|
|
26
35
|
expect(asFiniteNumber(-10)).toBe(-10);
|
|
36
|
+
|
|
27
37
|
expect(asFiniteNumber(0)).toBe(0);
|
|
28
38
|
});
|
|
29
39
|
|
|
@@ -44,70 +54,95 @@ describe('FiniteNumber test', () => {
|
|
|
44
54
|
describe('FiniteNumber.is', () => {
|
|
45
55
|
test('correctly identifies finite numbers', () => {
|
|
46
56
|
expect(FiniteNumber.is(0)).toBe(true);
|
|
57
|
+
|
|
47
58
|
expect(FiniteNumber.is(1)).toBe(true);
|
|
59
|
+
|
|
48
60
|
expect(FiniteNumber.is(-1)).toBe(true);
|
|
61
|
+
|
|
49
62
|
expect(FiniteNumber.is(3.14)).toBe(true);
|
|
63
|
+
|
|
50
64
|
expect(FiniteNumber.is(-2.5)).toBe(true);
|
|
65
|
+
|
|
51
66
|
expect(FiniteNumber.is(Number.MAX_VALUE)).toBe(true);
|
|
67
|
+
|
|
52
68
|
expect(FiniteNumber.is(-Number.MAX_VALUE)).toBe(true);
|
|
53
69
|
});
|
|
54
70
|
|
|
55
71
|
test('correctly identifies non-finite numbers', () => {
|
|
56
72
|
expect(FiniteNumber.is(Number.NaN)).toBe(false);
|
|
73
|
+
|
|
57
74
|
expect(FiniteNumber.is(Number.POSITIVE_INFINITY)).toBe(false);
|
|
75
|
+
|
|
58
76
|
expect(FiniteNumber.is(Number.NEGATIVE_INFINITY)).toBe(false);
|
|
59
77
|
});
|
|
60
78
|
});
|
|
61
79
|
|
|
62
80
|
describe('mathematical operations', () => {
|
|
63
81
|
const a = asFiniteNumber(5.5);
|
|
82
|
+
|
|
64
83
|
const b = asFiniteNumber(2.5);
|
|
84
|
+
|
|
65
85
|
const c = asFiniteNumber(-3.5);
|
|
66
86
|
|
|
67
87
|
test('abs', () => {
|
|
68
88
|
expect(FiniteNumber.abs(a)).toBe(5.5);
|
|
89
|
+
|
|
69
90
|
expect(FiniteNumber.abs(c)).toBe(3.5);
|
|
91
|
+
|
|
70
92
|
expect(FiniteNumber.abs(asFiniteNumber(0))).toBe(0);
|
|
71
93
|
});
|
|
72
94
|
|
|
73
95
|
test('min and max', () => {
|
|
74
96
|
expect(FiniteNumber.min(a, b)).toBe(2.5);
|
|
97
|
+
|
|
75
98
|
expect(FiniteNumber.max(a, b)).toBe(5.5);
|
|
99
|
+
|
|
76
100
|
expect(FiniteNumber.min(a, c)).toBe(-3.5);
|
|
101
|
+
|
|
77
102
|
expect(FiniteNumber.max(a, c)).toBe(5.5);
|
|
78
103
|
});
|
|
79
104
|
|
|
80
105
|
test('floor, ceil, round', () => {
|
|
81
106
|
expect(FiniteNumber.floor(a)).toBe(5);
|
|
107
|
+
|
|
82
108
|
expect(FiniteNumber.ceil(a)).toBe(6);
|
|
109
|
+
|
|
83
110
|
expect(FiniteNumber.round(a)).toBe(6);
|
|
111
|
+
|
|
84
112
|
expect(FiniteNumber.floor(c)).toBe(-4);
|
|
113
|
+
|
|
85
114
|
expect(FiniteNumber.ceil(c)).toBe(-3);
|
|
115
|
+
|
|
86
116
|
expect(FiniteNumber.round(c)).toBe(-3);
|
|
87
117
|
});
|
|
88
118
|
|
|
89
119
|
test('add', () => {
|
|
90
120
|
expect(FiniteNumber.add(a, b)).toBe(8);
|
|
121
|
+
|
|
91
122
|
expect(FiniteNumber.add(a, c)).toBe(2);
|
|
92
123
|
});
|
|
93
124
|
|
|
94
125
|
test('sub', () => {
|
|
95
126
|
expect(FiniteNumber.sub(a, b)).toBe(3);
|
|
127
|
+
|
|
96
128
|
expect(FiniteNumber.sub(a, c)).toBe(9);
|
|
97
129
|
});
|
|
98
130
|
|
|
99
131
|
test('mul', () => {
|
|
100
132
|
expect(FiniteNumber.mul(a, b)).toBe(13.75);
|
|
133
|
+
|
|
101
134
|
expect(FiniteNumber.mul(a, c)).toBe(-19.25);
|
|
102
135
|
});
|
|
103
136
|
|
|
104
137
|
test('div', () => {
|
|
105
138
|
expect(FiniteNumber.div(a, asNonZeroFiniteNumber(2.5))).toBe(2.2);
|
|
139
|
+
|
|
106
140
|
expect(FiniteNumber.div(a, asNonZeroFiniteNumber(2))).toBe(2.75);
|
|
107
141
|
});
|
|
108
142
|
|
|
109
143
|
test('pow', () => {
|
|
110
144
|
expect(FiniteNumber.pow(asFiniteNumber(2), asFiniteNumber(3))).toBe(8);
|
|
145
|
+
|
|
111
146
|
expect(FiniteNumber.pow(asFiniteNumber(3), asFiniteNumber(2))).toBe(9);
|
|
112
147
|
});
|
|
113
148
|
});
|
|
@@ -115,13 +150,16 @@ describe('FiniteNumber test', () => {
|
|
|
115
150
|
describe('random', () => {
|
|
116
151
|
test('generates numbers within specified range', () => {
|
|
117
152
|
const min = asFiniteNumber(-5.5);
|
|
153
|
+
|
|
118
154
|
const max = asFiniteNumber(10.3);
|
|
119
155
|
|
|
120
156
|
for (const _ of range(10)) {
|
|
121
157
|
const result = FiniteNumber.random(min, max);
|
|
122
158
|
|
|
123
159
|
expect(result).toBeGreaterThanOrEqual(min);
|
|
160
|
+
|
|
124
161
|
expect(result).toBeLessThanOrEqual(max);
|
|
162
|
+
|
|
125
163
|
expect(FiniteNumber.is(result)).toBe(true);
|
|
126
164
|
}
|
|
127
165
|
});
|
|
@@ -39,7 +39,9 @@ const {
|
|
|
39
39
|
*
|
|
40
40
|
* ```ts
|
|
41
41
|
* assert.ok(isInt(5));
|
|
42
|
+
*
|
|
42
43
|
* assert.notOk(isInt(5.25));
|
|
44
|
+
*
|
|
43
45
|
* assert.ok(Int.is(-10));
|
|
44
46
|
* ```
|
|
45
47
|
*
|
|
@@ -61,6 +63,7 @@ export const isInt = is;
|
|
|
61
63
|
* const branded = asInt(42);
|
|
62
64
|
*
|
|
63
65
|
* assert(branded === 42);
|
|
66
|
+
*
|
|
64
67
|
* assert.ok(Int.is(branded));
|
|
65
68
|
* ```
|
|
66
69
|
*
|
|
@@ -89,7 +92,9 @@ export const Int = {
|
|
|
89
92
|
*
|
|
90
93
|
* ```ts
|
|
91
94
|
* assert.ok(isInt(5));
|
|
95
|
+
*
|
|
92
96
|
* assert.notOk(isInt(5.25));
|
|
97
|
+
*
|
|
93
98
|
* assert.ok(Int.is(-10));
|
|
94
99
|
* ```
|
|
95
100
|
*
|
|
@@ -110,9 +115,11 @@ export const Int = {
|
|
|
110
115
|
*
|
|
111
116
|
* ```ts
|
|
112
117
|
* const negative = asInt(-12);
|
|
118
|
+
*
|
|
113
119
|
* const absolute = Int.abs(negative);
|
|
114
120
|
*
|
|
115
121
|
* assert(absolute === 12);
|
|
122
|
+
*
|
|
116
123
|
* assert.ok(Int.is(absolute));
|
|
117
124
|
* ```
|
|
118
125
|
*
|
|
@@ -163,10 +170,13 @@ export const Int = {
|
|
|
163
170
|
*
|
|
164
171
|
* ```ts
|
|
165
172
|
* const min = asInt(1);
|
|
173
|
+
*
|
|
166
174
|
* const max = asInt(6);
|
|
175
|
+
*
|
|
167
176
|
* const randomValue = Int.random(min, max);
|
|
168
177
|
*
|
|
169
178
|
* assert.ok(Int.is(randomValue));
|
|
179
|
+
*
|
|
170
180
|
* assert.ok(randomValue >= 1 && randomValue <= 6);
|
|
171
181
|
* ```
|
|
172
182
|
*
|
|
@@ -183,7 +193,9 @@ export const Int = {
|
|
|
183
193
|
*
|
|
184
194
|
* ```ts
|
|
185
195
|
* const base = asInt(2);
|
|
196
|
+
*
|
|
186
197
|
* const exponent = asInt(5);
|
|
198
|
+
*
|
|
187
199
|
* const power = Int.pow(base, exponent);
|
|
188
200
|
*
|
|
189
201
|
* assert(power === 32);
|
|
@@ -256,7 +268,9 @@ export const Int = {
|
|
|
256
268
|
*
|
|
257
269
|
* ```ts
|
|
258
270
|
* const dividend = asInt(17);
|
|
271
|
+
*
|
|
259
272
|
* const divisor = asInt(5);
|
|
273
|
+
*
|
|
260
274
|
* const quotient = Int.div(dividend, divisor);
|
|
261
275
|
*
|
|
262
276
|
* assert(quotient === 3);
|