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/globals.d.mts
CHANGED
|
@@ -23,27 +23,37 @@ type ArgArrayIndexWithNegative<Ar extends readonly unknown[]> =
|
|
|
23
23
|
|
|
24
24
|
declare namespace SizeType {
|
|
25
25
|
type Arr = Uint32;
|
|
26
|
+
|
|
26
27
|
type TypedArray = SafeUint;
|
|
28
|
+
|
|
27
29
|
type Str = SafeUint;
|
|
28
30
|
|
|
29
31
|
type ArrSearchResult = Arr | -1;
|
|
32
|
+
|
|
30
33
|
type TypedArraySearchResult = TypedArray | -1;
|
|
34
|
+
|
|
31
35
|
type StrSearchResult = Str | -1;
|
|
32
36
|
|
|
33
37
|
type ArgArr = WithSmallInt<Arr>;
|
|
38
|
+
|
|
34
39
|
type ArgTypedArray = WithSmallInt<TypedArray>;
|
|
40
|
+
|
|
35
41
|
type ArgStr = WithSmallInt<Str>;
|
|
36
42
|
|
|
37
43
|
type ArgArrWithNegative = WithSmallInt<
|
|
38
44
|
NormalizeBrandUnion<NegativeInt32 | Arr>
|
|
39
45
|
>;
|
|
46
|
+
|
|
40
47
|
type ArgTypedArrayWithNegative = WithSmallInt<SafeInt>;
|
|
48
|
+
|
|
41
49
|
type ArgStrWithNegative = WithSmallInt<SafeInt>;
|
|
42
50
|
|
|
43
51
|
type ArgArrPositive = WithSmallInt<IntersectBrand<PositiveNumber, Arr>>;
|
|
52
|
+
|
|
44
53
|
type ArgTypedArrayPositive = WithSmallInt<
|
|
45
54
|
IntersectBrand<PositiveNumber, TypedArray>
|
|
46
55
|
>;
|
|
56
|
+
|
|
47
57
|
type ArgStrPositive = WithSmallInt<IntersectBrand<PositiveNumber, Str>>;
|
|
48
58
|
}
|
|
49
59
|
|
|
@@ -66,6 +66,7 @@ import { hasKey, type HasKeyReturnType } from './has-key.mjs';
|
|
|
66
66
|
|
|
67
67
|
if (hasKey(obj, 'a')) {
|
|
68
68
|
expectType<typeof obj.a, 0>('=');
|
|
69
|
+
|
|
69
70
|
expectType<typeof obj, Readonly<{ a: 0 }>>('=');
|
|
70
71
|
}
|
|
71
72
|
|
|
@@ -86,7 +87,9 @@ import { hasKey, type HasKeyReturnType } from './has-key.mjs';
|
|
|
86
87
|
|
|
87
88
|
if (hasKey(obj, 'a') && hasKey(obj, 'b')) {
|
|
88
89
|
expectType<typeof obj.a, 1>('=');
|
|
90
|
+
|
|
89
91
|
expectType<typeof obj.b, 1>('=');
|
|
92
|
+
|
|
90
93
|
expectType<typeof obj, Readonly<{ a: 1; b: 1 }>>('=');
|
|
91
94
|
}
|
|
92
95
|
}
|
|
@@ -122,7 +125,9 @@ import { hasKey, type HasKeyReturnType } from './has-key.mjs';
|
|
|
122
125
|
|
|
123
126
|
if (hasKey(obj, 'a') && hasKey(obj, 'b')) {
|
|
124
127
|
expectType<typeof obj.a, number>('=');
|
|
128
|
+
|
|
125
129
|
expectType<typeof obj.b, number>('=');
|
|
130
|
+
|
|
126
131
|
expectType<
|
|
127
132
|
typeof obj,
|
|
128
133
|
| Readonly<{ a: 1; b: 1 }>
|
|
@@ -138,6 +143,7 @@ import { hasKey, type HasKeyReturnType } from './has-key.mjs';
|
|
|
138
143
|
|
|
139
144
|
if (hasKey(o, 'a')) {
|
|
140
145
|
expectType<typeof o.a, unknown>('=');
|
|
146
|
+
|
|
141
147
|
expectType<
|
|
142
148
|
typeof o,
|
|
143
149
|
ReadonlyRecord<'a', unknown> & ReadonlyRecord<string, unknown>
|
|
@@ -146,6 +152,7 @@ import { hasKey, type HasKeyReturnType } from './has-key.mjs';
|
|
|
146
152
|
|
|
147
153
|
if (hasKey(o, 'c')) {
|
|
148
154
|
expectType<typeof o.c, unknown>('=');
|
|
155
|
+
|
|
149
156
|
expectType<
|
|
150
157
|
typeof o,
|
|
151
158
|
ReadonlyRecord<'c', unknown> & ReadonlyRecord<string, unknown>
|
|
@@ -154,7 +161,9 @@ import { hasKey, type HasKeyReturnType } from './has-key.mjs';
|
|
|
154
161
|
|
|
155
162
|
if (hasKey(o, 'a') && hasKey(o, 'b')) {
|
|
156
163
|
expectType<typeof o.a, unknown>('=');
|
|
164
|
+
|
|
157
165
|
expectType<typeof o.b, unknown>('=');
|
|
166
|
+
|
|
158
167
|
expectType<
|
|
159
168
|
typeof o,
|
|
160
169
|
ReadonlyRecord<'a', unknown> &
|
|
@@ -4,10 +4,15 @@ import { isNonEmptyString } from './is-non-empty-string.mjs';
|
|
|
4
4
|
describe(isNonEmptyString, () => {
|
|
5
5
|
test('should return true for non-empty strings', () => {
|
|
6
6
|
expect(isNonEmptyString('hello')).toBe(true);
|
|
7
|
+
|
|
7
8
|
expect(isNonEmptyString('a')).toBe(true);
|
|
9
|
+
|
|
8
10
|
expect(isNonEmptyString(' ')).toBe(true); // Space is not empty
|
|
11
|
+
|
|
9
12
|
expect(isNonEmptyString(' multiple spaces ')).toBe(true);
|
|
13
|
+
|
|
10
14
|
expect(isNonEmptyString('123')).toBe(true);
|
|
15
|
+
|
|
11
16
|
expect(isNonEmptyString('special!@#$%')).toBe(true);
|
|
12
17
|
});
|
|
13
18
|
|
|
@@ -17,21 +22,30 @@ describe(isNonEmptyString, () => {
|
|
|
17
22
|
|
|
18
23
|
test('should return false for non-string values', () => {
|
|
19
24
|
expect(isNonEmptyString(null)).toBe(false);
|
|
25
|
+
|
|
20
26
|
expect(isNonEmptyString(undefined)).toBe(false);
|
|
27
|
+
|
|
21
28
|
// @ts-expect-error Testing non-string types
|
|
22
29
|
expect(isNonEmptyString(42)).toBe(false);
|
|
30
|
+
|
|
23
31
|
// @ts-expect-error Testing non-string types
|
|
24
32
|
expect(isNonEmptyString(0)).toBe(false);
|
|
33
|
+
|
|
25
34
|
// @ts-expect-error Testing non-string types
|
|
26
35
|
expect(isNonEmptyString(true)).toBe(false);
|
|
36
|
+
|
|
27
37
|
// @ts-expect-error Testing non-string types
|
|
28
38
|
expect(isNonEmptyString(false)).toBe(false);
|
|
39
|
+
|
|
29
40
|
// @ts-expect-error Testing non-string types
|
|
30
41
|
expect(isNonEmptyString({})).toBe(false);
|
|
42
|
+
|
|
31
43
|
// @ts-expect-error Testing non-string types
|
|
32
44
|
expect(isNonEmptyString([])).toBe(false);
|
|
45
|
+
|
|
33
46
|
// @ts-expect-error Testing non-string types
|
|
34
47
|
expect(isNonEmptyString(['string'])).toBe(false);
|
|
48
|
+
|
|
35
49
|
// @ts-expect-error Testing non-string types
|
|
36
50
|
expect(isNonEmptyString(() => 'string')).toBe(false);
|
|
37
51
|
});
|
|
@@ -45,6 +59,7 @@ describe(isNonEmptyString, () => {
|
|
|
45
59
|
|
|
46
60
|
// TypeScript knows it's a string
|
|
47
61
|
expect(value.length).toBeGreaterThan(0);
|
|
62
|
+
|
|
48
63
|
expect(value.charAt(0)).toBe('t');
|
|
49
64
|
}
|
|
50
65
|
});
|
|
@@ -79,10 +94,15 @@ describe(isNonEmptyString, () => {
|
|
|
79
94
|
|
|
80
95
|
test('should handle string edge cases', () => {
|
|
81
96
|
expect(isNonEmptyString('\n')).toBe(true); // Newline
|
|
97
|
+
|
|
82
98
|
expect(isNonEmptyString('\t')).toBe(true); // Tab
|
|
99
|
+
|
|
83
100
|
expect(isNonEmptyString('\r')).toBe(true); // Carriage return
|
|
101
|
+
|
|
84
102
|
expect(isNonEmptyString('\0')).toBe(true); // Null character
|
|
103
|
+
|
|
85
104
|
expect(isNonEmptyString('🎉')).toBe(true); // Emoji
|
|
105
|
+
|
|
86
106
|
expect(isNonEmptyString('你好')).toBe(true); // Unicode characters
|
|
87
107
|
});
|
|
88
108
|
|
|
@@ -4,37 +4,50 @@ import { isNonNullObject } from './is-non-null-object.mjs';
|
|
|
4
4
|
describe(isNonNullObject, () => {
|
|
5
5
|
test('should return true for plain objects', () => {
|
|
6
6
|
expect(isNonNullObject({})).toBe(true);
|
|
7
|
+
|
|
7
8
|
expect(isNonNullObject({ a: 1, b: 'test' })).toBe(true);
|
|
9
|
+
|
|
8
10
|
expect(isNonNullObject({ nested: { value: true } })).toBe(true);
|
|
9
11
|
});
|
|
10
12
|
|
|
11
13
|
test('should return true for arrays', () => {
|
|
12
14
|
expect(isNonNullObject([])).toBe(true);
|
|
15
|
+
|
|
13
16
|
expect(isNonNullObject([1, 2, 3])).toBe(true);
|
|
17
|
+
|
|
14
18
|
expect(isNonNullObject(['a', 'b', 'c'])).toBe(true);
|
|
15
19
|
});
|
|
16
20
|
|
|
17
21
|
test('should return true for functions', () => {
|
|
18
22
|
expect(isNonNullObject(() => {})).toBe(false);
|
|
23
|
+
|
|
19
24
|
expect(isNonNullObject(async () => {})).toBe(false);
|
|
25
|
+
|
|
20
26
|
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
|
21
27
|
expect(isNonNullObject(class MyClass {})).toBe(false);
|
|
22
28
|
});
|
|
23
29
|
|
|
24
30
|
test('should return true for built-in objects', () => {
|
|
25
31
|
expect(isNonNullObject(new Date())).toBe(true);
|
|
32
|
+
|
|
26
33
|
expect(isNonNullObject(/test/u)).toBe(true);
|
|
34
|
+
|
|
27
35
|
expect(isNonNullObject(/regex/u)).toBe(true);
|
|
36
|
+
|
|
28
37
|
expect(isNonNullObject(new Map())).toBe(true);
|
|
38
|
+
|
|
29
39
|
expect(isNonNullObject(new Set())).toBe(true);
|
|
40
|
+
|
|
30
41
|
expect(isNonNullObject(new Error('test'))).toBe(true);
|
|
31
42
|
});
|
|
32
43
|
|
|
33
44
|
test('should return true for boxed primitives', () => {
|
|
34
45
|
// eslint-disable-next-line unicorn/new-for-builtins
|
|
35
46
|
expect(isNonNullObject(new String('hello'))).toBe(true);
|
|
47
|
+
|
|
36
48
|
// eslint-disable-next-line unicorn/new-for-builtins
|
|
37
49
|
expect(isNonNullObject(new Number(42))).toBe(true);
|
|
50
|
+
|
|
38
51
|
// eslint-disable-next-line unicorn/new-for-builtins
|
|
39
52
|
expect(isNonNullObject(new Boolean(true))).toBe(true);
|
|
40
53
|
});
|
|
@@ -45,11 +58,17 @@ describe(isNonNullObject, () => {
|
|
|
45
58
|
|
|
46
59
|
test('should return false for primitive values', () => {
|
|
47
60
|
expect(isNonNullObject(undefined)).toBe(false);
|
|
61
|
+
|
|
48
62
|
expect(isNonNullObject('string')).toBe(false);
|
|
63
|
+
|
|
49
64
|
expect(isNonNullObject(42)).toBe(false);
|
|
65
|
+
|
|
50
66
|
expect(isNonNullObject(true)).toBe(false);
|
|
67
|
+
|
|
51
68
|
expect(isNonNullObject(false)).toBe(false);
|
|
69
|
+
|
|
52
70
|
expect(isNonNullObject(Symbol('test'))).toBe(false);
|
|
71
|
+
|
|
53
72
|
expect(isNonNullObject(123n)).toBe(false);
|
|
54
73
|
});
|
|
55
74
|
|
|
@@ -5,9 +5,11 @@ import { isSymbol } from './is-type.mjs';
|
|
|
5
5
|
describe(isPrimitive, () => {
|
|
6
6
|
test('should return true for string primitives', () => {
|
|
7
7
|
expect(isPrimitive('hello')).toBe(true);
|
|
8
|
+
|
|
8
9
|
expect(isPrimitive('')).toBe(true);
|
|
9
10
|
|
|
10
11
|
const value: unknown = 'test';
|
|
12
|
+
|
|
11
13
|
if (isPrimitive(value)) {
|
|
12
14
|
expectType<
|
|
13
15
|
typeof value,
|
|
@@ -18,25 +20,33 @@ describe(isPrimitive, () => {
|
|
|
18
20
|
|
|
19
21
|
test('should return true for number primitives', () => {
|
|
20
22
|
expect(isPrimitive(42)).toBe(true);
|
|
23
|
+
|
|
21
24
|
expect(isPrimitive(0)).toBe(true);
|
|
25
|
+
|
|
22
26
|
expect(isPrimitive(-3.14)).toBe(true);
|
|
27
|
+
|
|
23
28
|
expect(isPrimitive(Number.NaN)).toBe(true);
|
|
29
|
+
|
|
24
30
|
expect(isPrimitive(Number.POSITIVE_INFINITY)).toBe(true);
|
|
25
31
|
});
|
|
26
32
|
|
|
27
33
|
test('should return true for boolean primitives', () => {
|
|
28
34
|
expect(isPrimitive(true)).toBe(true);
|
|
35
|
+
|
|
29
36
|
expect(isPrimitive(false)).toBe(true);
|
|
30
37
|
});
|
|
31
38
|
|
|
32
39
|
test('should return true for symbol primitives', () => {
|
|
33
40
|
expect(isPrimitive(Symbol('test'))).toBe(true);
|
|
41
|
+
|
|
34
42
|
expect(isPrimitive(Symbol.iterator)).toBe(true);
|
|
35
43
|
});
|
|
36
44
|
|
|
37
45
|
test('should return true for bigint primitives', () => {
|
|
38
46
|
expect(isPrimitive(123n)).toBe(true);
|
|
47
|
+
|
|
39
48
|
expect(isPrimitive(0n)).toBe(true);
|
|
49
|
+
|
|
40
50
|
expect(isPrimitive(-123n)).toBe(true);
|
|
41
51
|
});
|
|
42
52
|
|
|
@@ -51,26 +61,33 @@ describe(isPrimitive, () => {
|
|
|
51
61
|
|
|
52
62
|
test('should return false for objects', () => {
|
|
53
63
|
expect(isPrimitive({})).toBe(false);
|
|
64
|
+
|
|
54
65
|
expect(isPrimitive({ a: 1 })).toBe(false);
|
|
66
|
+
|
|
55
67
|
expect(isPrimitive(new Date())).toBe(false);
|
|
56
68
|
});
|
|
57
69
|
|
|
58
70
|
test('should return false for arrays', () => {
|
|
59
71
|
expect(isPrimitive([])).toBe(false);
|
|
72
|
+
|
|
60
73
|
expect(isPrimitive([1, 2, 3])).toBe(false);
|
|
61
74
|
});
|
|
62
75
|
|
|
63
76
|
test('should return false for functions', () => {
|
|
64
77
|
expect(isPrimitive(() => {})).toBe(false);
|
|
78
|
+
|
|
65
79
|
expect(isPrimitive(() => {})).toBe(false);
|
|
80
|
+
|
|
66
81
|
expect(isPrimitive(async () => {})).toBe(false);
|
|
67
82
|
});
|
|
68
83
|
|
|
69
84
|
test('should return false for boxed primitives', () => {
|
|
70
85
|
// eslint-disable-next-line unicorn/new-for-builtins
|
|
71
86
|
expect(isPrimitive(new String('hello'))).toBe(false);
|
|
87
|
+
|
|
72
88
|
// eslint-disable-next-line unicorn/new-for-builtins
|
|
73
89
|
expect(isPrimitive(new Number(42))).toBe(false);
|
|
90
|
+
|
|
74
91
|
// eslint-disable-next-line unicorn/new-for-builtins
|
|
75
92
|
expect(isPrimitive(new Boolean(true))).toBe(false);
|
|
76
93
|
});
|
|
@@ -88,13 +105,19 @@ describe(isPrimitive, () => {
|
|
|
88
105
|
];
|
|
89
106
|
|
|
90
107
|
const primitives = values.filter(isPrimitive);
|
|
108
|
+
|
|
91
109
|
const nonPrimitives = values.filter((v) => !isPrimitive(v));
|
|
92
110
|
|
|
93
111
|
expect(primitives).toHaveLength(6); // string, 42, true, null, undefined, symbol
|
|
112
|
+
|
|
94
113
|
expect(primitives[0]).toBe('string');
|
|
114
|
+
|
|
95
115
|
expect(primitives[1]).toBe(42);
|
|
116
|
+
|
|
96
117
|
expect(primitives[2]).toBe(true);
|
|
118
|
+
|
|
97
119
|
expect(primitives[3]).toBeNull();
|
|
120
|
+
|
|
98
121
|
expect(primitives[4]).toBeUndefined();
|
|
99
122
|
|
|
100
123
|
expect(isSymbol(primitives[5])).toBe(true);
|
package/src/guard/is-record.mts
CHANGED
|
@@ -40,3 +40,37 @@ import { isNonNullObject } from './is-non-null-object.mjs';
|
|
|
40
40
|
*/
|
|
41
41
|
export const isRecord = (u: unknown): u is UnknownRecord =>
|
|
42
42
|
isNonNullObject(u) && !Array.isArray(u);
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Type guard that checks if a value is a mutable record (an object with mutable string keys).
|
|
46
|
+
*
|
|
47
|
+
* This function is an alias for {@link isRecord}, but narrows the type to
|
|
48
|
+
* `MutableRecord<string, unknown>`, which is useful when you need to ensure
|
|
49
|
+
* that the object can be safely mutated (i.e., its properties can be added or changed).
|
|
50
|
+
*
|
|
51
|
+
* **Type Narrowing Behavior:**
|
|
52
|
+
*
|
|
53
|
+
* - Narrows `unknown` to `MutableRecord<string, unknown>`
|
|
54
|
+
* - Excludes `null`, `undefined`, primitives, arrays, and functions
|
|
55
|
+
* - Returns `true` for plain objects with mutable string keys
|
|
56
|
+
* - Returns `false` for arrays and other non-record types
|
|
57
|
+
*
|
|
58
|
+
* **Implementation:** This is a type alias for {@link isRecord}.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* const obj: unknown = { foo: 1 };
|
|
63
|
+
*
|
|
64
|
+
* if (isMutableRecord(obj)) {
|
|
65
|
+
* obj['bar'] = 2; // Safe: obj is now known to be a mutable record
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @param u - The value to check
|
|
70
|
+
* @returns `true` if `u` is a mutable record (plain object with string keys), `false` otherwise.
|
|
71
|
+
* When `true`, TypeScript narrows the type to `MutableRecord<string, unknown>`.
|
|
72
|
+
* @see {@link isRecord} - For the underlying implementation and more details
|
|
73
|
+
*/
|
|
74
|
+
export const isMutableRecord: (
|
|
75
|
+
u: unknown,
|
|
76
|
+
) => u is MutableRecord<string, unknown> = isRecord;
|
|
@@ -4,10 +4,13 @@ import { isRecord } from './is-record.mjs';
|
|
|
4
4
|
describe(isRecord, () => {
|
|
5
5
|
test('{ x: 1 } is a record', () => {
|
|
6
6
|
const obj = { x: 1 } as const;
|
|
7
|
+
|
|
7
8
|
const unk: unknown = obj;
|
|
9
|
+
|
|
8
10
|
const res = isRecord(unk);
|
|
9
11
|
|
|
10
12
|
expectType<typeof obj, UnknownRecord>('<=');
|
|
13
|
+
|
|
11
14
|
expectType<typeof res, boolean>('=');
|
|
12
15
|
|
|
13
16
|
if (res) {
|
|
@@ -19,10 +22,13 @@ describe(isRecord, () => {
|
|
|
19
22
|
|
|
20
23
|
test('{} is a record', () => {
|
|
21
24
|
const obj = {} as const;
|
|
25
|
+
|
|
22
26
|
const unk: unknown = obj;
|
|
27
|
+
|
|
23
28
|
const res = isRecord(unk);
|
|
24
29
|
|
|
25
30
|
expectType<typeof obj, {}>('=');
|
|
31
|
+
|
|
26
32
|
expectType<typeof res, boolean>('=');
|
|
27
33
|
|
|
28
34
|
if (res) {
|
|
@@ -34,10 +40,13 @@ describe(isRecord, () => {
|
|
|
34
40
|
|
|
35
41
|
test('[] is not a record', () => {
|
|
36
42
|
const obj: DeepReadonly<never[]> = [] as const;
|
|
43
|
+
|
|
37
44
|
const unk: unknown = obj;
|
|
45
|
+
|
|
38
46
|
const res = isRecord(unk);
|
|
39
47
|
|
|
40
48
|
expectType<typeof obj, readonly never[]>('=');
|
|
49
|
+
|
|
41
50
|
expectType<typeof res, boolean>('=');
|
|
42
51
|
|
|
43
52
|
expect(res).toBe(false);
|
|
@@ -45,10 +54,13 @@ describe(isRecord, () => {
|
|
|
45
54
|
|
|
46
55
|
test('null is not a record', () => {
|
|
47
56
|
const obj = null;
|
|
57
|
+
|
|
48
58
|
const unk: unknown = obj;
|
|
59
|
+
|
|
49
60
|
const res = isRecord(unk);
|
|
50
61
|
|
|
51
62
|
expectType<typeof obj, null>('=');
|
|
63
|
+
|
|
52
64
|
expectType<typeof res, boolean>('=');
|
|
53
65
|
|
|
54
66
|
expect(res).toBe(false);
|
|
@@ -56,10 +68,13 @@ describe(isRecord, () => {
|
|
|
56
68
|
|
|
57
69
|
test('undefined is not a record', () => {
|
|
58
70
|
const obj = undefined;
|
|
71
|
+
|
|
59
72
|
const unk: unknown = obj;
|
|
73
|
+
|
|
60
74
|
const res = isRecord(unk);
|
|
61
75
|
|
|
62
76
|
expectType<typeof obj, undefined>('=');
|
|
77
|
+
|
|
63
78
|
expectType<typeof res, boolean>('=');
|
|
64
79
|
|
|
65
80
|
expect(res).toBe(false);
|
|
@@ -67,10 +82,13 @@ describe(isRecord, () => {
|
|
|
67
82
|
|
|
68
83
|
test('3 is not a record', () => {
|
|
69
84
|
const obj = 3;
|
|
85
|
+
|
|
70
86
|
const unk: unknown = obj;
|
|
87
|
+
|
|
71
88
|
const res = isRecord(unk);
|
|
72
89
|
|
|
73
90
|
expectType<typeof obj, 3>('=');
|
|
91
|
+
|
|
74
92
|
expectType<typeof res, boolean>('=');
|
|
75
93
|
|
|
76
94
|
expect(res).toBe(false);
|
|
@@ -78,10 +96,13 @@ describe(isRecord, () => {
|
|
|
78
96
|
|
|
79
97
|
test('"str" is not a record', () => {
|
|
80
98
|
const obj = 'str';
|
|
99
|
+
|
|
81
100
|
const unk: unknown = obj;
|
|
101
|
+
|
|
82
102
|
const res = isRecord(unk);
|
|
83
103
|
|
|
84
104
|
expectType<typeof obj, 'str'>('=');
|
|
105
|
+
|
|
85
106
|
expectType<typeof res, boolean>('=');
|
|
86
107
|
|
|
87
108
|
expect(res).toBe(false);
|
package/src/guard/is-type.mts
CHANGED
|
@@ -263,7 +263,9 @@ export const isNotString = <T,>(u: T): u is RelaxedExclude<T, string> =>
|
|
|
263
263
|
*
|
|
264
264
|
* ```ts
|
|
265
265
|
* const id = Symbol('id');
|
|
266
|
+
*
|
|
266
267
|
* const shared = Symbol.for('shared');
|
|
268
|
+
*
|
|
267
269
|
* const tokens: unknown[] = [id, 'shared', shared];
|
|
268
270
|
*
|
|
269
271
|
* const symbols = tokens.filter(isSymbol);
|
|
@@ -289,6 +291,7 @@ export const isSymbol = (u: unknown): u is symbol => typeof u === 'symbol';
|
|
|
289
291
|
*
|
|
290
292
|
* ```ts
|
|
291
293
|
* const id = Symbol('id');
|
|
294
|
+
*
|
|
292
295
|
* const tokens: unknown[] = [id, 'shared'];
|
|
293
296
|
*
|
|
294
297
|
* const nonSymbols = tokens.filter(isNotSymbol);
|