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
|
@@ -12,7 +12,9 @@ describe('Arr slicing', () => {
|
|
|
12
12
|
describe(tail, () => {
|
|
13
13
|
test('should return all elements except the first', () => {
|
|
14
14
|
const array = [1, 2, 3, 4] as const;
|
|
15
|
+
|
|
15
16
|
const result = tail(array);
|
|
17
|
+
|
|
16
18
|
expectType<typeof result, readonly [2, 3, 4]>('=');
|
|
17
19
|
|
|
18
20
|
assert.deepStrictEqual(result, [2, 3, 4]);
|
|
@@ -20,7 +22,9 @@ describe('Arr slicing', () => {
|
|
|
20
22
|
|
|
21
23
|
test('should work with single element array', () => {
|
|
22
24
|
const array = [1] as const;
|
|
25
|
+
|
|
23
26
|
const result = tail(array);
|
|
27
|
+
|
|
24
28
|
expectType<typeof result, readonly []>('=');
|
|
25
29
|
|
|
26
30
|
assert.deepStrictEqual(result, []);
|
|
@@ -28,7 +32,9 @@ describe('Arr slicing', () => {
|
|
|
28
32
|
|
|
29
33
|
test('should work with empty array', () => {
|
|
30
34
|
const array = [] as const;
|
|
35
|
+
|
|
31
36
|
const result = tail(array);
|
|
37
|
+
|
|
32
38
|
expectType<typeof result, readonly []>('=');
|
|
33
39
|
|
|
34
40
|
assert.deepStrictEqual(result, []);
|
|
@@ -38,6 +44,7 @@ describe('Arr slicing', () => {
|
|
|
38
44
|
describe(butLast, () => {
|
|
39
45
|
test('readonly number[] type', () => {
|
|
40
46
|
const xs: readonly number[] = [1, 2, 3];
|
|
47
|
+
|
|
41
48
|
const bl = butLast(xs);
|
|
42
49
|
|
|
43
50
|
expectType<typeof bl, readonly number[]>('=');
|
|
@@ -47,7 +54,9 @@ describe('Arr slicing', () => {
|
|
|
47
54
|
|
|
48
55
|
test('should return all elements except the last', () => {
|
|
49
56
|
const array = [1, 2, 3, 4] as const;
|
|
57
|
+
|
|
50
58
|
const result = butLast(array);
|
|
59
|
+
|
|
51
60
|
expectType<typeof result, readonly [1, 2, 3]>('=');
|
|
52
61
|
|
|
53
62
|
assert.deepStrictEqual(result, [1, 2, 3]);
|
|
@@ -55,7 +64,9 @@ describe('Arr slicing', () => {
|
|
|
55
64
|
|
|
56
65
|
test('should work with single element array', () => {
|
|
57
66
|
const array = [1] as const;
|
|
67
|
+
|
|
58
68
|
const result = butLast(array);
|
|
69
|
+
|
|
59
70
|
expectType<typeof result, readonly []>('=');
|
|
60
71
|
|
|
61
72
|
assert.deepStrictEqual(result, []);
|
|
@@ -63,7 +74,9 @@ describe('Arr slicing', () => {
|
|
|
63
74
|
|
|
64
75
|
test('should work with empty array', () => {
|
|
65
76
|
const array = [] as const;
|
|
77
|
+
|
|
66
78
|
const result = butLast(array);
|
|
79
|
+
|
|
67
80
|
expectType<typeof result, readonly []>('=');
|
|
68
81
|
|
|
69
82
|
assert.deepStrictEqual(result, []);
|
|
@@ -73,6 +86,7 @@ describe('Arr slicing', () => {
|
|
|
73
86
|
describe(take, () => {
|
|
74
87
|
{
|
|
75
88
|
const xs = [1, 2, 3] as const;
|
|
89
|
+
|
|
76
90
|
const t = take(xs, 2);
|
|
77
91
|
|
|
78
92
|
expectType<typeof t, readonly [1, 2]>('=');
|
|
@@ -81,8 +95,10 @@ describe('Arr slicing', () => {
|
|
|
81
95
|
assert.deepStrictEqual(t, [1, 2]);
|
|
82
96
|
});
|
|
83
97
|
}
|
|
98
|
+
|
|
84
99
|
{
|
|
85
100
|
const xs: readonly number[] = [1, 2, 3];
|
|
101
|
+
|
|
86
102
|
const t = take(xs, 2);
|
|
87
103
|
|
|
88
104
|
expectType<typeof t, readonly number[]>('=');
|
|
@@ -91,11 +107,20 @@ describe('Arr slicing', () => {
|
|
|
91
107
|
assert.deepStrictEqual(t, [1, 2]);
|
|
92
108
|
});
|
|
93
109
|
}
|
|
110
|
+
|
|
111
|
+
test('should work with curried version', () => {
|
|
112
|
+
const takeTwo = take(2);
|
|
113
|
+
|
|
114
|
+
const result = takeTwo([1, 2, 3, 4, 5]);
|
|
115
|
+
|
|
116
|
+
assert.deepStrictEqual(result, [1, 2]);
|
|
117
|
+
});
|
|
94
118
|
});
|
|
95
119
|
|
|
96
120
|
describe(takeLast, () => {
|
|
97
121
|
{
|
|
98
122
|
const xs = [1, 2, 3] as const;
|
|
123
|
+
|
|
99
124
|
const t = takeLast(xs, 2);
|
|
100
125
|
|
|
101
126
|
expectType<typeof t, readonly [2, 3]>('=');
|
|
@@ -104,8 +129,10 @@ describe('Arr slicing', () => {
|
|
|
104
129
|
assert.deepStrictEqual(t, [2, 3]);
|
|
105
130
|
});
|
|
106
131
|
}
|
|
132
|
+
|
|
107
133
|
{
|
|
108
134
|
const xs: readonly number[] = [1, 2, 3];
|
|
135
|
+
|
|
109
136
|
const t = takeLast(xs, 2);
|
|
110
137
|
|
|
111
138
|
expectType<typeof t, readonly number[]>('=');
|
|
@@ -114,11 +141,20 @@ describe('Arr slicing', () => {
|
|
|
114
141
|
assert.deepStrictEqual(t, [2, 3]);
|
|
115
142
|
});
|
|
116
143
|
}
|
|
144
|
+
|
|
145
|
+
test('should work with curried version', () => {
|
|
146
|
+
const takeLastThree = takeLast(3);
|
|
147
|
+
|
|
148
|
+
const result = takeLastThree([1, 2, 3, 4, 5]);
|
|
149
|
+
|
|
150
|
+
assert.deepStrictEqual(result, [3, 4, 5]);
|
|
151
|
+
});
|
|
117
152
|
});
|
|
118
153
|
|
|
119
154
|
describe(skip, () => {
|
|
120
155
|
{
|
|
121
156
|
const xs = [1, 2, 3] as const;
|
|
157
|
+
|
|
122
158
|
const t = skip(xs, 2);
|
|
123
159
|
|
|
124
160
|
expectType<typeof t, readonly [3]>('=');
|
|
@@ -127,8 +163,10 @@ describe('Arr slicing', () => {
|
|
|
127
163
|
assert.deepStrictEqual(t, [3]);
|
|
128
164
|
});
|
|
129
165
|
}
|
|
166
|
+
|
|
130
167
|
{
|
|
131
168
|
const xs: readonly number[] = [1, 2, 3];
|
|
169
|
+
|
|
132
170
|
const t = skip(xs, 2);
|
|
133
171
|
|
|
134
172
|
expectType<typeof t, readonly number[]>('=');
|
|
@@ -137,11 +175,20 @@ describe('Arr slicing', () => {
|
|
|
137
175
|
assert.deepStrictEqual(t, [3]);
|
|
138
176
|
});
|
|
139
177
|
}
|
|
178
|
+
|
|
179
|
+
test('should work with curried version', () => {
|
|
180
|
+
const skipTwo = skip(2);
|
|
181
|
+
|
|
182
|
+
const result = skipTwo([1, 2, 3, 4, 5]);
|
|
183
|
+
|
|
184
|
+
assert.deepStrictEqual(result, [3, 4, 5]);
|
|
185
|
+
});
|
|
140
186
|
});
|
|
141
187
|
|
|
142
188
|
describe(skipLast, () => {
|
|
143
189
|
{
|
|
144
190
|
const xs = [1, 2, 3] as const;
|
|
191
|
+
|
|
145
192
|
const t = skipLast(xs, 2);
|
|
146
193
|
|
|
147
194
|
expectType<typeof t, readonly [1]>('=');
|
|
@@ -150,8 +197,10 @@ describe('Arr slicing', () => {
|
|
|
150
197
|
assert.deepStrictEqual(t, [1]);
|
|
151
198
|
});
|
|
152
199
|
}
|
|
200
|
+
|
|
153
201
|
{
|
|
154
202
|
const xs: readonly number[] = [1, 2, 3];
|
|
203
|
+
|
|
155
204
|
const t = skipLast(xs, 2);
|
|
156
205
|
|
|
157
206
|
expectType<typeof t, readonly number[]>('=');
|
|
@@ -160,5 +209,13 @@ describe('Arr slicing', () => {
|
|
|
160
209
|
assert.deepStrictEqual(t, [1]);
|
|
161
210
|
});
|
|
162
211
|
}
|
|
212
|
+
|
|
213
|
+
test('should work with curried version', () => {
|
|
214
|
+
const skipLastTwo = skipLast(2);
|
|
215
|
+
|
|
216
|
+
const result = skipLastTwo([1, 2, 3, 4, 5]);
|
|
217
|
+
|
|
218
|
+
assert.deepStrictEqual(result, [1, 2, 3]);
|
|
219
|
+
});
|
|
163
220
|
});
|
|
164
221
|
});
|
|
@@ -14,11 +14,13 @@ import { size } from './array-utils-size.mjs';
|
|
|
14
14
|
* const numbers = [1, 2, 3] as const;
|
|
15
15
|
*
|
|
16
16
|
* const doubled = Arr.map(numbers, (value) => value * 2);
|
|
17
|
+
*
|
|
17
18
|
* const indexed = Arr.map<number, string>((value, index) => `${index}:${value}`)(
|
|
18
19
|
* numbers,
|
|
19
20
|
* );
|
|
20
21
|
*
|
|
21
22
|
* assert.deepStrictEqual(doubled, [2, 4, 6]);
|
|
23
|
+
*
|
|
22
24
|
* assert.deepStrictEqual(indexed, ['0:1', '1:2', '2:3']);
|
|
23
25
|
* ```
|
|
24
26
|
*/
|
|
@@ -42,11 +44,14 @@ export function map<A, B>(
|
|
|
42
44
|
switch (args.length) {
|
|
43
45
|
case 2: {
|
|
44
46
|
const [array, mapFn] = args;
|
|
47
|
+
|
|
45
48
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
46
49
|
return array.map(mapFn as never);
|
|
47
50
|
}
|
|
51
|
+
|
|
48
52
|
case 1: {
|
|
49
53
|
const [mapFn] = args;
|
|
54
|
+
|
|
50
55
|
return (array: readonly A[]) => map(array, mapFn);
|
|
51
56
|
}
|
|
52
57
|
}
|
|
@@ -61,15 +66,18 @@ export function map<A, B>(
|
|
|
61
66
|
* const changes = [5, -2, 3] as const;
|
|
62
67
|
*
|
|
63
68
|
* const runningTotals = Arr.scan(changes, (total, change) => total + change, 0);
|
|
69
|
+
*
|
|
64
70
|
* const runningTotalsFromCurried = Arr.scan(
|
|
65
71
|
* (total: number, change: number) => total + change,
|
|
66
72
|
* 10,
|
|
67
73
|
* )([-5, 15]);
|
|
68
74
|
*
|
|
69
75
|
* const expectedTotals = [0, 5, 3, 6] as const;
|
|
76
|
+
*
|
|
70
77
|
* const expectedCurriedTotals = [10, 5, 20] as const;
|
|
71
78
|
*
|
|
72
79
|
* assert.deepStrictEqual(runningTotals, expectedTotals);
|
|
80
|
+
*
|
|
73
81
|
* assert.deepStrictEqual(runningTotalsFromCurried, expectedCurriedTotals);
|
|
74
82
|
* ```
|
|
75
83
|
*/
|
|
@@ -111,6 +119,7 @@ export function scan<E, S>(
|
|
|
111
119
|
switch (args.length) {
|
|
112
120
|
case 3: {
|
|
113
121
|
const [array, reducer, init] = args;
|
|
122
|
+
|
|
114
123
|
const mut_result: MutableNonEmptyArray<S> = castMutable(
|
|
115
124
|
newArray<S, PositiveUint32>(asPositiveUint32(array.length + 1), init),
|
|
116
125
|
);
|
|
@@ -119,13 +128,16 @@ export function scan<E, S>(
|
|
|
119
128
|
|
|
120
129
|
for (const [index, value] of array.entries()) {
|
|
121
130
|
mut_acc = reducer(mut_acc, value, asUint32(index));
|
|
131
|
+
|
|
122
132
|
mut_result[index + 1] = mut_acc;
|
|
123
133
|
}
|
|
124
134
|
|
|
125
135
|
return mut_result;
|
|
126
136
|
}
|
|
137
|
+
|
|
127
138
|
case 2: {
|
|
128
139
|
const [reducer, init] = args;
|
|
140
|
+
|
|
129
141
|
return (array) => scan(array, reducer, init);
|
|
130
142
|
}
|
|
131
143
|
}
|
|
@@ -159,17 +171,21 @@ export const toReversed = <const Ar extends readonly unknown[]>(
|
|
|
159
171
|
*
|
|
160
172
|
* ```ts
|
|
161
173
|
* const numbers = [3, 1, 2] as const;
|
|
174
|
+
*
|
|
162
175
|
* const words = ['banana', 'apple', 'cherry'] as const;
|
|
163
176
|
*
|
|
164
177
|
* const ascendingNumbers = Arr.toSorted(numbers);
|
|
178
|
+
*
|
|
165
179
|
* const alphabetical = Arr.toSorted(words, (left, right) =>
|
|
166
180
|
* left.localeCompare(right),
|
|
167
181
|
* );
|
|
168
182
|
*
|
|
169
183
|
* const expectedNumbers = [1, 2, 3] as const;
|
|
184
|
+
*
|
|
170
185
|
* const expectedWords = ['apple', 'banana', 'cherry'] as const;
|
|
171
186
|
*
|
|
172
187
|
* assert.deepStrictEqual(ascendingNumbers, expectedNumbers);
|
|
188
|
+
*
|
|
173
189
|
* assert.deepStrictEqual(alphabetical, expectedWords);
|
|
174
190
|
* ```
|
|
175
191
|
*/
|
|
@@ -207,6 +223,7 @@ export const toSorted = <const Ar extends readonly unknown[]>(
|
|
|
207
223
|
* ] as const;
|
|
208
224
|
*
|
|
209
225
|
* const byIssueCount = Arr.toSortedBy(projects, (project) => project.issues);
|
|
226
|
+
*
|
|
210
227
|
* const byIssueCountDescending = Arr.toSortedBy(
|
|
211
228
|
* projects,
|
|
212
229
|
* (project) => project.issues,
|
|
@@ -226,6 +243,7 @@ export const toSorted = <const Ar extends readonly unknown[]>(
|
|
|
226
243
|
* ] as const;
|
|
227
244
|
*
|
|
228
245
|
* assert.deepStrictEqual(byIssueCount, expectedByIssues);
|
|
246
|
+
*
|
|
229
247
|
* assert.deepStrictEqual(byIssueCountDescending, expectedByIssueCountDescending);
|
|
230
248
|
* ```
|
|
231
249
|
*/
|
|
@@ -276,9 +294,11 @@ export function toSortedBy<E, const V>(
|
|
|
276
294
|
* const numbers = [1, 2, 3, 4] as const;
|
|
277
295
|
*
|
|
278
296
|
* const evens = Arr.filter(numbers, (value) => value % 2 === 0);
|
|
297
|
+
*
|
|
279
298
|
* const greaterThanTwo = Arr.filter<number>((value) => value > 2)(numbers);
|
|
280
299
|
*
|
|
281
300
|
* assert.deepStrictEqual(evens, [2, 4]);
|
|
301
|
+
*
|
|
282
302
|
* assert.deepStrictEqual(greaterThanTwo, [3, 4]);
|
|
283
303
|
* ```
|
|
284
304
|
*/
|
|
@@ -316,10 +336,13 @@ export function filter<E>(
|
|
|
316
336
|
switch (args.length) {
|
|
317
337
|
case 2: {
|
|
318
338
|
const [array, predicate] = args;
|
|
339
|
+
|
|
319
340
|
return array.filter((a, i) => predicate(a, asUint32(i)));
|
|
320
341
|
}
|
|
342
|
+
|
|
321
343
|
case 1: {
|
|
322
344
|
const [predicate] = args;
|
|
345
|
+
|
|
323
346
|
return (array) => filter(array, predicate);
|
|
324
347
|
}
|
|
325
348
|
}
|
|
@@ -334,9 +357,11 @@ export function filter<E>(
|
|
|
334
357
|
* const names = ['Ada', 'Grace', 'Linus'] as const;
|
|
335
358
|
*
|
|
336
359
|
* const notAda = Arr.filterNot(names, (name) => name === 'Ada');
|
|
360
|
+
*
|
|
337
361
|
* const notShort = Arr.filterNot<string>((name) => name.length <= 4)(names);
|
|
338
362
|
*
|
|
339
363
|
* assert.deepStrictEqual(notAda, ['Grace', 'Linus']);
|
|
364
|
+
*
|
|
340
365
|
* assert.deepStrictEqual(notShort, ['Grace', 'Linus']);
|
|
341
366
|
* ```
|
|
342
367
|
*/
|
|
@@ -360,10 +385,13 @@ export function filterNot<E>(
|
|
|
360
385
|
switch (args.length) {
|
|
361
386
|
case 2: {
|
|
362
387
|
const [array, predicate] = args;
|
|
388
|
+
|
|
363
389
|
return array.filter((a, i) => !predicate(a, asUint32(i)));
|
|
364
390
|
}
|
|
391
|
+
|
|
365
392
|
case 1: {
|
|
366
393
|
const [predicate] = args;
|
|
394
|
+
|
|
367
395
|
return (array) => filterNot(array, predicate);
|
|
368
396
|
}
|
|
369
397
|
}
|
|
@@ -432,6 +460,7 @@ export const uniqBy = <
|
|
|
432
460
|
const mappedValue = mapFn(val);
|
|
433
461
|
|
|
434
462
|
if (mut_mappedValues.has(mappedValue)) return false;
|
|
463
|
+
|
|
435
464
|
mut_mappedValues.add(mappedValue);
|
|
436
465
|
|
|
437
466
|
return true;
|
|
@@ -450,9 +479,11 @@ export const uniqBy = <
|
|
|
450
479
|
* ] as const;
|
|
451
480
|
*
|
|
452
481
|
* const flatOnce = Arr.flat(nested, 1);
|
|
482
|
+
*
|
|
453
483
|
* const flatCurried = Arr.flat()(nested);
|
|
454
484
|
*
|
|
455
485
|
* assert.deepStrictEqual(flatOnce, [1, 2, 3, 4]);
|
|
486
|
+
*
|
|
456
487
|
* assert.deepStrictEqual(flatCurried, [1, 2, 3, 4]);
|
|
457
488
|
* ```
|
|
458
489
|
*/
|
|
@@ -473,17 +504,22 @@ export function flat<E, D extends SafeUintWithSmallInt = 1>(
|
|
|
473
504
|
switch (args.length) {
|
|
474
505
|
case 2: {
|
|
475
506
|
const [array, depth] = args;
|
|
507
|
+
|
|
476
508
|
return array.flat(depth);
|
|
477
509
|
}
|
|
510
|
+
|
|
478
511
|
case 1: {
|
|
479
512
|
const [arrayOrDepth] = args;
|
|
513
|
+
|
|
480
514
|
if (typeof arrayOrDepth === 'number') {
|
|
481
515
|
const depth = arrayOrDepth as SafeUintWithSmallInt | undefined;
|
|
516
|
+
|
|
482
517
|
return (array) => flat(array, depth);
|
|
483
518
|
} else if (arrayOrDepth === undefined) {
|
|
484
519
|
return (array) => flat(array, 1);
|
|
485
520
|
} else {
|
|
486
521
|
expectType<typeof arrayOrDepth, readonly E[]>('=');
|
|
522
|
+
|
|
487
523
|
return arrayOrDepth.flat();
|
|
488
524
|
}
|
|
489
525
|
}
|
|
@@ -502,11 +538,13 @@ export function flat<E, D extends SafeUintWithSmallInt = 1>(
|
|
|
502
538
|
* const words = ['Ada', 'AI'] as const;
|
|
503
539
|
*
|
|
504
540
|
* const characters = Arr.flatMap(words, (word) => word.split(''));
|
|
541
|
+
*
|
|
505
542
|
* const labeled = Arr.flatMap<string, string>((word, index) =>
|
|
506
543
|
* word.split('').map((char) => `${index}-${char}`),
|
|
507
544
|
* )(words);
|
|
508
545
|
*
|
|
509
546
|
* assert.deepStrictEqual(characters, ['A', 'd', 'a', 'A', 'I']);
|
|
547
|
+
*
|
|
510
548
|
* assert.deepStrictEqual(labeled, ['0-A', '0-d', '0-a', '1-A', '1-I']);
|
|
511
549
|
* ```
|
|
512
550
|
*/
|
|
@@ -530,10 +568,13 @@ export function flatMap<A, B>(
|
|
|
530
568
|
switch (args.length) {
|
|
531
569
|
case 2: {
|
|
532
570
|
const [array, mapFn] = args;
|
|
571
|
+
|
|
533
572
|
return array.flatMap((a, i) => mapFn(a, asUint32(i)));
|
|
534
573
|
}
|
|
574
|
+
|
|
535
575
|
case 1: {
|
|
536
576
|
const [mapFn] = args;
|
|
577
|
+
|
|
537
578
|
return (array: readonly A[]) => flatMap(array, mapFn);
|
|
538
579
|
}
|
|
539
580
|
}
|
|
@@ -548,11 +589,13 @@ export function flatMap<A, B>(
|
|
|
548
589
|
* const values = [1, 2, 3, 4, 5] as const;
|
|
549
590
|
*
|
|
550
591
|
* const pairs = Arr.partition(values, 2);
|
|
592
|
+
*
|
|
551
593
|
* const triples = Arr.partition(3)(values);
|
|
552
594
|
*
|
|
553
595
|
* const expectedPairs = [[1, 2], [3, 4], [5]] as const;
|
|
554
596
|
*
|
|
555
597
|
* assert.deepStrictEqual(pairs, expectedPairs);
|
|
598
|
+
*
|
|
556
599
|
* assert.deepStrictEqual(triples, [
|
|
557
600
|
* [1, 2, 3],
|
|
558
601
|
* [4, 5],
|
|
@@ -589,6 +632,7 @@ export function partition<
|
|
|
589
632
|
switch (args.length) {
|
|
590
633
|
case 2: {
|
|
591
634
|
const [array, chunkSize] = args;
|
|
635
|
+
|
|
592
636
|
return chunkSize < 2
|
|
593
637
|
? []
|
|
594
638
|
: // eslint-disable-next-line total-functions/no-partial-division
|
|
@@ -596,8 +640,10 @@ export function partition<
|
|
|
596
640
|
array.slice(chunkSize * i, chunkSize * (i + 1)),
|
|
597
641
|
);
|
|
598
642
|
}
|
|
643
|
+
|
|
599
644
|
case 1: {
|
|
600
645
|
const [chunkSize] = args;
|
|
646
|
+
|
|
601
647
|
return (array) => partition(array, chunkSize);
|
|
602
648
|
}
|
|
603
649
|
}
|
|
@@ -610,6 +656,7 @@ export function partition<
|
|
|
610
656
|
*
|
|
611
657
|
* ```ts
|
|
612
658
|
* const numbers = [1, 2] as const;
|
|
659
|
+
*
|
|
613
660
|
* const words = ['three', 'four'] as const;
|
|
614
661
|
*
|
|
615
662
|
* const combined = Arr.concat(numbers, words);
|
|
@@ -636,6 +683,7 @@ export const concat = <
|
|
|
636
683
|
* const animals = ['ant', 'bat', 'cat', 'dove'] as const;
|
|
637
684
|
*
|
|
638
685
|
* const groupedByLength = Arr.groupBy(animals, (animal) => animal.length);
|
|
686
|
+
*
|
|
639
687
|
* const groupedByFirstLetter = Arr.groupBy((animal: string) => animal[0])(
|
|
640
688
|
* animals,
|
|
641
689
|
* );
|
|
@@ -644,16 +692,19 @@ export const concat = <
|
|
|
644
692
|
* groupedByLength.get(3),
|
|
645
693
|
* Optional.some(['ant', 'bat', 'cat'] as const),
|
|
646
694
|
* );
|
|
695
|
+
*
|
|
647
696
|
* assert.deepStrictEqual(
|
|
648
697
|
* groupedByLength.get(4),
|
|
649
698
|
* Optional.some(['dove'] as const),
|
|
650
699
|
* );
|
|
700
|
+
*
|
|
651
701
|
* assert.deepStrictEqual(groupedByLength.get(5), Optional.none);
|
|
652
702
|
*
|
|
653
703
|
* assert.deepStrictEqual(
|
|
654
704
|
* groupedByFirstLetter.get('a'),
|
|
655
705
|
* Optional.some(['ant'] as const),
|
|
656
706
|
* );
|
|
707
|
+
*
|
|
657
708
|
* assert.deepStrictEqual(
|
|
658
709
|
* groupedByFirstLetter.get('d'),
|
|
659
710
|
* Optional.some(['dove'] as const),
|
|
@@ -683,22 +734,28 @@ export function groupBy<E, G extends MapSetKeyType>(
|
|
|
683
734
|
switch (args.length) {
|
|
684
735
|
case 2: {
|
|
685
736
|
const [array, grouper] = args;
|
|
737
|
+
|
|
686
738
|
const mut_groups = new Map<G, E[]>(); // Store mutable arrays internally
|
|
687
739
|
|
|
688
740
|
for (const [index, e] of array.entries()) {
|
|
689
741
|
const key = grouper(e, asUint32(index)); // Ensure index is treated as SizeType.Arr
|
|
742
|
+
|
|
690
743
|
const mut_group = mut_groups.get(key);
|
|
744
|
+
|
|
691
745
|
if (mut_group !== undefined) {
|
|
692
746
|
mut_group.push(e);
|
|
693
747
|
} else {
|
|
694
748
|
mut_groups.set(key, [e]);
|
|
695
749
|
}
|
|
696
750
|
}
|
|
751
|
+
|
|
697
752
|
// Cast to IMap<G, readonly A[]> for the public interface
|
|
698
753
|
return IMap.create<G, readonly E[]>(mut_groups);
|
|
699
754
|
}
|
|
755
|
+
|
|
700
756
|
case 1: {
|
|
701
757
|
const [grouper] = args;
|
|
758
|
+
|
|
702
759
|
return (array: readonly E[]) => groupBy(array, grouper);
|
|
703
760
|
}
|
|
704
761
|
}
|
|
@@ -711,6 +768,7 @@ export function groupBy<E, G extends MapSetKeyType>(
|
|
|
711
768
|
*
|
|
712
769
|
* ```ts
|
|
713
770
|
* const letters = ['a', 'b', 'c'] as const;
|
|
771
|
+
*
|
|
714
772
|
* const numbers = [1, 2, 3] as const;
|
|
715
773
|
*
|
|
716
774
|
* const pairs = Arr.zip(letters, numbers);
|