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
|
@@ -45,21 +45,29 @@ export type Queue<T> = Readonly<{
|
|
|
45
45
|
* const queue = createQueue<number>();
|
|
46
46
|
*
|
|
47
47
|
* assert.ok(queue.isEmpty);
|
|
48
|
+
*
|
|
48
49
|
* assert(queue.size === 0);
|
|
49
50
|
*
|
|
50
51
|
* queue.enqueue(1);
|
|
52
|
+
*
|
|
51
53
|
* queue.enqueue(2);
|
|
52
54
|
*
|
|
53
55
|
* assert.notOk(queue.isEmpty);
|
|
56
|
+
*
|
|
54
57
|
* assert(queue.size === 2);
|
|
58
|
+
*
|
|
55
59
|
* assert.deepStrictEqual(queue.dequeue(), Optional.some(1));
|
|
60
|
+
*
|
|
56
61
|
* assert.deepStrictEqual(queue.dequeue(), Optional.some(2));
|
|
62
|
+
*
|
|
57
63
|
* assert.deepStrictEqual(queue.dequeue(), Optional.none);
|
|
58
64
|
*
|
|
59
65
|
* const seededQueue = createQueue(['first', 'second']);
|
|
60
66
|
*
|
|
61
67
|
* assert(seededQueue.size === 2);
|
|
68
|
+
*
|
|
62
69
|
* assert.deepStrictEqual(seededQueue.dequeue(), Optional.some('first'));
|
|
70
|
+
*
|
|
63
71
|
* assert.deepStrictEqual(seededQueue.dequeue(), Optional.some('second'));
|
|
64
72
|
* ```
|
|
65
73
|
*/
|
|
@@ -74,21 +82,29 @@ export type Queue<T> = Readonly<{
|
|
|
74
82
|
* const queue = createQueue<number>();
|
|
75
83
|
*
|
|
76
84
|
* assert.ok(queue.isEmpty);
|
|
85
|
+
*
|
|
77
86
|
* assert(queue.size === 0);
|
|
78
87
|
*
|
|
79
88
|
* queue.enqueue(1);
|
|
89
|
+
*
|
|
80
90
|
* queue.enqueue(2);
|
|
81
91
|
*
|
|
82
92
|
* assert.notOk(queue.isEmpty);
|
|
93
|
+
*
|
|
83
94
|
* assert(queue.size === 2);
|
|
95
|
+
*
|
|
84
96
|
* assert.deepStrictEqual(queue.dequeue(), Optional.some(1));
|
|
97
|
+
*
|
|
85
98
|
* assert.deepStrictEqual(queue.dequeue(), Optional.some(2));
|
|
99
|
+
*
|
|
86
100
|
* assert.deepStrictEqual(queue.dequeue(), Optional.none);
|
|
87
101
|
*
|
|
88
102
|
* const seededQueue = createQueue(['first', 'second']);
|
|
89
103
|
*
|
|
90
104
|
* assert(seededQueue.size === 2);
|
|
105
|
+
*
|
|
91
106
|
* assert.deepStrictEqual(seededQueue.dequeue(), Optional.some('first'));
|
|
107
|
+
*
|
|
92
108
|
* assert.deepStrictEqual(seededQueue.dequeue(), Optional.some('second'));
|
|
93
109
|
* ```
|
|
94
110
|
*/
|
|
@@ -103,21 +119,29 @@ export type Queue<T> = Readonly<{
|
|
|
103
119
|
* const queue = createQueue<number>();
|
|
104
120
|
*
|
|
105
121
|
* assert.ok(queue.isEmpty);
|
|
122
|
+
*
|
|
106
123
|
* assert(queue.size === 0);
|
|
107
124
|
*
|
|
108
125
|
* queue.enqueue(1);
|
|
126
|
+
*
|
|
109
127
|
* queue.enqueue(2);
|
|
110
128
|
*
|
|
111
129
|
* assert.notOk(queue.isEmpty);
|
|
130
|
+
*
|
|
112
131
|
* assert(queue.size === 2);
|
|
132
|
+
*
|
|
113
133
|
* assert.deepStrictEqual(queue.dequeue(), Optional.some(1));
|
|
134
|
+
*
|
|
114
135
|
* assert.deepStrictEqual(queue.dequeue(), Optional.some(2));
|
|
136
|
+
*
|
|
115
137
|
* assert.deepStrictEqual(queue.dequeue(), Optional.none);
|
|
116
138
|
*
|
|
117
139
|
* const seededQueue = createQueue(['first', 'second']);
|
|
118
140
|
*
|
|
119
141
|
* assert(seededQueue.size === 2);
|
|
142
|
+
*
|
|
120
143
|
* assert.deepStrictEqual(seededQueue.dequeue(), Optional.some('first'));
|
|
144
|
+
*
|
|
121
145
|
* assert.deepStrictEqual(seededQueue.dequeue(), Optional.some('second'));
|
|
122
146
|
* ```
|
|
123
147
|
*
|
|
@@ -135,21 +159,29 @@ export type Queue<T> = Readonly<{
|
|
|
135
159
|
* const queue = createQueue<number>();
|
|
136
160
|
*
|
|
137
161
|
* assert.ok(queue.isEmpty);
|
|
162
|
+
*
|
|
138
163
|
* assert(queue.size === 0);
|
|
139
164
|
*
|
|
140
165
|
* queue.enqueue(1);
|
|
166
|
+
*
|
|
141
167
|
* queue.enqueue(2);
|
|
142
168
|
*
|
|
143
169
|
* assert.notOk(queue.isEmpty);
|
|
170
|
+
*
|
|
144
171
|
* assert(queue.size === 2);
|
|
172
|
+
*
|
|
145
173
|
* assert.deepStrictEqual(queue.dequeue(), Optional.some(1));
|
|
174
|
+
*
|
|
146
175
|
* assert.deepStrictEqual(queue.dequeue(), Optional.some(2));
|
|
176
|
+
*
|
|
147
177
|
* assert.deepStrictEqual(queue.dequeue(), Optional.none);
|
|
148
178
|
*
|
|
149
179
|
* const seededQueue = createQueue(['first', 'second']);
|
|
150
180
|
*
|
|
151
181
|
* assert(seededQueue.size === 2);
|
|
182
|
+
*
|
|
152
183
|
* assert.deepStrictEqual(seededQueue.dequeue(), Optional.some('first'));
|
|
184
|
+
*
|
|
153
185
|
* assert.deepStrictEqual(seededQueue.dequeue(), Optional.some('second'));
|
|
154
186
|
* ```
|
|
155
187
|
*
|
|
@@ -206,8 +238,11 @@ class QueueClass<T> implements Queue<T> {
|
|
|
206
238
|
);
|
|
207
239
|
|
|
208
240
|
this.#head = 0;
|
|
241
|
+
|
|
209
242
|
this.#tail = 0;
|
|
243
|
+
|
|
210
244
|
this.#mut_size = 0;
|
|
245
|
+
|
|
211
246
|
this.#capacity = initialCapacity;
|
|
212
247
|
|
|
213
248
|
// Add initial values
|
|
@@ -247,8 +282,11 @@ class QueueClass<T> implements Queue<T> {
|
|
|
247
282
|
|
|
248
283
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
249
284
|
const element = this.#buffer[this.#head]!;
|
|
285
|
+
|
|
250
286
|
this.#buffer[this.#head] = undefined; // Clear reference for garbage collection
|
|
287
|
+
|
|
251
288
|
this.#head = (this.#head + 1) % this.#capacity;
|
|
289
|
+
|
|
252
290
|
this.#mut_size -= 1;
|
|
253
291
|
|
|
254
292
|
return Optional.some(element);
|
|
@@ -278,7 +316,9 @@ class QueueClass<T> implements Queue<T> {
|
|
|
278
316
|
}
|
|
279
317
|
|
|
280
318
|
this.#buffer[this.#tail] = value;
|
|
319
|
+
|
|
281
320
|
this.#tail = (this.#tail + 1) % this.#capacity;
|
|
321
|
+
|
|
282
322
|
this.#mut_size += 1;
|
|
283
323
|
}
|
|
284
324
|
|
|
@@ -289,6 +329,7 @@ class QueueClass<T> implements Queue<T> {
|
|
|
289
329
|
*/
|
|
290
330
|
#resize(): void {
|
|
291
331
|
const newCapacity = asUint32(this.#capacity * 2);
|
|
332
|
+
|
|
292
333
|
const newBuffer = Array.from<unknown, T | undefined>(
|
|
293
334
|
{ length: newCapacity },
|
|
294
335
|
() => undefined,
|
|
@@ -297,12 +338,16 @@ class QueueClass<T> implements Queue<T> {
|
|
|
297
338
|
// Copy elements in order from head to tail
|
|
298
339
|
for (const i of range(asSafeUint(this.#mut_size))) {
|
|
299
340
|
const sourceIndex = (this.#head + i) % this.#capacity;
|
|
341
|
+
|
|
300
342
|
newBuffer[i] = this.#buffer[sourceIndex];
|
|
301
343
|
}
|
|
302
344
|
|
|
303
345
|
this.#buffer = newBuffer;
|
|
346
|
+
|
|
304
347
|
this.#head = 0;
|
|
348
|
+
|
|
305
349
|
this.#tail = this.#mut_size;
|
|
350
|
+
|
|
306
351
|
this.#capacity = newCapacity;
|
|
307
352
|
}
|
|
308
353
|
}
|
|
@@ -337,21 +382,29 @@ class QueueClass<T> implements Queue<T> {
|
|
|
337
382
|
* const queue = createQueue<number>();
|
|
338
383
|
*
|
|
339
384
|
* assert.ok(queue.isEmpty);
|
|
385
|
+
*
|
|
340
386
|
* assert(queue.size === 0);
|
|
341
387
|
*
|
|
342
388
|
* queue.enqueue(1);
|
|
389
|
+
*
|
|
343
390
|
* queue.enqueue(2);
|
|
344
391
|
*
|
|
345
392
|
* assert.notOk(queue.isEmpty);
|
|
393
|
+
*
|
|
346
394
|
* assert(queue.size === 2);
|
|
395
|
+
*
|
|
347
396
|
* assert.deepStrictEqual(queue.dequeue(), Optional.some(1));
|
|
397
|
+
*
|
|
348
398
|
* assert.deepStrictEqual(queue.dequeue(), Optional.some(2));
|
|
399
|
+
*
|
|
349
400
|
* assert.deepStrictEqual(queue.dequeue(), Optional.none);
|
|
350
401
|
*
|
|
351
402
|
* const seededQueue = createQueue(['first', 'second']);
|
|
352
403
|
*
|
|
353
404
|
* assert(seededQueue.size === 2);
|
|
405
|
+
*
|
|
354
406
|
* assert.deepStrictEqual(seededQueue.dequeue(), Optional.some('first'));
|
|
407
|
+
*
|
|
355
408
|
* assert.deepStrictEqual(seededQueue.dequeue(), Optional.some('second'));
|
|
356
409
|
* ```
|
|
357
410
|
*
|
|
@@ -10,6 +10,7 @@ describe('Queue test', () => {
|
|
|
10
10
|
const q = createQueue();
|
|
11
11
|
|
|
12
12
|
expect(q.isEmpty).toBe(true);
|
|
13
|
+
|
|
13
14
|
expect(q.size).toBe(0);
|
|
14
15
|
});
|
|
15
16
|
|
|
@@ -17,6 +18,7 @@ describe('Queue test', () => {
|
|
|
17
18
|
const q = createQueue([1, 2, 3]);
|
|
18
19
|
|
|
19
20
|
expect(q.isEmpty).toBe(false);
|
|
21
|
+
|
|
20
22
|
expect(q.size).toBe(3);
|
|
21
23
|
});
|
|
22
24
|
});
|
|
@@ -33,11 +35,13 @@ describe('Queue test', () => {
|
|
|
33
35
|
mut_q.enqueue(1);
|
|
34
36
|
|
|
35
37
|
expect(mut_q.isEmpty).toBe(false);
|
|
38
|
+
|
|
36
39
|
expect(mut_q.size).toBe(1);
|
|
37
40
|
});
|
|
38
41
|
|
|
39
42
|
test('should increase size when enqueueing to a non-empty queue', () => {
|
|
40
43
|
mut_q.enqueue(1);
|
|
44
|
+
|
|
41
45
|
mut_q.enqueue(2);
|
|
42
46
|
|
|
43
47
|
expect(mut_q.size).toBe(2);
|
|
@@ -47,15 +51,19 @@ describe('Queue test', () => {
|
|
|
47
51
|
describe('dequeue', () => {
|
|
48
52
|
test('should return Optional.none and size should be 0 when dequeuing from an empty queue', () => {
|
|
49
53
|
const q = createQueue<number>();
|
|
54
|
+
|
|
50
55
|
const result = q.dequeue();
|
|
51
56
|
|
|
52
57
|
expect(Optional.isNone(result)).toBe(true);
|
|
58
|
+
|
|
53
59
|
expect(q.isEmpty).toBe(true);
|
|
60
|
+
|
|
54
61
|
expect(q.size).toBe(0);
|
|
55
62
|
});
|
|
56
63
|
|
|
57
64
|
test('should decrease size and return the dequeued element for a non-empty queue', () => {
|
|
58
65
|
const q = createQueue([1, 2, 3]); // FIFO: elements are in order [1, 2, 3]
|
|
66
|
+
|
|
59
67
|
const initialSize = q.size;
|
|
60
68
|
|
|
61
69
|
const result1 = q.dequeue(); // Dequeues 1 (first element)
|
|
@@ -81,10 +89,13 @@ describe('Queue test', () => {
|
|
|
81
89
|
|
|
82
90
|
test('should become empty after dequeuing all elements', () => {
|
|
83
91
|
const q = createQueue([1, 2]); // Internal: [1, 2]
|
|
92
|
+
|
|
84
93
|
q.dequeue(); // Dequeues 1
|
|
94
|
+
|
|
85
95
|
q.dequeue(); // Dequeues 2
|
|
86
96
|
|
|
87
97
|
expect(q.isEmpty).toBe(true);
|
|
98
|
+
|
|
88
99
|
expect(q.size).toBe(0);
|
|
89
100
|
|
|
90
101
|
const result = q.dequeue(); // Dequeue from empty
|
|
@@ -96,8 +107,11 @@ describe('Queue test', () => {
|
|
|
96
107
|
describe('FIFO behavior', () => {
|
|
97
108
|
test('elements should be dequeued in first-in, first-out order', () => {
|
|
98
109
|
const q = createQueue<number>();
|
|
110
|
+
|
|
99
111
|
q.enqueue(1); // internal: [1]
|
|
112
|
+
|
|
100
113
|
q.enqueue(2); // internal: [1, 2]
|
|
114
|
+
|
|
101
115
|
q.enqueue(3); // internal: [1, 2, 3]
|
|
102
116
|
|
|
103
117
|
expect(q.size).toBe(3);
|
|
@@ -105,17 +119,21 @@ describe('Queue test', () => {
|
|
|
105
119
|
let mut_result = q.dequeue(); // Dequeues 1 (first in)
|
|
106
120
|
|
|
107
121
|
expect(Optional.isSome(mut_result) && mut_result.value === 1).toBe(true);
|
|
122
|
+
|
|
108
123
|
expect(q.size).toBe(2);
|
|
109
124
|
|
|
110
125
|
mut_result = q.dequeue(); // Dequeues 2
|
|
111
126
|
|
|
112
127
|
expect(Optional.isSome(mut_result) && mut_result.value === 2).toBe(true);
|
|
128
|
+
|
|
113
129
|
expect(q.size).toBe(1);
|
|
114
130
|
|
|
115
131
|
mut_result = q.dequeue(); // Dequeues 3
|
|
116
132
|
|
|
117
133
|
expect(Optional.isSome(mut_result) && mut_result.value === 3).toBe(true);
|
|
134
|
+
|
|
118
135
|
expect(q.size).toBe(0);
|
|
136
|
+
|
|
119
137
|
expect(q.isEmpty).toBe(true);
|
|
120
138
|
|
|
121
139
|
mut_result = q.dequeue();
|
|
@@ -147,6 +165,7 @@ describe('Queue test', () => {
|
|
|
147
165
|
const q = createQueue<string>();
|
|
148
166
|
|
|
149
167
|
q.enqueue('A');
|
|
168
|
+
|
|
150
169
|
q.enqueue('B');
|
|
151
170
|
|
|
152
171
|
const result1 = q.dequeue();
|
|
@@ -154,6 +173,7 @@ describe('Queue test', () => {
|
|
|
154
173
|
expect(Optional.isSome(result1) && result1.value === 'A').toBe(true);
|
|
155
174
|
|
|
156
175
|
q.enqueue('C');
|
|
176
|
+
|
|
157
177
|
q.enqueue('D');
|
|
158
178
|
|
|
159
179
|
const result2 = q.dequeue();
|
|
@@ -183,19 +203,27 @@ describe('Queue test', () => {
|
|
|
183
203
|
|
|
184
204
|
// Remove first 3 elements
|
|
185
205
|
expect(Optional.unwrap(q.dequeue())).toBe(1);
|
|
206
|
+
|
|
186
207
|
expect(Optional.unwrap(q.dequeue())).toBe(2);
|
|
208
|
+
|
|
187
209
|
expect(Optional.unwrap(q.dequeue())).toBe(3);
|
|
188
210
|
|
|
189
211
|
// Add more elements (this should wrap around in the buffer)
|
|
190
212
|
q.enqueue(6);
|
|
213
|
+
|
|
191
214
|
q.enqueue(7);
|
|
215
|
+
|
|
192
216
|
q.enqueue(8);
|
|
193
217
|
|
|
194
218
|
// Verify FIFO order is maintained
|
|
195
219
|
expect(Optional.unwrap(q.dequeue())).toBe(4);
|
|
220
|
+
|
|
196
221
|
expect(Optional.unwrap(q.dequeue())).toBe(5);
|
|
222
|
+
|
|
197
223
|
expect(Optional.unwrap(q.dequeue())).toBe(6);
|
|
224
|
+
|
|
198
225
|
expect(Optional.unwrap(q.dequeue())).toBe(7);
|
|
226
|
+
|
|
199
227
|
expect(Optional.unwrap(q.dequeue())).toBe(8);
|
|
200
228
|
|
|
201
229
|
expect(q.isEmpty).toBe(true);
|
|
@@ -247,6 +275,7 @@ describe('Queue test', () => {
|
|
|
247
275
|
for (const i of range(51, 101)) {
|
|
248
276
|
expect(Optional.unwrap(q.dequeue())).toBe(i);
|
|
249
277
|
}
|
|
278
|
+
|
|
250
279
|
for (const i of range(101, 151)) {
|
|
251
280
|
expect(Optional.unwrap(q.dequeue())).toBe(i);
|
|
252
281
|
}
|
|
@@ -268,12 +297,14 @@ describe('Queue test', () => {
|
|
|
268
297
|
expect(Optional.isSome(result) && result.value === `item-${i}`).toBe(
|
|
269
298
|
true,
|
|
270
299
|
);
|
|
300
|
+
|
|
271
301
|
expect(q.isEmpty).toBe(true);
|
|
272
302
|
}
|
|
273
303
|
});
|
|
274
304
|
|
|
275
305
|
test('should handle large initial values array', () => {
|
|
276
306
|
const largeArray = Arr.range(1, asUint32(51));
|
|
307
|
+
|
|
277
308
|
const q = createQueue(largeArray);
|
|
278
309
|
|
|
279
310
|
expect(q.size).toBe(50);
|
|
@@ -288,6 +319,7 @@ describe('Queue test', () => {
|
|
|
288
319
|
|
|
289
320
|
test('should properly clean up references for garbage collection', () => {
|
|
290
321
|
const q = createQueue<{ id: number }>();
|
|
322
|
+
|
|
291
323
|
const objects = Arr.seq(10).map((i) => ({ id: i }));
|
|
292
324
|
|
|
293
325
|
// Add all objects
|
|
@@ -45,21 +45,28 @@ export type Stack<T> = Readonly<{
|
|
|
45
45
|
* const stack = createStack<string>();
|
|
46
46
|
*
|
|
47
47
|
* assert.ok(stack.isEmpty);
|
|
48
|
+
*
|
|
48
49
|
* assert(stack.size === 0);
|
|
49
50
|
*
|
|
50
51
|
* stack.push('first');
|
|
52
|
+
*
|
|
51
53
|
* // eslint-disable-next-line unicorn/prefer-single-call
|
|
52
54
|
* stack.push('second');
|
|
53
55
|
*
|
|
54
56
|
* assert.notOk(stack.isEmpty);
|
|
57
|
+
*
|
|
55
58
|
* assert(stack.size === 2);
|
|
59
|
+
*
|
|
56
60
|
* assert.deepStrictEqual(stack.pop(), Optional.some('second'));
|
|
61
|
+
*
|
|
57
62
|
* assert.deepStrictEqual(stack.pop(), Optional.some('first'));
|
|
63
|
+
*
|
|
58
64
|
* assert.deepStrictEqual(stack.pop(), Optional.none);
|
|
59
65
|
*
|
|
60
66
|
* const seededStack = createStack([10, 20, 30]);
|
|
61
67
|
*
|
|
62
68
|
* assert(seededStack.size === 3);
|
|
69
|
+
*
|
|
63
70
|
* assert.deepStrictEqual(seededStack.pop(), Optional.some(30));
|
|
64
71
|
* ```
|
|
65
72
|
*/
|
|
@@ -74,21 +81,28 @@ export type Stack<T> = Readonly<{
|
|
|
74
81
|
* const stack = createStack<string>();
|
|
75
82
|
*
|
|
76
83
|
* assert.ok(stack.isEmpty);
|
|
84
|
+
*
|
|
77
85
|
* assert(stack.size === 0);
|
|
78
86
|
*
|
|
79
87
|
* stack.push('first');
|
|
88
|
+
*
|
|
80
89
|
* // eslint-disable-next-line unicorn/prefer-single-call
|
|
81
90
|
* stack.push('second');
|
|
82
91
|
*
|
|
83
92
|
* assert.notOk(stack.isEmpty);
|
|
93
|
+
*
|
|
84
94
|
* assert(stack.size === 2);
|
|
95
|
+
*
|
|
85
96
|
* assert.deepStrictEqual(stack.pop(), Optional.some('second'));
|
|
97
|
+
*
|
|
86
98
|
* assert.deepStrictEqual(stack.pop(), Optional.some('first'));
|
|
99
|
+
*
|
|
87
100
|
* assert.deepStrictEqual(stack.pop(), Optional.none);
|
|
88
101
|
*
|
|
89
102
|
* const seededStack = createStack([10, 20, 30]);
|
|
90
103
|
*
|
|
91
104
|
* assert(seededStack.size === 3);
|
|
105
|
+
*
|
|
92
106
|
* assert.deepStrictEqual(seededStack.pop(), Optional.some(30));
|
|
93
107
|
* ```
|
|
94
108
|
*/
|
|
@@ -103,21 +117,28 @@ export type Stack<T> = Readonly<{
|
|
|
103
117
|
* const stack = createStack<string>();
|
|
104
118
|
*
|
|
105
119
|
* assert.ok(stack.isEmpty);
|
|
120
|
+
*
|
|
106
121
|
* assert(stack.size === 0);
|
|
107
122
|
*
|
|
108
123
|
* stack.push('first');
|
|
124
|
+
*
|
|
109
125
|
* // eslint-disable-next-line unicorn/prefer-single-call
|
|
110
126
|
* stack.push('second');
|
|
111
127
|
*
|
|
112
128
|
* assert.notOk(stack.isEmpty);
|
|
129
|
+
*
|
|
113
130
|
* assert(stack.size === 2);
|
|
131
|
+
*
|
|
114
132
|
* assert.deepStrictEqual(stack.pop(), Optional.some('second'));
|
|
133
|
+
*
|
|
115
134
|
* assert.deepStrictEqual(stack.pop(), Optional.some('first'));
|
|
135
|
+
*
|
|
116
136
|
* assert.deepStrictEqual(stack.pop(), Optional.none);
|
|
117
137
|
*
|
|
118
138
|
* const seededStack = createStack([10, 20, 30]);
|
|
119
139
|
*
|
|
120
140
|
* assert(seededStack.size === 3);
|
|
141
|
+
*
|
|
121
142
|
* assert.deepStrictEqual(seededStack.pop(), Optional.some(30));
|
|
122
143
|
* ```
|
|
123
144
|
*
|
|
@@ -135,21 +156,28 @@ export type Stack<T> = Readonly<{
|
|
|
135
156
|
* const stack = createStack<string>();
|
|
136
157
|
*
|
|
137
158
|
* assert.ok(stack.isEmpty);
|
|
159
|
+
*
|
|
138
160
|
* assert(stack.size === 0);
|
|
139
161
|
*
|
|
140
162
|
* stack.push('first');
|
|
163
|
+
*
|
|
141
164
|
* // eslint-disable-next-line unicorn/prefer-single-call
|
|
142
165
|
* stack.push('second');
|
|
143
166
|
*
|
|
144
167
|
* assert.notOk(stack.isEmpty);
|
|
168
|
+
*
|
|
145
169
|
* assert(stack.size === 2);
|
|
170
|
+
*
|
|
146
171
|
* assert.deepStrictEqual(stack.pop(), Optional.some('second'));
|
|
172
|
+
*
|
|
147
173
|
* assert.deepStrictEqual(stack.pop(), Optional.some('first'));
|
|
174
|
+
*
|
|
148
175
|
* assert.deepStrictEqual(stack.pop(), Optional.none);
|
|
149
176
|
*
|
|
150
177
|
* const seededStack = createStack([10, 20, 30]);
|
|
151
178
|
*
|
|
152
179
|
* assert(seededStack.size === 3);
|
|
180
|
+
*
|
|
153
181
|
* assert.deepStrictEqual(seededStack.pop(), Optional.some(30));
|
|
154
182
|
* ```
|
|
155
183
|
*
|
|
@@ -197,7 +225,9 @@ class StackClass<T> implements Stack<T> {
|
|
|
197
225
|
{ length: initialCapacity },
|
|
198
226
|
() => undefined,
|
|
199
227
|
);
|
|
228
|
+
|
|
200
229
|
this.#mut_size = asUint32(0);
|
|
230
|
+
|
|
201
231
|
this.#capacity = initialCapacity;
|
|
202
232
|
|
|
203
233
|
// Add initial values
|
|
@@ -236,8 +266,10 @@ class StackClass<T> implements Stack<T> {
|
|
|
236
266
|
}
|
|
237
267
|
|
|
238
268
|
this.#mut_size = Uint32.sub(this.#mut_size, 1);
|
|
269
|
+
|
|
239
270
|
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
240
271
|
const element = this.#buffer[this.#mut_size]!;
|
|
272
|
+
|
|
241
273
|
this.#buffer[this.#mut_size] = undefined; // Clear reference for garbage collection
|
|
242
274
|
|
|
243
275
|
return Optional.some(element);
|
|
@@ -267,6 +299,7 @@ class StackClass<T> implements Stack<T> {
|
|
|
267
299
|
}
|
|
268
300
|
|
|
269
301
|
this.#buffer[this.#mut_size] = value;
|
|
302
|
+
|
|
270
303
|
this.#mut_size = Uint32.add(this.#mut_size, 1);
|
|
271
304
|
}
|
|
272
305
|
|
|
@@ -277,6 +310,7 @@ class StackClass<T> implements Stack<T> {
|
|
|
277
310
|
*/
|
|
278
311
|
#resize(): void {
|
|
279
312
|
const newCapacity = asUint32(this.#capacity * 2);
|
|
313
|
+
|
|
280
314
|
const newBuffer = Array.from<unknown, T | undefined>(
|
|
281
315
|
{ length: newCapacity },
|
|
282
316
|
() => undefined,
|
|
@@ -288,6 +322,7 @@ class StackClass<T> implements Stack<T> {
|
|
|
288
322
|
}
|
|
289
323
|
|
|
290
324
|
this.#buffer = newBuffer;
|
|
325
|
+
|
|
291
326
|
this.#capacity = newCapacity;
|
|
292
327
|
}
|
|
293
328
|
}
|
|
@@ -322,21 +357,28 @@ class StackClass<T> implements Stack<T> {
|
|
|
322
357
|
* const stack = createStack<string>();
|
|
323
358
|
*
|
|
324
359
|
* assert.ok(stack.isEmpty);
|
|
360
|
+
*
|
|
325
361
|
* assert(stack.size === 0);
|
|
326
362
|
*
|
|
327
363
|
* stack.push('first');
|
|
364
|
+
*
|
|
328
365
|
* // eslint-disable-next-line unicorn/prefer-single-call
|
|
329
366
|
* stack.push('second');
|
|
330
367
|
*
|
|
331
368
|
* assert.notOk(stack.isEmpty);
|
|
369
|
+
*
|
|
332
370
|
* assert(stack.size === 2);
|
|
371
|
+
*
|
|
333
372
|
* assert.deepStrictEqual(stack.pop(), Optional.some('second'));
|
|
373
|
+
*
|
|
334
374
|
* assert.deepStrictEqual(stack.pop(), Optional.some('first'));
|
|
375
|
+
*
|
|
335
376
|
* assert.deepStrictEqual(stack.pop(), Optional.none);
|
|
336
377
|
*
|
|
337
378
|
* const seededStack = createStack([10, 20, 30]);
|
|
338
379
|
*
|
|
339
380
|
* assert(seededStack.size === 3);
|
|
381
|
+
*
|
|
340
382
|
* assert.deepStrictEqual(seededStack.pop(), Optional.some(30));
|
|
341
383
|
* ```
|
|
342
384
|
*
|