ts-data-forge 5.0.1 → 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 +6 -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.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.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.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 +6 -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.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 +2 -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 +8 -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 +7 -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 +2 -0
- 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 +2 -0
- 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 +21 -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 +22 -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.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 +4 -0
- package/dist/promise/promise.mjs.map +1 -1
- package/package.json +18 -22
- 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 +53 -8
- 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 +4 -0
- 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 +3 -0
- 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 +2 -0
- 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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ts-data-forge",
|
|
3
|
-
"version": "5.0
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -48,15 +48,14 @@
|
|
|
48
48
|
"fmt": "format-uncommitted",
|
|
49
49
|
"fmt:diff": "format-diff-from origin/main",
|
|
50
50
|
"fmt:full": "prettier --write .",
|
|
51
|
-
"gh:apply-all": "
|
|
52
|
-
"gh:apply-repository-settings": "
|
|
53
|
-
"gh:apply-rulesets": "
|
|
54
|
-
"gh:apply-variables": "
|
|
55
|
-
"gh:backup-all": "
|
|
56
|
-
"gh:backup-repository-settings": "
|
|
57
|
-
"gh:backup-rulesets": "
|
|
58
|
-
"gi": "run-s gi:
|
|
59
|
-
"gi:scripts": "gen-index-ts ./scripts/github --index-ext .mts --export-ext .mjs --target-ext .mts --exclude cmd --exclude apply.mts --exclude octokit.mts",
|
|
51
|
+
"gh:apply-all": "gh-apply-all",
|
|
52
|
+
"gh:apply-repository-settings": "gh-apply-repository-settings",
|
|
53
|
+
"gh:apply-rulesets": "gh-apply-rulesets",
|
|
54
|
+
"gh:apply-variables": "gh-apply-variables",
|
|
55
|
+
"gh:backup-all": "gh-backup-all",
|
|
56
|
+
"gh:backup-repository-settings": "gh-backup-repository-settings",
|
|
57
|
+
"gh:backup-rulesets": "gh-backup-rulesets",
|
|
58
|
+
"gi": "run-s gi:src fmt",
|
|
60
59
|
"gi:src": "tsx scripts/cmd/gen-index.mts",
|
|
61
60
|
"lint": "eslint .",
|
|
62
61
|
"lint:fix": "eslint . --fix",
|
|
@@ -79,7 +78,6 @@
|
|
|
79
78
|
"@emotion/react": "^11.14.0",
|
|
80
79
|
"@emotion/styled": "^11.14.1",
|
|
81
80
|
"@mui/material": "^7.3.5",
|
|
82
|
-
"@octokit/core": "7.0.6",
|
|
83
81
|
"@rollup/plugin-replace": "^6.0.3",
|
|
84
82
|
"@rollup/plugin-strip": "^3.0.4",
|
|
85
83
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
@@ -88,38 +86,36 @@
|
|
|
88
86
|
"@semantic-release/exec": "^7.1.0",
|
|
89
87
|
"@semantic-release/git": "^10.0.1",
|
|
90
88
|
"@semantic-release/github": "^12.0.2",
|
|
91
|
-
"@semantic-release/npm": "^13.1.
|
|
89
|
+
"@semantic-release/npm": "^13.1.2",
|
|
92
90
|
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
93
91
|
"@sindresorhus/is": "^7.1.1",
|
|
94
92
|
"@types/node": "^24.10.1",
|
|
95
|
-
"@types/react": "^19.2.
|
|
96
|
-
"@vitest/coverage-v8": "^4.0.
|
|
97
|
-
"@vitest/ui": "^4.0.
|
|
93
|
+
"@types/react": "^19.2.5",
|
|
94
|
+
"@vitest/coverage-v8": "^4.0.9",
|
|
95
|
+
"@vitest/ui": "^4.0.9",
|
|
98
96
|
"conventional-changelog-conventionalcommits": "^9.1.0",
|
|
99
|
-
"cspell": "^9.3.
|
|
97
|
+
"cspell": "^9.3.2",
|
|
100
98
|
"eslint": "9.39.1",
|
|
101
|
-
"eslint-config-typed": "^3.
|
|
102
|
-
"
|
|
99
|
+
"eslint-config-typed": "^3.13.3",
|
|
100
|
+
"github-settings-as-code": "^1.0.6",
|
|
103
101
|
"immer": "^10.2.0",
|
|
104
102
|
"jiti": "^2.6.1",
|
|
105
103
|
"markdownlint": "^0.39.0",
|
|
106
104
|
"markdownlint-cli2": "^0.19.0",
|
|
107
105
|
"npm-run-all2": "^8.0.4",
|
|
108
|
-
"octokit-safe-types": "^1.2.0",
|
|
109
106
|
"prettier": "^3.6.2",
|
|
110
107
|
"prettier-plugin-organize-imports": "^4.3.0",
|
|
111
108
|
"prettier-plugin-packagejson": "^2.5.19",
|
|
112
109
|
"rollup": "^4.53.2",
|
|
113
110
|
"semantic-release": "^25.0.2",
|
|
114
|
-
"ts-
|
|
115
|
-
"ts-repo-utils": "^7.8.1",
|
|
111
|
+
"ts-repo-utils": "^7.8.2",
|
|
116
112
|
"tslib": "^2.8.1",
|
|
117
113
|
"tsx": "^4.20.6",
|
|
118
114
|
"typedoc": "^0.28.14",
|
|
119
115
|
"typedoc-github-theme": "^0.3.1",
|
|
120
116
|
"typescript": "^5.9.3",
|
|
121
117
|
"vite": "^7.2.2",
|
|
122
|
-
"vitest": "^4.0.
|
|
118
|
+
"vitest": "^4.0.9"
|
|
123
119
|
},
|
|
124
120
|
"peerDependencies": {
|
|
125
121
|
"typescript": ">=4.8"
|
|
@@ -8,9 +8,11 @@ import { range as rangeIterator } from '../../iterator/index.mjs';
|
|
|
8
8
|
*
|
|
9
9
|
* ```ts
|
|
10
10
|
* const emptyZeros = Arr.zeros(0);
|
|
11
|
+
*
|
|
11
12
|
* const threeZeros = Arr.zeros(3);
|
|
12
13
|
*
|
|
13
14
|
* assert.deepStrictEqual(emptyZeros, []);
|
|
15
|
+
*
|
|
14
16
|
* assert.deepStrictEqual(threeZeros, [0, 0, 0]);
|
|
15
17
|
* ```
|
|
16
18
|
*/
|
|
@@ -31,9 +33,11 @@ export const zeros = <N extends SizeType.ArgArr>(
|
|
|
31
33
|
*
|
|
32
34
|
* ```ts
|
|
33
35
|
* const emptySeq = Arr.seq(0);
|
|
36
|
+
*
|
|
34
37
|
* const firstFive = Arr.seq(5);
|
|
35
38
|
*
|
|
36
39
|
* assert.deepStrictEqual(emptySeq, []);
|
|
40
|
+
*
|
|
37
41
|
* assert.deepStrictEqual(firstFive, [0, 1, 2, 3, 4]);
|
|
38
42
|
* ```
|
|
39
43
|
*/
|
|
@@ -54,9 +58,11 @@ export const seq = <N extends SizeType.ArgArr>(
|
|
|
54
58
|
*
|
|
55
59
|
* ```ts
|
|
56
60
|
* const threeOnes = Arr.create(3, 1);
|
|
61
|
+
*
|
|
57
62
|
* const emptyStrings = Arr.create(0, 'Ada');
|
|
58
63
|
*
|
|
59
64
|
* assert.deepStrictEqual(threeOnes, [1, 1, 1]);
|
|
65
|
+
*
|
|
60
66
|
* assert.deepStrictEqual(emptyStrings, []);
|
|
61
67
|
* ```
|
|
62
68
|
*/
|
|
@@ -86,7 +92,9 @@ export const newArray = create;
|
|
|
86
92
|
* ```ts
|
|
87
93
|
* const numbers = Arr.generate(function* () {
|
|
88
94
|
* yield 1;
|
|
95
|
+
*
|
|
89
96
|
* yield 2;
|
|
97
|
+
*
|
|
90
98
|
* yield 3;
|
|
91
99
|
* });
|
|
92
100
|
*
|
|
@@ -105,7 +113,9 @@ export const generate = <T,>(
|
|
|
105
113
|
* ```ts
|
|
106
114
|
* const values = await Arr.generateAsync(async function* () {
|
|
107
115
|
* yield 'Ada';
|
|
116
|
+
*
|
|
108
117
|
* await Promise.resolve();
|
|
118
|
+
*
|
|
109
119
|
* yield 'Lovelace';
|
|
110
120
|
* });
|
|
111
121
|
*
|
|
@@ -123,9 +133,11 @@ export const generateAsync = <T,>(
|
|
|
123
133
|
*
|
|
124
134
|
* ```ts
|
|
125
135
|
* const original = [{ id: 1 }, { id: 2 }] as const;
|
|
136
|
+
*
|
|
126
137
|
* const cloned = Arr.copy(original);
|
|
127
138
|
*
|
|
128
139
|
* assert.deepStrictEqual(cloned, original);
|
|
140
|
+
*
|
|
129
141
|
* assert.notStrictEqual(cloned, original);
|
|
130
142
|
* ```
|
|
131
143
|
*/
|
|
@@ -143,13 +155,19 @@ type RangeList<S extends SmallUint, E extends SmallUint> =
|
|
|
143
155
|
: List.Skip<S, Seq<E>>;
|
|
144
156
|
|
|
145
157
|
expectType<RangeList<1, 5>, readonly [1, 2, 3, 4]>('=');
|
|
158
|
+
|
|
146
159
|
expectType<RangeList<1, 2>, readonly [1]>('=');
|
|
160
|
+
|
|
147
161
|
expectType<RangeList<1, 1>, readonly []>('=');
|
|
162
|
+
|
|
148
163
|
expectType<RangeList<1, 1 | 3>, readonly (1 | 2)[]>('=');
|
|
164
|
+
|
|
149
165
|
expectType<RangeList<1 | 3, 3 | 5>, readonly (1 | 2 | 3 | 4)[]>('=');
|
|
166
|
+
|
|
150
167
|
expectType<RangeList<1 | 2 | 3, 5 | 6 | 7>, readonly (1 | 2 | 3 | 4 | 5 | 6)[]>(
|
|
151
168
|
'=',
|
|
152
169
|
);
|
|
170
|
+
|
|
153
171
|
expectType<RangeList<5, 1>, readonly []>('=');
|
|
154
172
|
|
|
155
173
|
/**
|
|
@@ -159,9 +177,11 @@ expectType<RangeList<5, 1>, readonly []>('=');
|
|
|
159
177
|
*
|
|
160
178
|
* ```ts
|
|
161
179
|
* const ascending = Arr.range(asUint32(1), asUint32(5));
|
|
180
|
+
*
|
|
162
181
|
* const empty = Arr.range(asUint32(2), asUint32(2));
|
|
163
182
|
*
|
|
164
183
|
* assert.deepStrictEqual(ascending, [1, 2, 3, 4]);
|
|
184
|
+
*
|
|
165
185
|
* assert.deepStrictEqual(empty, []);
|
|
166
186
|
* ```
|
|
167
187
|
*/
|
|
@@ -21,6 +21,7 @@ describe('Arr creations', () => {
|
|
|
21
21
|
describe(zeros, () => {
|
|
22
22
|
test('fixed length', () => {
|
|
23
23
|
const result = zeros(3);
|
|
24
|
+
|
|
24
25
|
expectType<typeof result, readonly [0, 0, 0]>('=');
|
|
25
26
|
|
|
26
27
|
assert.deepStrictEqual(result, [0, 0, 0]);
|
|
@@ -28,6 +29,7 @@ describe('Arr creations', () => {
|
|
|
28
29
|
|
|
29
30
|
test('fixed length (empty)', () => {
|
|
30
31
|
const result = zeros(0);
|
|
32
|
+
|
|
31
33
|
expectType<typeof result, readonly []>('=');
|
|
32
34
|
|
|
33
35
|
assert.deepStrictEqual(result, []);
|
|
@@ -35,7 +37,9 @@ describe('Arr creations', () => {
|
|
|
35
37
|
|
|
36
38
|
test('unknown length', () => {
|
|
37
39
|
const n: number = 3;
|
|
40
|
+
|
|
38
41
|
const result = zeros(asUint32(n));
|
|
42
|
+
|
|
39
43
|
expectType<typeof result, readonly 0[]>('=');
|
|
40
44
|
|
|
41
45
|
assert.deepStrictEqual(result, [0, 0, 0]);
|
|
@@ -53,6 +57,7 @@ describe('Arr creations', () => {
|
|
|
53
57
|
const result = zeros(asUint32(1000));
|
|
54
58
|
|
|
55
59
|
expect(result).toHaveLength(1000);
|
|
60
|
+
|
|
56
61
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
57
62
|
expect(result.every((x) => x === 0)).toBe(true);
|
|
58
63
|
});
|
|
@@ -67,6 +72,7 @@ describe('Arr creations', () => {
|
|
|
67
72
|
describe(seq, () => {
|
|
68
73
|
test('fixed length', () => {
|
|
69
74
|
const result = seq(5);
|
|
75
|
+
|
|
70
76
|
expectType<typeof result, readonly [0, 1, 2, 3, 4]>('=');
|
|
71
77
|
|
|
72
78
|
assert.deepStrictEqual(result, [0, 1, 2, 3, 4]);
|
|
@@ -74,6 +80,7 @@ describe('Arr creations', () => {
|
|
|
74
80
|
|
|
75
81
|
test('fixed length (empty)', () => {
|
|
76
82
|
const result = seq(0);
|
|
83
|
+
|
|
77
84
|
expectType<typeof result, readonly []>('=');
|
|
78
85
|
|
|
79
86
|
assert.deepStrictEqual(result, []);
|
|
@@ -81,7 +88,9 @@ describe('Arr creations', () => {
|
|
|
81
88
|
|
|
82
89
|
test('unknown length', () => {
|
|
83
90
|
const n: number = 3;
|
|
91
|
+
|
|
84
92
|
const result = seq(asUint32(n));
|
|
93
|
+
|
|
85
94
|
expectType<typeof result, readonly SizeType.Arr[]>('=');
|
|
86
95
|
|
|
87
96
|
assert.deepStrictEqual(result, [asUint32(0), asUint32(1), asUint32(2)]);
|
|
@@ -97,7 +106,9 @@ describe('Arr creations', () => {
|
|
|
97
106
|
const result = seq(asUint32(100));
|
|
98
107
|
|
|
99
108
|
expect(result).toHaveLength(100);
|
|
109
|
+
|
|
100
110
|
expect(result[0]).toBe(0);
|
|
111
|
+
|
|
101
112
|
expect(result[99]).toBe(99);
|
|
102
113
|
});
|
|
103
114
|
|
|
@@ -111,6 +122,7 @@ describe('Arr creations', () => {
|
|
|
111
122
|
describe(create, () => {
|
|
112
123
|
test('fixed length with primitive value', () => {
|
|
113
124
|
const result = create(3, 'a');
|
|
125
|
+
|
|
114
126
|
expectType<typeof result, readonly ['a', 'a', 'a']>('=');
|
|
115
127
|
|
|
116
128
|
assert.deepStrictEqual(result, ['a', 'a', 'a']);
|
|
@@ -118,6 +130,7 @@ describe('Arr creations', () => {
|
|
|
118
130
|
|
|
119
131
|
test('fixed length with null', () => {
|
|
120
132
|
const result = create(2, null);
|
|
133
|
+
|
|
121
134
|
expectType<typeof result, readonly [null, null]>('=');
|
|
122
135
|
|
|
123
136
|
assert.deepStrictEqual(result, [null, null]);
|
|
@@ -125,7 +138,9 @@ describe('Arr creations', () => {
|
|
|
125
138
|
|
|
126
139
|
test('fixed length with object (shallow copy)', () => {
|
|
127
140
|
const obj = { id: 1 };
|
|
141
|
+
|
|
128
142
|
const result = create(2, obj);
|
|
143
|
+
|
|
129
144
|
expectType<typeof result, readonly [{ id: number }, { id: number }]>(
|
|
130
145
|
'~=',
|
|
131
146
|
);
|
|
@@ -133,11 +148,13 @@ describe('Arr creations', () => {
|
|
|
133
148
|
assert.deepStrictEqual(result, [obj, obj]);
|
|
134
149
|
|
|
135
150
|
expect(result[0]).toBe(obj);
|
|
151
|
+
|
|
136
152
|
expect(result[1]).toBe(obj);
|
|
137
153
|
});
|
|
138
154
|
|
|
139
155
|
test('fixed length (empty)', () => {
|
|
140
156
|
const result = create(0, 123);
|
|
157
|
+
|
|
141
158
|
expectType<typeof result, readonly []>('=');
|
|
142
159
|
|
|
143
160
|
assert.deepStrictEqual(result, []);
|
|
@@ -145,7 +162,9 @@ describe('Arr creations', () => {
|
|
|
145
162
|
|
|
146
163
|
test('unknown length', () => {
|
|
147
164
|
const n: number = 2;
|
|
165
|
+
|
|
148
166
|
const result = create(asUint32(n), true);
|
|
167
|
+
|
|
149
168
|
expectType<typeof result, readonly true[]>('=');
|
|
150
169
|
|
|
151
170
|
assert.deepStrictEqual(result, [true, true]);
|
|
@@ -153,6 +172,7 @@ describe('Arr creations', () => {
|
|
|
153
172
|
|
|
154
173
|
test('should create array with function values', () => {
|
|
155
174
|
const fn = (): string => 'test';
|
|
175
|
+
|
|
156
176
|
const result = create(3, fn);
|
|
157
177
|
|
|
158
178
|
assert.deepStrictEqual(result, [fn, fn, fn]);
|
|
@@ -162,6 +182,7 @@ describe('Arr creations', () => {
|
|
|
162
182
|
|
|
163
183
|
test('should create array with object values', () => {
|
|
164
184
|
const obj = { a: 1 };
|
|
185
|
+
|
|
165
186
|
const result = create(2, obj);
|
|
166
187
|
|
|
167
188
|
assert.deepStrictEqual(result, [obj, obj]);
|
|
@@ -177,9 +198,11 @@ describe('Arr creations', () => {
|
|
|
177
198
|
|
|
178
199
|
test('newArray is alias for create', () => {
|
|
179
200
|
const created1 = create(3, 'test');
|
|
201
|
+
|
|
180
202
|
const created2 = newArray(3, 'test');
|
|
181
203
|
|
|
182
204
|
assert.deepStrictEqual(created1, created2);
|
|
205
|
+
|
|
183
206
|
assert.deepStrictEqual(created1, ['test', 'test', 'test']);
|
|
184
207
|
});
|
|
185
208
|
});
|
|
@@ -187,7 +210,9 @@ describe('Arr creations', () => {
|
|
|
187
210
|
describe(copy, () => {
|
|
188
211
|
test('should create a shallow copy of an array of primitives', () => {
|
|
189
212
|
const original = [1, 2, 3] as const;
|
|
213
|
+
|
|
190
214
|
const copied = copy(original);
|
|
215
|
+
|
|
191
216
|
expectType<typeof copied, readonly [1, 2, 3]>('=');
|
|
192
217
|
|
|
193
218
|
assert.deepStrictEqual(copied, original);
|
|
@@ -197,8 +222,11 @@ describe('Arr creations', () => {
|
|
|
197
222
|
|
|
198
223
|
test('should create a shallow copy of an array of objects', () => {
|
|
199
224
|
const obj1 = { id: 1 };
|
|
225
|
+
|
|
200
226
|
const obj2 = { id: 2 };
|
|
227
|
+
|
|
201
228
|
const original = [obj1, obj2] as const;
|
|
229
|
+
|
|
202
230
|
const copied = copy(original);
|
|
203
231
|
|
|
204
232
|
expectType<typeof copied, readonly [{ id: number }, { id: number }]>('=');
|
|
@@ -206,13 +234,17 @@ describe('Arr creations', () => {
|
|
|
206
234
|
assert.deepStrictEqual(copied, original);
|
|
207
235
|
|
|
208
236
|
expect(copied).not.toBe(original);
|
|
237
|
+
|
|
209
238
|
expect(copied[0]).toBe(original[0]); // Object references are the same
|
|
239
|
+
|
|
210
240
|
expect(copied[1]).toBe(original[1]);
|
|
211
241
|
});
|
|
212
242
|
|
|
213
243
|
test('should create a copy of an empty array', () => {
|
|
214
244
|
const original = [] as const;
|
|
245
|
+
|
|
215
246
|
const copied = copy(original);
|
|
247
|
+
|
|
216
248
|
expectType<typeof copied, readonly []>('=');
|
|
217
249
|
|
|
218
250
|
assert.deepStrictEqual(copied, original);
|
|
@@ -222,7 +254,9 @@ describe('Arr creations', () => {
|
|
|
222
254
|
|
|
223
255
|
test('should create a copy of an array with mixed types', () => {
|
|
224
256
|
const original = [1, 'hello', true, null, undefined] as const;
|
|
257
|
+
|
|
225
258
|
const copied = copy(original);
|
|
259
|
+
|
|
226
260
|
expectType<typeof copied, readonly [1, 'hello', true, null, undefined]>(
|
|
227
261
|
'=',
|
|
228
262
|
);
|
|
@@ -234,7 +268,9 @@ describe('Arr creations', () => {
|
|
|
234
268
|
|
|
235
269
|
test('should handle unknown array type', () => {
|
|
236
270
|
const mut_original: number[] = [1, 2, 3];
|
|
271
|
+
|
|
237
272
|
const copied = copy(mut_original);
|
|
273
|
+
|
|
238
274
|
expectType<typeof copied, number[]>('=');
|
|
239
275
|
|
|
240
276
|
assert.deepStrictEqual(copied, mut_original);
|
|
@@ -245,12 +281,15 @@ describe('Arr creations', () => {
|
|
|
245
281
|
mut_original.push(4);
|
|
246
282
|
|
|
247
283
|
assert.deepStrictEqual(mut_original, [1, 2, 3, 4]);
|
|
284
|
+
|
|
248
285
|
assert.deepStrictEqual(copied, [1, 2, 3]);
|
|
249
286
|
});
|
|
250
287
|
|
|
251
288
|
test('should create shallow copy of array', () => {
|
|
252
289
|
const original = [1, 2, 3] as const;
|
|
290
|
+
|
|
253
291
|
const copied = copy(original);
|
|
292
|
+
|
|
254
293
|
expectType<typeof copied, readonly [1, 2, 3]>('=');
|
|
255
294
|
|
|
256
295
|
assert.deepStrictEqual(copied, original);
|
|
@@ -260,6 +299,7 @@ describe('Arr creations', () => {
|
|
|
260
299
|
|
|
261
300
|
test('should work with empty array', () => {
|
|
262
301
|
const empty = [] as const;
|
|
302
|
+
|
|
263
303
|
const copied = copy(empty);
|
|
264
304
|
|
|
265
305
|
assert.deepStrictEqual(copied, []);
|
|
@@ -269,7 +309,9 @@ describe('Arr creations', () => {
|
|
|
269
309
|
|
|
270
310
|
test('should preserve array type', () => {
|
|
271
311
|
const mixed = [1, 'hello', true] as const;
|
|
312
|
+
|
|
272
313
|
const copied = copy(mixed);
|
|
314
|
+
|
|
273
315
|
expectType<typeof copied, readonly [1, 'hello', true]>('=');
|
|
274
316
|
|
|
275
317
|
assert.deepStrictEqual(copied, [1, 'hello', true]);
|
|
@@ -279,6 +321,7 @@ describe('Arr creations', () => {
|
|
|
279
321
|
describe(range, () => {
|
|
280
322
|
test('start < end, step = 1 (default)', () => {
|
|
281
323
|
const result = range(1, 5);
|
|
324
|
+
|
|
282
325
|
expectType<typeof result, readonly [1, 2, 3, 4]>('=');
|
|
283
326
|
|
|
284
327
|
assert.deepStrictEqual(result, [1, 2, 3, 4]);
|
|
@@ -286,6 +329,7 @@ describe('Arr creations', () => {
|
|
|
286
329
|
|
|
287
330
|
test('start === end, step = 1 (default)', () => {
|
|
288
331
|
const result = range(3, 3);
|
|
332
|
+
|
|
289
333
|
expectType<typeof result, readonly []>('=');
|
|
290
334
|
|
|
291
335
|
assert.deepStrictEqual(result, []);
|
|
@@ -293,6 +337,7 @@ describe('Arr creations', () => {
|
|
|
293
337
|
|
|
294
338
|
test('start > end, step = 1 (default)', () => {
|
|
295
339
|
const result = range(5, 1);
|
|
340
|
+
|
|
296
341
|
expectType<typeof result, readonly []>('=');
|
|
297
342
|
|
|
298
343
|
assert.deepStrictEqual(result, []);
|
|
@@ -300,6 +345,7 @@ describe('Arr creations', () => {
|
|
|
300
345
|
|
|
301
346
|
test('start < end, step > 1', () => {
|
|
302
347
|
const result = range(0, 6, 2);
|
|
348
|
+
|
|
303
349
|
expectType<typeof result, readonly SafeUint[]>('='); // Type is less specific with explicit step
|
|
304
350
|
|
|
305
351
|
assert.deepStrictEqual(result, [
|
|
@@ -351,13 +397,17 @@ describe('Arr creations', () => {
|
|
|
351
397
|
|
|
352
398
|
test('unknown start/end/step', () => {
|
|
353
399
|
const start: number = 1;
|
|
400
|
+
|
|
354
401
|
const end: number = 4;
|
|
402
|
+
|
|
355
403
|
const step: number = 1;
|
|
404
|
+
|
|
356
405
|
const result = range(
|
|
357
406
|
asUint32(start),
|
|
358
407
|
asUint32(end),
|
|
359
408
|
asNonZeroSafeInt(step),
|
|
360
409
|
);
|
|
410
|
+
|
|
361
411
|
expectType<typeof result, readonly SafeInt[]>('=');
|
|
362
412
|
|
|
363
413
|
assert.deepStrictEqual(result, [
|
|
@@ -551,7 +601,9 @@ describe('Arr creations', () => {
|
|
|
551
601
|
test('basic generator usage', () => {
|
|
552
602
|
const result = generate<number>(function* () {
|
|
553
603
|
yield 1;
|
|
604
|
+
|
|
554
605
|
yield 2;
|
|
606
|
+
|
|
555
607
|
yield 3;
|
|
556
608
|
});
|
|
557
609
|
|
|
@@ -563,7 +615,9 @@ describe('Arr creations', () => {
|
|
|
563
615
|
test('generator with yield*', () => {
|
|
564
616
|
const result = generate<number>(function* () {
|
|
565
617
|
yield 1;
|
|
618
|
+
|
|
566
619
|
yield* [2, 3];
|
|
620
|
+
|
|
567
621
|
yield 4;
|
|
568
622
|
});
|
|
569
623
|
|
|
@@ -584,11 +638,14 @@ describe('Arr creations', () => {
|
|
|
584
638
|
|
|
585
639
|
test('generator with conditional logic', () => {
|
|
586
640
|
const condition = true as boolean; // Simulating a condition
|
|
641
|
+
|
|
587
642
|
const result = generate<number>(function* () {
|
|
588
643
|
yield 1;
|
|
644
|
+
|
|
589
645
|
if (condition) {
|
|
590
646
|
yield 2;
|
|
591
647
|
}
|
|
648
|
+
|
|
592
649
|
yield 3;
|
|
593
650
|
});
|
|
594
651
|
|
|
@@ -599,11 +656,14 @@ describe('Arr creations', () => {
|
|
|
599
656
|
|
|
600
657
|
test('generator with early return', () => {
|
|
601
658
|
const condition = true as boolean; // Simulating a condition
|
|
659
|
+
|
|
602
660
|
const result = generate<number>(function* () {
|
|
603
661
|
yield 1;
|
|
662
|
+
|
|
604
663
|
if (condition) {
|
|
605
664
|
return; // Early return is OK
|
|
606
665
|
}
|
|
666
|
+
|
|
607
667
|
yield 2; // This won't be reached
|
|
608
668
|
});
|
|
609
669
|
|
|
@@ -615,6 +675,7 @@ describe('Arr creations', () => {
|
|
|
615
675
|
test('generator with complex data types', () => {
|
|
616
676
|
const result = generate<{ id: number; name: string }>(function* () {
|
|
617
677
|
yield { id: 1, name: 'Alice' };
|
|
678
|
+
|
|
618
679
|
yield { id: 2, name: 'Bob' };
|
|
619
680
|
});
|
|
620
681
|
|
|
@@ -629,7 +690,9 @@ describe('Arr creations', () => {
|
|
|
629
690
|
test('generator with different types', () => {
|
|
630
691
|
const result = generate<string | number>(function* () {
|
|
631
692
|
yield 'hello';
|
|
693
|
+
|
|
632
694
|
yield 42;
|
|
695
|
+
|
|
633
696
|
yield 'world';
|
|
634
697
|
});
|
|
635
698
|
|
|
@@ -656,7 +719,9 @@ describe('Arr creations', () => {
|
|
|
656
719
|
// eslint-disable-next-line @typescript-eslint/require-await
|
|
657
720
|
const result = await generateAsync<number>(async function* () {
|
|
658
721
|
yield 1;
|
|
722
|
+
|
|
659
723
|
yield 2;
|
|
724
|
+
|
|
660
725
|
yield 3;
|
|
661
726
|
});
|
|
662
727
|
|
|
@@ -668,10 +733,15 @@ describe('Arr creations', () => {
|
|
|
668
733
|
test('should handle async operations in generator', async () => {
|
|
669
734
|
const result = await generateAsync<string>(async function* () {
|
|
670
735
|
await Promise.resolve();
|
|
736
|
+
|
|
671
737
|
yield 'a';
|
|
738
|
+
|
|
672
739
|
await Promise.resolve();
|
|
740
|
+
|
|
673
741
|
yield 'b';
|
|
742
|
+
|
|
674
743
|
await Promise.resolve();
|
|
744
|
+
|
|
675
745
|
yield 'c';
|
|
676
746
|
});
|
|
677
747
|
|
|
@@ -692,6 +762,7 @@ describe('Arr creations', () => {
|
|
|
692
762
|
for (let i = 0; i < 3; i++) {
|
|
693
763
|
// eslint-disable-next-line no-promise-executor-return, no-await-in-loop
|
|
694
764
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
765
|
+
|
|
695
766
|
yield i;
|
|
696
767
|
}
|
|
697
768
|
});
|
|
@@ -9,11 +9,15 @@ import { Optional, pipe } from '../../functional/index.mjs';
|
|
|
9
9
|
* const letters: readonly string[] = ['a', 'b', 'c'];
|
|
10
10
|
*
|
|
11
11
|
* const two = Arr.at(letters, 1);
|
|
12
|
+
*
|
|
12
13
|
* const last = Arr.at(-1)(letters);
|
|
14
|
+
*
|
|
13
15
|
* const missing = Arr.at(letters, 5);
|
|
14
16
|
*
|
|
15
17
|
* assert.deepStrictEqual(two, Optional.some('b'));
|
|
18
|
+
*
|
|
16
19
|
* assert.deepStrictEqual(last, Optional.some('c'));
|
|
20
|
+
*
|
|
17
21
|
* assert.deepStrictEqual(missing, Optional.none);
|
|
18
22
|
* ```
|
|
19
23
|
*/
|
|
@@ -36,6 +40,7 @@ export function at<E>(
|
|
|
36
40
|
switch (args.length) {
|
|
37
41
|
case 2: {
|
|
38
42
|
const [array, index] = args;
|
|
43
|
+
|
|
39
44
|
return pipe(index < 0 ? array.length + index : index).map(
|
|
40
45
|
(normalizedIndex) =>
|
|
41
46
|
normalizedIndex < 0 || normalizedIndex >= array.length
|
|
@@ -44,8 +49,10 @@ export function at<E>(
|
|
|
44
49
|
Optional.some(array[normalizedIndex]!),
|
|
45
50
|
).value;
|
|
46
51
|
}
|
|
52
|
+
|
|
47
53
|
case 1: {
|
|
48
54
|
const [index] = args;
|
|
55
|
+
|
|
49
56
|
return (array) => at(array, index);
|
|
50
57
|
}
|
|
51
58
|
}
|
|
@@ -58,12 +65,15 @@ export function at<E>(
|
|
|
58
65
|
*
|
|
59
66
|
* ```ts
|
|
60
67
|
* const users = [{ id: 1 }, { id: 2 }];
|
|
68
|
+
*
|
|
61
69
|
* const empty: { id: number }[] = [];
|
|
62
70
|
*
|
|
63
71
|
* const first = Arr.head(users);
|
|
72
|
+
*
|
|
64
73
|
* const none = Arr.head(empty);
|
|
65
74
|
*
|
|
66
75
|
* assert.deepStrictEqual(first, Optional.some({ id: 1 }));
|
|
76
|
+
*
|
|
67
77
|
* assert.deepStrictEqual(none, Optional.none);
|
|
68
78
|
* ```
|
|
69
79
|
*/
|
|
@@ -86,12 +96,15 @@ export const head = <const Ar extends readonly unknown[]>(
|
|
|
86
96
|
*
|
|
87
97
|
* ```ts
|
|
88
98
|
* const queue = ['first', 'second'];
|
|
99
|
+
*
|
|
89
100
|
* const emptyQueue: string[] = [];
|
|
90
101
|
*
|
|
91
102
|
* const lastValue = Arr.last(queue);
|
|
103
|
+
*
|
|
92
104
|
* const none = Arr.last(emptyQueue);
|
|
93
105
|
*
|
|
94
106
|
* assert.deepStrictEqual(lastValue, Optional.some('second'));
|
|
107
|
+
*
|
|
95
108
|
* assert.deepStrictEqual(none, Optional.none);
|
|
96
109
|
* ```
|
|
97
110
|
*/
|