ts-data-forge 14.6.1 → 14.6.2
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/dist/array/impl/array-utils-creation.mjs +126 -26
- package/dist/array/impl/array-utils-creation.mjs.map +1 -1
- package/dist/array/impl/array-utils-element-access.mjs +63 -30
- package/dist/array/impl/array-utils-element-access.mjs.map +1 -1
- package/dist/array/impl/array-utils-iterators.mjs +69 -53
- package/dist/array/impl/array-utils-iterators.mjs.map +1 -1
- package/dist/array/impl/array-utils-length-bounded-array-cast.mjs +109 -73
- package/dist/array/impl/array-utils-length-bounded-array-cast.mjs.map +1 -1
- package/dist/array/impl/array-utils-length-bounded-array-guard.mjs +71 -33
- package/dist/array/impl/array-utils-length-bounded-array-guard.mjs.map +1 -1
- package/dist/array/impl/array-utils-length-bounded-tuple-cast.mjs +102 -73
- package/dist/array/impl/array-utils-length-bounded-tuple-cast.mjs.map +1 -1
- package/dist/array/impl/array-utils-length-bounded-tuple-guard.mjs +77 -33
- package/dist/array/impl/array-utils-length-bounded-tuple-guard.mjs.map +1 -1
- package/dist/array/impl/array-utils-modification.mjs +75 -122
- package/dist/array/impl/array-utils-modification.mjs.map +1 -1
- package/dist/array/impl/array-utils-reducing-value.mjs +100 -150
- package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
- package/dist/array/impl/array-utils-search.mjs +110 -134
- package/dist/array/impl/array-utils-search.mjs.map +1 -1
- package/dist/array/impl/array-utils-set-op.mjs +146 -38
- package/dist/array/impl/array-utils-set-op.mjs.map +1 -1
- package/dist/array/impl/array-utils-size.mjs +10 -8
- package/dist/array/impl/array-utils-size.mjs.map +1 -1
- package/dist/array/impl/array-utils-slice-clamped.mjs +13 -50
- package/dist/array/impl/array-utils-slice-clamped.mjs.map +1 -1
- package/dist/array/impl/array-utils-slicing.mjs +94 -78
- package/dist/array/impl/array-utils-slicing.mjs.map +1 -1
- package/dist/array/impl/array-utils-transformation.mjs +291 -199
- package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
- package/dist/array/impl/array-utils-validation.mjs +54 -56
- package/dist/array/impl/array-utils-validation.mjs.map +1 -1
- package/dist/array/impl/index.mjs +17 -17
- package/dist/array/impl/index.mjs.map +1 -1
- package/dist/array/index.mjs +2 -3
- package/dist/array/index.mjs.map +1 -1
- package/dist/collections/imap-mapped.mjs +335 -292
- package/dist/collections/imap-mapped.mjs.map +1 -1
- package/dist/collections/imap.mjs +280 -239
- package/dist/collections/imap.mjs.map +1 -1
- package/dist/collections/index.mjs +7 -7
- package/dist/collections/index.mjs.map +1 -1
- package/dist/collections/iset-mapped.mjs +448 -265
- package/dist/collections/iset-mapped.mjs.map +1 -1
- package/dist/collections/iset.mjs +328 -201
- package/dist/collections/iset.mjs.map +1 -1
- package/dist/collections/queue.mjs +183 -151
- package/dist/collections/queue.mjs.map +1 -1
- package/dist/collections/stack.mjs +169 -140
- package/dist/collections/stack.mjs.map +1 -1
- package/dist/entry-point.mjs +4 -77
- package/dist/entry-point.mjs.map +1 -1
- package/dist/expect-type.mjs +70 -4
- package/dist/expect-type.mjs.map +1 -1
- package/dist/functional/async-result/async-result.mjs +2 -3
- package/dist/functional/async-result/async-result.mjs.map +1 -1
- package/dist/functional/async-result/impl/async-result-flat-map.mjs +19 -21
- package/dist/functional/async-result/impl/async-result-flat-map.mjs.map +1 -1
- package/dist/functional/async-result/impl/async-result-from-promise.mjs +9 -10
- package/dist/functional/async-result/impl/async-result-from-promise.mjs.map +1 -1
- package/dist/functional/async-result/impl/async-result-from-throwable.mjs +12 -14
- package/dist/functional/async-result/impl/async-result-from-throwable.mjs.map +1 -1
- package/dist/functional/async-result/impl/async-result-map-err.mjs +16 -19
- package/dist/functional/async-result/impl/async-result-map-err.mjs.map +1 -1
- package/dist/functional/async-result/impl/async-result-map.mjs +16 -19
- package/dist/functional/async-result/impl/async-result-map.mjs.map +1 -1
- package/dist/functional/async-result/impl/async-result-unwrap-or.mjs +36 -9
- package/dist/functional/async-result/impl/async-result-unwrap-or.mjs.map +1 -1
- package/dist/functional/async-result/impl/index.mjs +8 -7
- package/dist/functional/async-result/impl/index.mjs.map +1 -1
- package/dist/functional/async-result/impl/types.mjs +2 -2
- package/dist/functional/async-result/impl/types.mjs.map +1 -1
- package/dist/functional/async-result/index.mjs +2 -3
- package/dist/functional/async-result/index.mjs.map +1 -1
- package/dist/functional/index.mjs +7 -11
- package/dist/functional/index.mjs.map +1 -1
- package/dist/functional/match.mjs +27 -13
- package/dist/functional/match.mjs.map +1 -1
- package/dist/functional/optional/impl/index.mjs +19 -18
- package/dist/functional/optional/impl/index.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-expect-to-be.mjs +16 -18
- package/dist/functional/optional/impl/optional-expect-to-be.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-filter.mjs +17 -19
- package/dist/functional/optional/impl/optional-filter.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-flat-map.mjs +13 -15
- package/dist/functional/optional/impl/optional-flat-map.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-from-nullable.mjs +26 -5
- package/dist/functional/optional/impl/optional-from-nullable.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-is-none.mjs +21 -5
- package/dist/functional/optional/impl/optional-is-none.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-is-optional.mjs +26 -8
- package/dist/functional/optional/impl/optional-is-optional.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-is-some.mjs +22 -5
- package/dist/functional/optional/impl/optional-is-some.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-map.mjs +16 -18
- package/dist/functional/optional/impl/optional-map.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-match.mjs +16 -18
- package/dist/functional/optional/impl/optional-match.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-none.mjs +18 -5
- package/dist/functional/optional/impl/optional-none.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-or-else.mjs +13 -15
- package/dist/functional/optional/impl/optional-or-else.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-some.mjs +23 -7
- package/dist/functional/optional/impl/optional-some.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-to-nullable.mjs +28 -5
- package/dist/functional/optional/impl/optional-to-nullable.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap-or.mjs +12 -14
- package/dist/functional/optional/impl/optional-unwrap-or.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap-throw.mjs +34 -9
- package/dist/functional/optional/impl/optional-unwrap-throw.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-unwrap.mjs +6 -9
- package/dist/functional/optional/impl/optional-unwrap.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-zip.mjs +36 -5
- package/dist/functional/optional/impl/optional-zip.mjs.map +1 -1
- package/dist/functional/optional/impl/tag.mjs +4 -5
- package/dist/functional/optional/impl/tag.mjs.map +1 -1
- package/dist/functional/optional/impl/types.mjs +2 -2
- package/dist/functional/optional/impl/types.mjs.map +1 -1
- package/dist/functional/optional/index.mjs +2 -3
- package/dist/functional/optional/index.mjs.map +1 -1
- package/dist/functional/optional/optional.mjs +2 -3
- package/dist/functional/optional/optional.mjs.map +1 -1
- package/dist/functional/pipe.mjs +42 -14
- package/dist/functional/pipe.mjs.map +1 -1
- package/dist/functional/result/impl/index.mjs +28 -27
- package/dist/functional/result/impl/index.mjs.map +1 -1
- package/dist/functional/result/impl/result-err.mjs +29 -7
- package/dist/functional/result/impl/result-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-expect-to-be.mjs +17 -18
- package/dist/functional/result/impl/result-expect-to-be.mjs.map +1 -1
- package/dist/functional/result/impl/result-flat-map.mjs +18 -21
- package/dist/functional/result/impl/result-flat-map.mjs.map +1 -1
- package/dist/functional/result/impl/result-fold.mjs +18 -21
- package/dist/functional/result/impl/result-fold.mjs.map +1 -1
- package/dist/functional/result/impl/result-from-optional.mjs +17 -20
- package/dist/functional/result/impl/result-from-optional.mjs.map +1 -1
- package/dist/functional/result/impl/result-from-promise.mjs +37 -8
- package/dist/functional/result/impl/result-from-promise.mjs.map +1 -1
- package/dist/functional/result/impl/result-from-throwable.mjs +41 -14
- package/dist/functional/result/impl/result-from-throwable.mjs.map +1 -1
- package/dist/functional/result/impl/result-is-err.mjs +21 -5
- package/dist/functional/result/impl/result-is-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-is-ok.mjs +21 -5
- package/dist/functional/result/impl/result-is-ok.mjs.map +1 -1
- package/dist/functional/result/impl/result-is-result.mjs +25 -7
- package/dist/functional/result/impl/result-is-result.mjs.map +1 -1
- package/dist/functional/result/impl/result-map-err.mjs +18 -21
- package/dist/functional/result/impl/result-map-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-map.mjs +18 -21
- package/dist/functional/result/impl/result-map.mjs.map +1 -1
- package/dist/functional/result/impl/result-match.mjs +17 -21
- package/dist/functional/result/impl/result-match.mjs.map +1 -1
- package/dist/functional/result/impl/result-ok.mjs +29 -7
- package/dist/functional/result/impl/result-ok.mjs.map +1 -1
- package/dist/functional/result/impl/result-or-else.mjs +14 -15
- package/dist/functional/result/impl/result-or-else.mjs.map +1 -1
- package/dist/functional/result/impl/result-safe-try.mjs +32 -21
- package/dist/functional/result/impl/result-safe-try.mjs.map +1 -1
- package/dist/functional/result/impl/result-safe-unwrap.mjs +40 -12
- package/dist/functional/result/impl/result-safe-unwrap.mjs.map +1 -1
- package/dist/functional/result/impl/result-swap.mjs +23 -8
- package/dist/functional/result/impl/result-swap.mjs.map +1 -1
- package/dist/functional/result/impl/result-to-optional.mjs +30 -7
- package/dist/functional/result/impl/result-to-optional.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err-or.mjs +13 -14
- package/dist/functional/result/impl/result-unwrap-err-or.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err-throw.mjs +43 -20
- package/dist/functional/result/impl/result-unwrap-err-throw.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-err.mjs +33 -8
- package/dist/functional/result/impl/result-unwrap-err.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-ok-or.mjs +13 -14
- package/dist/functional/result/impl/result-unwrap-ok-or.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-ok.mjs +6 -9
- package/dist/functional/result/impl/result-unwrap-ok.mjs.map +1 -1
- package/dist/functional/result/impl/result-unwrap-throw.mjs +38 -11
- package/dist/functional/result/impl/result-unwrap-throw.mjs.map +1 -1
- package/dist/functional/result/impl/result-zip.mjs +35 -5
- package/dist/functional/result/impl/result-zip.mjs.map +1 -1
- package/dist/functional/result/impl/tag.mjs +4 -5
- package/dist/functional/result/impl/tag.mjs.map +1 -1
- package/dist/functional/result/impl/types.mjs +2 -2
- package/dist/functional/result/impl/types.mjs.map +1 -1
- package/dist/functional/result/index.mjs +2 -3
- package/dist/functional/result/index.mjs.map +1 -1
- package/dist/functional/result/result.mjs +2 -3
- package/dist/functional/result/result.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/index.mjs +29 -28
- package/dist/functional/ternary-result/impl/index.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/tag.mjs +6 -6
- package/dist/functional/ternary-result/impl/tag.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-err.mjs +17 -7
- package/dist/functional/ternary-result/impl/ternary-result-err.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-expect-to-be.mjs +15 -18
- 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.mjs +28 -32
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-fold.mjs +24 -26
- package/dist/functional/ternary-result/impl/ternary-result-fold.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs +21 -8
- package/dist/functional/ternary-result/impl/ternary-result-from-promise.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs +28 -13
- package/dist/functional/ternary-result/impl/ternary-result-from-throwable.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs +19 -5
- package/dist/functional/ternary-result/impl/ternary-result-is-err.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-is-ok.mjs +21 -5
- 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.mjs +28 -8
- 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.mjs +20 -5
- package/dist/functional/ternary-result/impl/ternary-result-is-warn.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs +17 -18
- package/dist/functional/ternary-result/impl/ternary-result-map-err.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs +20 -23
- package/dist/functional/ternary-result/impl/ternary-result-map-warn.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-map.mjs +24 -26
- package/dist/functional/ternary-result/impl/ternary-result-map.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-ok.mjs +18 -7
- package/dist/functional/ternary-result/impl/ternary-result-ok.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs +11 -14
- package/dist/functional/ternary-result/impl/ternary-result-or-else.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-to-optional.mjs +24 -10
- 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.mjs +11 -14
- 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.mjs +30 -19
- 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.mjs +20 -8
- 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.mjs +11 -14
- 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.mjs +7 -9
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-ok.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-throw.mjs +30 -22
- 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.mjs +11 -14
- 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.mjs +27 -17
- 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.mjs +20 -8
- package/dist/functional/ternary-result/impl/ternary-result-unwrap-warn.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-warn.mjs +21 -8
- package/dist/functional/ternary-result/impl/ternary-result-warn.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-zip.mjs +47 -19
- package/dist/functional/ternary-result/impl/ternary-result-zip.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/types.mjs +2 -2
- package/dist/functional/ternary-result/impl/types.mjs.map +1 -1
- package/dist/functional/ternary-result/impl/variant-name.mjs +12 -14
- package/dist/functional/ternary-result/impl/variant-name.mjs.map +1 -1
- package/dist/functional/ternary-result/index.mjs +2 -3
- package/dist/functional/ternary-result/index.mjs.map +1 -1
- package/dist/functional/ternary-result/ternary-result.mjs +2 -3
- package/dist/functional/ternary-result/ternary-result.mjs.map +1 -1
- package/dist/guard/has-key.mjs +43 -4
- package/dist/guard/has-key.mjs.map +1 -1
- package/dist/guard/index.mjs +8 -8
- package/dist/guard/index.mjs.map +1 -1
- package/dist/guard/is-non-empty-string.mjs +39 -4
- package/dist/guard/is-non-empty-string.mjs.map +1 -1
- package/dist/guard/is-non-null-object.mjs +36 -4
- package/dist/guard/is-non-null-object.mjs.map +1 -1
- package/dist/guard/is-primitive.mjs +46 -15
- package/dist/guard/is-primitive.mjs.map +1 -1
- package/dist/guard/is-record.mjs +89 -6
- package/dist/guard/is-record.mjs.map +1 -1
- package/dist/guard/is-type.mjs +404 -19
- package/dist/guard/is-type.mjs.map +1 -1
- package/dist/guard/key-is-in.mjs +42 -4
- package/dist/guard/key-is-in.mjs.map +1 -1
- package/dist/index.mjs +12 -65
- package/dist/index.mjs.map +1 -1
- package/dist/iterator/index.mjs +2 -2
- package/dist/iterator/index.mjs.map +1 -1
- package/dist/iterator/range.mjs +19 -57
- package/dist/iterator/range.mjs.map +1 -1
- package/dist/json/index.mjs +2 -2
- package/dist/json/index.mjs.map +1 -1
- package/dist/json/json.mjs +346 -105
- package/dist/json/json.mjs.map +1 -1
- package/dist/number/branded-types/finite-number.mjs +148 -137
- package/dist/number/branded-types/finite-number.mjs.map +1 -1
- package/dist/number/branded-types/index.mjs +33 -33
- package/dist/number/branded-types/index.mjs.map +1 -1
- package/dist/number/branded-types/int.mjs +245 -209
- package/dist/number/branded-types/int.mjs.map +1 -1
- package/dist/number/branded-types/int16.mjs +141 -131
- package/dist/number/branded-types/int16.mjs.map +1 -1
- package/dist/number/branded-types/int32.mjs +141 -131
- package/dist/number/branded-types/int32.mjs.map +1 -1
- package/dist/number/branded-types/negative-finite-number.mjs +155 -149
- package/dist/number/branded-types/negative-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/negative-int.mjs +125 -110
- package/dist/number/branded-types/negative-int.mjs.map +1 -1
- package/dist/number/branded-types/negative-safe-int.mjs +126 -115
- package/dist/number/branded-types/negative-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-finite-number.mjs +164 -154
- package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-int16.mjs +137 -125
- package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-int32.mjs +137 -125
- package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
- package/dist/number/branded-types/non-positive-finite-number.mjs +143 -139
- package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-positive-int.mjs +116 -99
- package/dist/number/branded-types/non-positive-int.mjs.map +1 -1
- package/dist/number/branded-types/non-positive-safe-int.mjs +118 -107
- package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-finite-number.mjs +144 -129
- package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int.mjs +102 -82
- package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int16.mjs +118 -105
- package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int32.mjs +118 -105
- package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-safe-int.mjs +122 -108
- package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint16.mjs +118 -104
- package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint32.mjs +118 -104
- package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
- package/dist/number/branded-types/positive-finite-number.mjs +167 -160
- package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/positive-int.mjs +260 -224
- package/dist/number/branded-types/positive-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-int16.mjs +134 -122
- package/dist/number/branded-types/positive-int16.mjs.map +1 -1
- package/dist/number/branded-types/positive-int32.mjs +134 -122
- package/dist/number/branded-types/positive-int32.mjs.map +1 -1
- package/dist/number/branded-types/positive-safe-int.mjs +292 -258
- package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-uint16.mjs +134 -122
- package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
- package/dist/number/branded-types/positive-uint32.mjs +134 -122
- package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
- package/dist/number/branded-types/safe-int.mjs +284 -255
- package/dist/number/branded-types/safe-int.mjs.map +1 -1
- package/dist/number/branded-types/safe-uint.mjs +135 -124
- package/dist/number/branded-types/safe-uint.mjs.map +1 -1
- package/dist/number/branded-types/uint.mjs +248 -211
- package/dist/number/branded-types/uint.mjs.map +1 -1
- package/dist/number/branded-types/uint16.mjs +132 -121
- package/dist/number/branded-types/uint16.mjs.map +1 -1
- package/dist/number/branded-types/uint32.mjs +132 -121
- package/dist/number/branded-types/uint32.mjs.map +1 -1
- package/dist/number/enum/index.mjs +3 -3
- package/dist/number/enum/index.mjs.map +1 -1
- package/dist/number/enum/int8.mjs +146 -131
- package/dist/number/enum/int8.mjs.map +1 -1
- package/dist/number/enum/uint8.mjs +133 -119
- package/dist/number/enum/uint8.mjs.map +1 -1
- package/dist/number/index.mjs +6 -37
- package/dist/number/index.mjs.map +1 -1
- package/dist/number/num-arithmetic-types.mjs +42 -1
- package/dist/number/num-arithmetic-types.mjs.map +1 -1
- package/dist/number/num.mjs +541 -83
- package/dist/number/num.mjs.map +1 -1
- package/dist/number/refined-number-utils.mjs +294 -133
- package/dist/number/refined-number-utils.mjs.map +1 -1
- package/dist/object/index.mjs +2 -2
- package/dist/object/index.mjs.map +1 -1
- package/dist/object/object.mjs +355 -202
- package/dist/object/object.mjs.map +1 -1
- package/dist/others/cast-mutable.mjs +38 -11
- package/dist/others/cast-mutable.mjs.map +1 -1
- package/dist/others/cast-readonly.mjs +37 -11
- package/dist/others/cast-readonly.mjs.map +1 -1
- package/dist/others/debounce-function.mjs +22 -11
- package/dist/others/debounce-function.mjs.map +1 -1
- package/dist/others/fast-deep-equal.mjs +70 -51
- package/dist/others/fast-deep-equal.mjs.map +1 -1
- package/dist/others/if-then.mjs +32 -5
- package/dist/others/if-then.mjs.map +1 -1
- package/dist/others/index.mjs +10 -10
- package/dist/others/index.mjs.map +1 -1
- package/dist/others/map-nullable.mjs +11 -13
- package/dist/others/map-nullable.mjs.map +1 -1
- package/dist/others/memoize-function.mjs +14 -16
- package/dist/others/memoize-function.mjs.map +1 -1
- package/dist/others/tuple.mjs +52 -4
- package/dist/others/tuple.mjs.map +1 -1
- package/dist/others/unknown-to-string.mjs +91 -47
- package/dist/others/unknown-to-string.mjs.map +1 -1
- package/dist/promise/index.mjs +2 -2
- package/dist/promise/index.mjs.map +1 -1
- package/dist/promise/promise.mjs +51 -10
- package/dist/promise/promise.mjs.map +1 -1
- package/dist/string/index.mjs +2 -2
- package/dist/string/index.mjs.map +1 -1
- package/dist/string/str.mjs +250 -83
- package/dist/string/str.mjs.map +1 -1
- package/dist/types.mjs +3 -2
- package/dist/types.mjs.map +1 -1
- package/package.json +5 -6
|
@@ -1,156 +1,132 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import '
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import '../../number/branded-types/negative-safe-int.mjs';
|
|
12
|
-
import '../../number/branded-types/non-negative-finite-number.mjs';
|
|
13
|
-
import '../../number/branded-types/non-negative-int16.mjs';
|
|
14
|
-
import '../../number/branded-types/non-negative-int32.mjs';
|
|
15
|
-
import '../../number/branded-types/non-positive-finite-number.mjs';
|
|
16
|
-
import '../../number/branded-types/non-positive-int.mjs';
|
|
17
|
-
import '../../number/branded-types/non-positive-safe-int.mjs';
|
|
18
|
-
import '../../number/branded-types/non-zero-finite-number.mjs';
|
|
19
|
-
import '../../number/branded-types/non-zero-int.mjs';
|
|
20
|
-
import '../../number/branded-types/non-zero-int16.mjs';
|
|
21
|
-
import '../../number/branded-types/non-zero-int32.mjs';
|
|
22
|
-
import '../../number/branded-types/non-zero-safe-int.mjs';
|
|
23
|
-
import '../../number/branded-types/non-zero-uint16.mjs';
|
|
24
|
-
import '../../number/branded-types/non-zero-uint32.mjs';
|
|
25
|
-
import '../../number/branded-types/positive-finite-number.mjs';
|
|
26
|
-
import '../../number/branded-types/positive-int.mjs';
|
|
27
|
-
import '../../number/branded-types/positive-int16.mjs';
|
|
28
|
-
import '../../number/branded-types/positive-int32.mjs';
|
|
29
|
-
import '../../number/branded-types/positive-safe-int.mjs';
|
|
30
|
-
import '../../number/branded-types/positive-uint16.mjs';
|
|
31
|
-
import '../../number/branded-types/positive-uint32.mjs';
|
|
32
|
-
import '../../number/branded-types/safe-int.mjs';
|
|
33
|
-
import '../../number/branded-types/safe-uint.mjs';
|
|
34
|
-
import '../../number/branded-types/uint.mjs';
|
|
35
|
-
import '../../number/branded-types/uint16.mjs';
|
|
36
|
-
import { asUint32 } from '../../number/branded-types/uint32.mjs';
|
|
37
|
-
import '../../number/enum/int8.mjs';
|
|
38
|
-
import '../../number/enum/uint8.mjs';
|
|
39
|
-
import '../../number/num.mjs';
|
|
40
|
-
import '../../number/refined-number-utils.mjs';
|
|
41
|
-
|
|
42
|
-
function find(...args) {
|
|
43
|
-
switch (args.length) {
|
|
44
|
-
case 2:
|
|
45
|
-
return findImpl(...args);
|
|
46
|
-
case 1:
|
|
47
|
-
return (array) => findImpl(array, ...args);
|
|
48
|
-
}
|
|
1
|
+
|
|
2
|
+
import { Optional, pipe } from '../../functional/index.mjs';
|
|
3
|
+
import { asUint32 } from '../../number/index.mjs';
|
|
4
|
+
export function find(...args) {
|
|
5
|
+
switch (args.length) {
|
|
6
|
+
case 2:
|
|
7
|
+
return findImpl(...args);
|
|
8
|
+
case 1:
|
|
9
|
+
return (array) => findImpl(array, ...args);
|
|
10
|
+
}
|
|
49
11
|
}
|
|
50
12
|
const findImpl = (array, predicate) => {
|
|
51
|
-
|
|
13
|
+
const foundIndex = array.findIndex(
|
|
52
14
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
53
|
-
predicate
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
15
|
+
predicate);
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
return foundIndex === -1
|
|
29
|
+
? Optional.none
|
|
30
|
+
: // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
31
|
+
Optional.some(array[foundIndex]);
|
|
59
32
|
};
|
|
60
|
-
function findLast(...args) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
33
|
+
export function findLast(...args) {
|
|
34
|
+
switch (args.length) {
|
|
35
|
+
case 2:
|
|
36
|
+
return findLastImpl(...args);
|
|
37
|
+
case 1:
|
|
38
|
+
return (array) => findLastImpl(array, ...args);
|
|
39
|
+
}
|
|
67
40
|
}
|
|
68
41
|
const findLastImpl = (array, predicate) => {
|
|
69
|
-
|
|
42
|
+
const foundIndex = array.findLastIndex(
|
|
70
43
|
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
71
|
-
predicate
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
44
|
+
predicate);
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
return foundIndex === -1
|
|
58
|
+
? Optional.none
|
|
59
|
+
: // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
60
|
+
Optional.some(array[foundIndex]);
|
|
77
61
|
};
|
|
78
|
-
function findIndex(...args) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
62
|
+
export function findIndex(...args) {
|
|
63
|
+
switch (args.length) {
|
|
64
|
+
case 2:
|
|
65
|
+
return findIndexImpl(...args);
|
|
66
|
+
case 1:
|
|
67
|
+
return (array) => findIndexImpl(array, ...args);
|
|
68
|
+
}
|
|
85
69
|
}
|
|
86
|
-
const findIndexImpl = (array, predicate) => pipe(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
case 1:
|
|
97
|
-
return (array) => findLastIndexImpl(array, ...args);
|
|
98
|
-
}
|
|
70
|
+
const findIndexImpl = (array, predicate) => pipe(array.findIndex(
|
|
71
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
72
|
+
predicate)).map((idx) => (idx >= 0 ? asUint32(idx) : -1)).value;
|
|
73
|
+
export function findLastIndex(...args) {
|
|
74
|
+
switch (args.length) {
|
|
75
|
+
case 2:
|
|
76
|
+
return findLastIndexImpl(...args);
|
|
77
|
+
case 1:
|
|
78
|
+
return (array) => findLastIndexImpl(array, ...args);
|
|
79
|
+
}
|
|
99
80
|
}
|
|
100
|
-
const findLastIndexImpl = (array, predicate) => pipe(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
case 1:
|
|
111
|
-
return (array) => indexOfImpl(array, ...args);
|
|
112
|
-
}
|
|
81
|
+
const findLastIndexImpl = (array, predicate) => pipe(array.findLastIndex(
|
|
82
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
83
|
+
predicate)).map((idx) => (idx >= 0 ? asUint32(idx) : -1)).value;
|
|
84
|
+
export function indexOf(...args) {
|
|
85
|
+
switch (args.length) {
|
|
86
|
+
case 2:
|
|
87
|
+
return indexOfImpl(...args);
|
|
88
|
+
case 1:
|
|
89
|
+
return (array) => indexOfImpl(array, ...args);
|
|
90
|
+
}
|
|
113
91
|
}
|
|
114
92
|
const indexOfImpl = (array, searchElement) => {
|
|
115
|
-
|
|
116
|
-
|
|
93
|
+
const index = array.indexOf(searchElement);
|
|
94
|
+
return index !== -1 ? asUint32(index) : -1;
|
|
117
95
|
};
|
|
118
|
-
function indexOfFrom(...args) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
96
|
+
export function indexOfFrom(...args) {
|
|
97
|
+
switch (args.length) {
|
|
98
|
+
case 3:
|
|
99
|
+
return indexOfFromImpl(...args);
|
|
100
|
+
case 2:
|
|
101
|
+
return (array) => indexOfFromImpl(array, ...args);
|
|
102
|
+
}
|
|
125
103
|
}
|
|
126
104
|
const indexOfFromImpl = (array, searchElement, fromIndex) => {
|
|
127
|
-
|
|
128
|
-
|
|
105
|
+
const index = array.indexOf(searchElement, fromIndex);
|
|
106
|
+
return index !== -1 ? asUint32(index) : -1;
|
|
129
107
|
};
|
|
130
|
-
function lastIndexOf(...args) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
108
|
+
export function lastIndexOf(...args) {
|
|
109
|
+
switch (args.length) {
|
|
110
|
+
case 2:
|
|
111
|
+
return lastIndexOfImpl(...args);
|
|
112
|
+
case 1:
|
|
113
|
+
return (array) => lastIndexOfImpl(array, ...args);
|
|
114
|
+
}
|
|
137
115
|
}
|
|
138
116
|
const lastIndexOfImpl = (array, searchElement) => {
|
|
139
|
-
|
|
140
|
-
|
|
117
|
+
const index = array.lastIndexOf(searchElement);
|
|
118
|
+
return index !== -1 ? asUint32(index) : -1;
|
|
141
119
|
};
|
|
142
|
-
function lastIndexOfFrom(...args) {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
120
|
+
export function lastIndexOfFrom(...args) {
|
|
121
|
+
switch (args.length) {
|
|
122
|
+
case 3:
|
|
123
|
+
return lastIndexOfFromImpl(...args);
|
|
124
|
+
case 2:
|
|
125
|
+
return (array) => lastIndexOfFromImpl(array, ...args);
|
|
126
|
+
}
|
|
149
127
|
}
|
|
150
128
|
const lastIndexOfFromImpl = (array, searchElement, fromIndex) => {
|
|
151
|
-
|
|
152
|
-
|
|
129
|
+
const index = array.lastIndexOf(searchElement, fromIndex);
|
|
130
|
+
return index !== -1 ? asUint32(index) : -1;
|
|
153
131
|
};
|
|
154
|
-
|
|
155
|
-
export { find, findIndex, findLast, findLastIndex, indexOf, indexOfFrom, lastIndexOf, lastIndexOfFrom };
|
|
156
|
-
//# sourceMappingURL=array-utils-search.mjs.map
|
|
132
|
+
//# sourceMappingURL=array-utils-search.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-utils-search.mjs","sources":["../../../src/array/impl/array-utils-search.mts"],"sourcesContent":["import { expectType } from '../../expect-type.mjs';\nimport { Optional, pipe } from '../../functional/index.mjs';\nimport { asUint32 } from '../../number/index.mjs';\nimport {\n type ArgArrayIndexWithNegative,\n type ArrayIndex,\n type SizeType,\n} from '../../types.mjs';\n\n/**\n * Finds the first element that satisfies a predicate.\n *\n * @example\n *\n * ```ts\n * const users = [\n * { id: 1, name: 'Ada' },\n * { id: 2, name: 'Grace' },\n * ] as const;\n *\n * const found = Arr.find(users, (user) => user.id === 2);\n *\n * const missing = Arr.find<Readonly<{ id: number }>>((user) => user.id === 3)(\n * users,\n * );\n *\n * assert.deepStrictEqual(found, Optional.some({ id: 2, name: 'Grace' }));\n *\n * assert.deepStrictEqual(missing, Optional.none);\n * ```\n */\nexport function find<E, F extends E>(\n array: readonly E[],\n predicate: (value: E, index: SizeType.Arr, arr: readonly E[]) => value is F,\n): Optional<F>;\n\nexport function find<const Ar extends readonly unknown[]>(\n array: Ar,\n predicate: (value: Ar[number], index: ArrayIndex<Ar>, arr: Ar) => boolean,\n): Optional<Ar[number]>;\n\nexport function find<E>(\n predicate: (value: E, index: SizeType.Arr, arr: readonly E[]) => boolean,\n): (array: readonly E[]) => Optional<E>;\n\nexport function find<E>(\n ...args:\n | readonly [\n array: readonly E[],\n predicate: (\n value: E,\n index: SizeType.Arr,\n arr: readonly E[],\n ) => boolean,\n ]\n | readonly [\n predicate: (\n value: E,\n index: SizeType.Arr,\n arr: readonly E[],\n ) => boolean,\n ]\n): Optional<E> | ((array: readonly E[]) => Optional<E>) {\n switch (args.length) {\n case 2:\n return findImpl(...args);\n\n case 1:\n return (array) => findImpl(array, ...args);\n }\n}\n\nconst findImpl = <E,>(\n array: readonly E[],\n predicate: (value: E, index: SizeType.Arr, arr: readonly E[]) => boolean,\n): Optional<E> => {\n const foundIndex = array.findIndex(\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n predicate as () => boolean,\n );\n\n // Left as a comment rather than asserted. This pinned the shape of the\n // standard library's `findIndex`, and the shape differs between the stock\n // library and the strict one — `(value, index, obj: this) => boolean` there\n // against `(value, index, arr: readonly E[]) => unknown` here. `src` ships\n // to consumers so that \"Go to Definition\" reaches it, so an assertion that\n // only holds under one of them shows up as an error in their editor.\n //\n // expectType<\n // Parameters<typeof array.findIndex>[0],\n // (value: E, index: number, arr: readonly E[]) => unknown\n // >('=');\n\n expectType<\n typeof predicate,\n (value: E, index: SizeType.Arr, arr: readonly E[]) => boolean\n >('=');\n\n return foundIndex === -1\n ? Optional.none\n : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n Optional.some(array[foundIndex]!);\n};\n\n/**\n * Finds the last element that satisfies a predicate.\n *\n * @example\n *\n * ```ts\n * const numbers = [1, 3, 2, 4, 5] as const;\n *\n * const lastEven = Arr.findLast(numbers, (n) => n % 2 === 0);\n *\n * const none = Arr.findLast<number>((n) => n > 10)(numbers);\n *\n * assert.deepStrictEqual(lastEven, Optional.some(4));\n *\n * assert.deepStrictEqual(none, Optional.none);\n * ```\n */\nexport function findLast<E, F extends E>(\n array: readonly E[],\n predicate: (value: E, index: SizeType.Arr, arr: readonly E[]) => value is F,\n): Optional<F>;\n\nexport function findLast<const Ar extends readonly unknown[]>(\n array: Ar,\n predicate: (value: Ar[number], index: ArrayIndex<Ar>, arr: Ar) => boolean,\n): Optional<Ar[number]>;\n\nexport function findLast<E>(\n predicate: (value: E, index: SizeType.Arr, arr: readonly E[]) => boolean,\n): (array: readonly E[]) => Optional<E>;\n\nexport function findLast<E>(\n ...args:\n | readonly [\n array: readonly E[],\n predicate: (\n value: E,\n index: SizeType.Arr,\n arr: readonly E[],\n ) => boolean,\n ]\n | readonly [\n predicate: (\n value: E,\n index: SizeType.Arr,\n arr: readonly E[],\n ) => boolean,\n ]\n): Optional<E> | ((array: readonly E[]) => Optional<E>) {\n switch (args.length) {\n case 2:\n return findLastImpl(...args);\n\n case 1:\n return (array) => findLastImpl(array, ...args);\n }\n}\n\nconst findLastImpl = <E,>(\n array: readonly E[],\n predicate: (value: E, index: SizeType.Arr, arr: readonly E[]) => boolean,\n): Optional<E> => {\n const foundIndex = array.findLastIndex(\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n predicate as () => boolean,\n );\n\n // Left as a comment rather than asserted. This pinned the shape of the\n // standard library's `findIndex`, and the shape differs between the stock\n // library and the strict one — `(value, index, obj: this) => boolean` there\n // against `(value, index, arr: readonly E[]) => unknown` here. `src` ships\n // to consumers so that \"Go to Definition\" reaches it, so an assertion that\n // only holds under one of them shows up as an error in their editor.\n //\n // expectType<\n // Parameters<typeof array.findIndex>[0],\n // (value: E, index: number, arr: readonly E[]) => unknown\n // >('=');\n\n expectType<\n typeof predicate,\n (value: E, index: SizeType.Arr, arr: readonly E[]) => boolean\n >('=');\n\n return foundIndex === -1\n ? Optional.none\n : // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n Optional.some(array[foundIndex]!);\n};\n\n/**\n * Finds the index of the first element that satisfies a predicate.\n *\n * @example\n *\n * ```ts\n * const letters = ['a', 'b', 'c'] as const;\n *\n * const indexOfB = Arr.findIndex(letters, (letter) => letter === 'b');\n *\n * const indexOfMissing = Arr.findIndex<string>((letter) => letter === 'z')(\n * letters,\n * );\n *\n * assert.isTrue(indexOfB === 1);\n *\n * assert.isTrue(indexOfMissing === -1);\n * ```\n */\nexport function findIndex<const Ar extends readonly unknown[]>(\n array: Ar,\n predicate: (value: Ar[number], index: ArrayIndex<Ar>, arr: Ar) => boolean,\n): ArrayIndex<Ar> | -1;\n\nexport function findIndex<E>(\n predicate: (value: E, index: SizeType.Arr, arr: readonly E[]) => boolean,\n): (array: readonly E[]) => SizeType.Arr | -1;\n\nexport function findIndex<E>(\n ...args:\n | readonly [\n array: readonly E[],\n predicate: (\n value: E,\n index: SizeType.Arr,\n arr: readonly E[],\n ) => boolean,\n ]\n | readonly [\n predicate: (\n value: E,\n index: SizeType.Arr,\n arr: readonly E[],\n ) => boolean,\n ]\n): SizeType.Arr | ((array: readonly E[]) => SizeType.Arr | -1) | -1 {\n switch (args.length) {\n case 2:\n return findIndexImpl(...args);\n\n case 1:\n return (array) => findIndexImpl(array, ...args);\n }\n}\n\nconst findIndexImpl = <E,>(\n array: readonly E[],\n predicate: (value: E, index: SizeType.Arr, arr: readonly E[]) => boolean,\n): SizeType.Arr | -1 =>\n pipe(\n array.findIndex(\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n predicate as (value: E, index: number) => boolean,\n ),\n ).map((idx) => (idx >= 0 ? asUint32(idx) : -1)).value;\n\n/**\n * Finds the index of the last element that satisfies a predicate.\n *\n * @example\n *\n * ```ts\n * const letters = ['a', 'b', 'c', 'b'] as const;\n *\n * const lastIndexOfB = Arr.findLastIndex(letters, (letter) => letter === 'b');\n *\n * const notFound = Arr.findLastIndex<string>((letter) => letter === 'z')(\n * letters,\n * );\n *\n * assert.isTrue(lastIndexOfB === 3);\n *\n * assert.isTrue(notFound === -1);\n * ```\n */\nexport function findLastIndex<const Ar extends readonly unknown[]>(\n array: Ar,\n predicate: (value: Ar[number], index: ArrayIndex<Ar>, arr: Ar) => boolean,\n): ArrayIndex<Ar> | -1;\n\nexport function findLastIndex<E>(\n predicate: (value: E, index: SizeType.Arr, arr: readonly E[]) => boolean,\n): (array: readonly E[]) => SizeType.Arr | -1;\n\nexport function findLastIndex<E>(\n ...args:\n | readonly [\n array: readonly E[],\n predicate: (\n value: E,\n index: SizeType.Arr,\n arr: readonly E[],\n ) => boolean,\n ]\n | readonly [\n predicate: (\n value: E,\n index: SizeType.Arr,\n arr: readonly E[],\n ) => boolean,\n ]\n): SizeType.Arr | ((array: readonly E[]) => SizeType.Arr | -1) | -1 {\n switch (args.length) {\n case 2:\n return findLastIndexImpl(...args);\n\n case 1:\n return (array) => findLastIndexImpl(array, ...args);\n }\n}\n\nconst findLastIndexImpl = <E,>(\n array: readonly E[],\n predicate: (value: E, index: SizeType.Arr, arr: readonly E[]) => boolean,\n): SizeType.Arr | -1 =>\n pipe(\n array.findLastIndex(\n // eslint-disable-next-line total-functions/no-unsafe-type-assertion\n predicate as (value: E, index: number) => boolean,\n ),\n ).map((idx) => (idx >= 0 ? asUint32(idx) : -1)).value;\n\n/**\n * Gets the index of a value in an array.\n *\n * @example\n *\n * ```ts\n * const fruits = ['apple', 'banana', 'orange', 'banana'] as readonly string[];\n *\n * const indexOfBanana = Arr.indexOf(fruits, 'banana');\n *\n * const indexOfGrape = Arr.indexOf(fruits, 'grape');\n *\n * // Curried version\n * const findApple = Arr.indexOf('apple');\n *\n * const indexOfApple = findApple(fruits);\n *\n * console.log(indexOfBanana); // => 1\n *\n * console.log(indexOfGrape); // => -1\n *\n * console.log(indexOfApple); // => 0\n * ```\n */\nexport function indexOf<const Ar extends readonly unknown[]>(\n array: Ar,\n searchElement: Ar[number],\n): ArrayIndex<Ar> | -1;\n\nexport function indexOf<E>(\n searchElement: E,\n): (array: readonly E[]) => SizeType.Arr | -1;\n\nexport function indexOf<E>(\n ...args:\n | readonly [array: readonly E[], searchElement: E]\n | readonly [searchElement: E]\n): SizeType.Arr | ((array: readonly E[]) => SizeType.Arr | -1) | -1 {\n switch (args.length) {\n case 2:\n return indexOfImpl(...args);\n\n case 1:\n return (array) => indexOfImpl(array, ...args);\n }\n}\n\nconst indexOfImpl = <E,>(\n array: readonly E[],\n searchElement: E,\n): SizeType.Arr | -1 => {\n const index = array.indexOf(searchElement);\n\n return index !== -1 ? asUint32(index) : -1;\n};\n\n/**\n * Gets the index of a value in an array, starting from a specified index.\n *\n * @example\n *\n * ```ts\n * const fruits = ['apple', 'banana', 'orange', 'banana'] as readonly string[];\n *\n * // Search for 'banana' starting from index 1\n * const firstBanana = Arr.indexOfFrom(fruits, 'banana', 1);\n *\n * // Search for 'banana' starting from index 2\n * const secondBanana = Arr.indexOfFrom(fruits, 'banana', 2);\n *\n * // Element not found\n * const notFound = Arr.indexOfFrom(fruits, 'grape', 0);\n *\n * // Curried version\n * const findBananaFrom2 = Arr.indexOfFrom('banana', 2);\n *\n * const index = findBananaFrom2(fruits);\n *\n * console.log(firstBanana); // => 1\n *\n * console.log(secondBanana); // => 3\n *\n * console.log(notFound); // => -1\n *\n * console.log(index); // => 3\n * ```\n */\nexport function indexOfFrom<const Ar extends readonly unknown[]>(\n array: Ar,\n searchElement: Ar[number],\n fromIndex: ArgArrayIndexWithNegative<Ar>,\n): ArrayIndex<Ar> | -1;\n\nexport function indexOfFrom<E>(\n searchElement: E,\n fromIndex: SizeType.ArgArrWithNegative,\n): (array: readonly E[]) => SizeType.Arr | -1;\n\nexport function indexOfFrom<E>(\n ...args:\n | readonly [\n array: readonly E[],\n searchElement: E,\n fromIndex: SizeType.ArgArrWithNegative,\n ]\n | readonly [searchElement: E, fromIndex: SizeType.ArgArrWithNegative]\n): SizeType.Arr | ((array: readonly E[]) => SizeType.Arr | -1) | -1 {\n switch (args.length) {\n case 3:\n return indexOfFromImpl(...args);\n\n case 2:\n return (array) => indexOfFromImpl(array, ...args);\n }\n}\n\nconst indexOfFromImpl = <E,>(\n array: readonly E[],\n searchElement: E,\n fromIndex: SizeType.ArgArrWithNegative,\n): SizeType.Arr | -1 => {\n const index = array.indexOf(searchElement, fromIndex);\n\n return index !== -1 ? asUint32(index) : -1;\n};\n\n/**\n * Gets the last index of a value in an array.\n *\n * @example\n *\n * ```ts\n * const fruits = ['apple', 'banana', 'orange', 'banana'] as readonly string[];\n *\n * const lastBanana = Arr.lastIndexOf(fruits, 'banana');\n *\n * const lastApple = Arr.lastIndexOf(fruits, 'apple');\n *\n * const notFound = Arr.lastIndexOf(fruits, 'grape');\n *\n * // Curried version\n * const findLastBanana = Arr.lastIndexOf('banana');\n *\n * const index = findLastBanana(fruits);\n *\n * console.log(lastBanana); // => 3\n *\n * console.log(lastApple); // => 0\n *\n * console.log(notFound); // => -1\n *\n * console.log(index); // => 3\n * ```\n */\nexport function lastIndexOf<const Ar extends readonly unknown[]>(\n array: Ar,\n searchElement: Ar[number],\n): ArrayIndex<Ar> | -1;\n\nexport function lastIndexOf<E>(\n searchElement: E,\n): (array: readonly E[]) => SizeType.Arr | -1;\n\nexport function lastIndexOf<E>(\n ...args:\n | readonly [array: readonly E[], searchElement: E]\n | readonly [searchElement: E]\n): SizeType.Arr | ((array: readonly E[]) => SizeType.Arr | -1) | -1 {\n switch (args.length) {\n case 2:\n return lastIndexOfImpl(...args);\n\n case 1:\n return (array) => lastIndexOfImpl(array, ...args);\n }\n}\n\nconst lastIndexOfImpl = <E,>(\n array: readonly E[],\n searchElement: E,\n): SizeType.Arr | -1 => {\n const index = array.lastIndexOf(searchElement);\n\n return index !== -1 ? asUint32(index) : -1;\n};\n\n/**\n * Gets the last index of a value in an array, starting from a specified index.\n *\n * @example\n *\n * ```ts\n * const fruits = ['apple', 'banana', 'orange', 'banana', 'grape'] as const;\n *\n * // Search backwards for 'banana' from index 3\n * const lastBananaFrom3 = Arr.lastIndexOfFrom(fruits, 'banana', 3);\n *\n * // Search backwards for 'banana' from index 2\n * const lastBananaFrom2 = Arr.lastIndexOfFrom(fruits, 'banana', 2);\n *\n * // Element not found\n * const notFound = Arr.lastIndexOfFrom(fruits, 'grape', 2);\n *\n * // Curried version\n * const findBananaFrom3 = Arr.lastIndexOfFrom('banana', 3);\n *\n * const index = findBananaFrom3(fruits);\n *\n * console.log(lastBananaFrom3); // => 3\n *\n * console.log(lastBananaFrom2); // => 1\n *\n * console.log(notFound); // => -1\n *\n * console.log(index); // => 3\n * ```\n */\nexport function lastIndexOfFrom<const Ar extends readonly unknown[]>(\n array: Ar,\n searchElement: Ar[number],\n fromIndex: ArgArrayIndexWithNegative<Ar>,\n): ArrayIndex<Ar> | -1;\n\nexport function lastIndexOfFrom<E>(\n searchElement: E,\n fromIndex: SizeType.ArgArrWithNegative,\n): (array: readonly E[]) => SizeType.Arr | -1;\n\nexport function lastIndexOfFrom<E>(\n ...args:\n | readonly [\n array: readonly E[],\n searchElement: E,\n fromIndex: SizeType.ArgArrWithNegative,\n ]\n | readonly [searchElement: E, fromIndex: SizeType.ArgArrWithNegative]\n): SizeType.Arr | ((array: readonly E[]) => SizeType.Arr | -1) | -1 {\n switch (args.length) {\n case 3:\n return lastIndexOfFromImpl(...args);\n\n case 2:\n return (array) => lastIndexOfFromImpl(array, ...args);\n }\n}\n\nconst lastIndexOfFromImpl = <E,>(\n array: readonly E[],\n searchElement: E,\n fromIndex: SizeType.ArgArrWithNegative,\n): SizeType.Arr | -1 => {\n const index = array.lastIndexOf(searchElement, fromIndex);\n\n return index !== -1 ? asUint32(index) : -1;\n};\n"],"names":["Optional.none","Optional.some"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6CO,SAAS,QACX,IAAA,EAgBmD;AACtD,EAAA,QAAQ,KAAK,MAAA;AAAQ,IACnB,KAAK,CAAA;AACH,MAAA,OAAO,QAAA,CAAS,GAAG,IAAI,CAAA;AAAA,IAEzB,KAAK,CAAA;AACH,MAAA,OAAO,CAAC,KAAA,KAAU,QAAA,CAAS,KAAA,EAAO,GAAG,IAAI,CA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E,EAAE,CAAC,mBAAmB,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,CAAC;IAC1D,CAAC;AACH,CAAC;AAED,MAAM,mBAAmB,GAAG,CAC1B,KAAmB,EACnB,aAAgB,EAChB,SAAsC,EACnB,EAAE;IACrB,MAAM,KAAK,GAAG,KAAK,CAAC,WAAW,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;IAE1D,OAAO,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7C,CAAC,CAAC"}
|
|
@@ -1,40 +1,148 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Checks if two arrays are equal by comparing their elements.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
*
|
|
6
|
+
* ```ts
|
|
7
|
+
* const numbers = [1, 2, 3] as const;
|
|
8
|
+
*
|
|
9
|
+
* const sameNumbers = [1, 2, 3] as const;
|
|
10
|
+
*
|
|
11
|
+
* const differentNumbers = [1, 2, 4] as const;
|
|
12
|
+
*
|
|
13
|
+
* assert.isTrue(Arr.eq(numbers, sameNumbers));
|
|
14
|
+
*
|
|
15
|
+
* assert.isFalse(Arr.eq(numbers, differentNumbers));
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export const eq = (array1, array2, equality = Object.is) => array1.length === array2.length &&
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
20
|
+
array1.every((v, i) => equality(v, array2[i]));
|
|
21
|
+
/**
|
|
22
|
+
* Alias for `eq`.
|
|
23
|
+
*
|
|
24
|
+
* @see {@link eq}
|
|
25
|
+
*/
|
|
26
|
+
export const equal = eq;
|
|
27
|
+
/**
|
|
28
|
+
* Checks if the first array is a subset of the second array.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
*
|
|
32
|
+
* ```ts
|
|
33
|
+
* const subset = [1, 2] as const;
|
|
34
|
+
*
|
|
35
|
+
* const superset = [1, 2, 3] as const;
|
|
36
|
+
*
|
|
37
|
+
* const notSubset = [2, 4] as const;
|
|
38
|
+
*
|
|
39
|
+
* assert.isTrue(Arr.isSubset(subset, superset));
|
|
40
|
+
*
|
|
41
|
+
* assert.isFalse(Arr.isSubset(notSubset, superset));
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export const isSubset = (array1, array2) => array1.every((a) =>
|
|
45
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
46
|
+
array2.includes(a));
|
|
47
|
+
/**
|
|
48
|
+
* Checks if the first array is a superset of the second array.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
*
|
|
52
|
+
* ```ts
|
|
53
|
+
* const potentialSuperset = ['a', 'b', 'c'] as const;
|
|
54
|
+
*
|
|
55
|
+
* const subset = ['a', 'c'] as const;
|
|
56
|
+
*
|
|
57
|
+
* const notSuperset = ['a', 'd'] as const;
|
|
58
|
+
*
|
|
59
|
+
* assert.isTrue(Arr.isSuperset(potentialSuperset, subset));
|
|
60
|
+
*
|
|
61
|
+
* assert.isFalse(Arr.isSuperset(subset, potentialSuperset));
|
|
62
|
+
*
|
|
63
|
+
* assert.isFalse(Arr.isSuperset(potentialSuperset, notSuperset));
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export const isSuperset = (array1, array2) => isSubset(array2, array1);
|
|
67
|
+
/**
|
|
68
|
+
* Returns the intersection of two arrays.
|
|
69
|
+
*
|
|
70
|
+
* @example
|
|
71
|
+
*
|
|
72
|
+
* ```ts
|
|
73
|
+
* const refs = ['Ada', 'Alan', 'Grace'] as const;
|
|
74
|
+
*
|
|
75
|
+
* const attendees = ['Grace', 'Alan', 'Barbara'] as const;
|
|
76
|
+
*
|
|
77
|
+
* const both = Arr.setIntersection(refs, attendees);
|
|
78
|
+
*
|
|
79
|
+
* assert.deepStrictEqual(both, ['Alan', 'Grace']);
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export const setIntersection = (array1, array2) =>
|
|
83
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
84
|
+
array1.filter((e) => array2.includes(e));
|
|
85
|
+
/**
|
|
86
|
+
* Returns the set difference of two arrays (elements in first but not in second).
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
*
|
|
90
|
+
* ```ts
|
|
91
|
+
* const baseline = [1, 2, 3, 4] as const;
|
|
92
|
+
*
|
|
93
|
+
* const removed = [2, 4] as const;
|
|
94
|
+
*
|
|
95
|
+
* const remaining = Arr.setDifference(baseline, removed);
|
|
96
|
+
*
|
|
97
|
+
* assert.deepStrictEqual(remaining, [1, 3]);
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export const setDifference = (array1, array2) => array1.filter((e) => !array2.includes(e));
|
|
101
|
+
/**
|
|
102
|
+
* Returns the set difference of two sorted numeric arrays (optimized for sorted arrays).
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
*
|
|
106
|
+
* ```ts
|
|
107
|
+
* const upcoming = [1, 3, 5, 7, 9] as const;
|
|
108
|
+
*
|
|
109
|
+
* const completed = [3, 4, 7] as const;
|
|
110
|
+
*
|
|
111
|
+
* const remaining = Arr.sortedNumSetDifference(upcoming, completed);
|
|
112
|
+
*
|
|
113
|
+
* const expected = [1, 5, 9] as const;
|
|
114
|
+
*
|
|
115
|
+
* assert.deepStrictEqual(remaining, expected);
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
export const sortedNumSetDifference = (sortedList1, sortedList2) => {
|
|
119
|
+
const mut_result = [];
|
|
120
|
+
let mut_it1 = 0; // iterator for sortedList1
|
|
121
|
+
let mut_it2 = 0; // iterator for sortedList2
|
|
122
|
+
while (mut_it1 < sortedList1.length && mut_it2 < sortedList2.length) {
|
|
123
|
+
// Non-null assertions are safe due to loop condition
|
|
124
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
125
|
+
const val1 = sortedList1[mut_it1];
|
|
126
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
127
|
+
const val2 = sortedList2[mut_it2];
|
|
128
|
+
if (val1 === val2) {
|
|
129
|
+
mut_it1 += 1;
|
|
130
|
+
mut_it2 += 1;
|
|
131
|
+
}
|
|
132
|
+
else if (val1 < val2) {
|
|
133
|
+
mut_result.push(val1);
|
|
134
|
+
mut_it1 += 1;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
// val1 > val2
|
|
138
|
+
mut_it2 += 1;
|
|
139
|
+
}
|
|
31
140
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
141
|
+
// Add remaining elements from sortedList1
|
|
142
|
+
for (; mut_it1 < sortedList1.length; mut_it1 += 1) {
|
|
143
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
144
|
+
mut_result.push(sortedList1[mut_it1]);
|
|
145
|
+
}
|
|
146
|
+
return mut_result;
|
|
37
147
|
};
|
|
38
|
-
|
|
39
|
-
export { eq, equal, isSubset, isSuperset, setDifference, setIntersection, sortedNumSetDifference };
|
|
40
|
-
//# sourceMappingURL=array-utils-set-op.mjs.map
|
|
148
|
+
//# sourceMappingURL=array-utils-set-op.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-utils-set-op.mjs","sources":["../../../src/array/impl/array-utils-set-op.mts"],"
|
|
1
|
+
{"version":3,"file":"array-utils-set-op.mjs","sourceRoot":"","sources":["../../../src/array/impl/array-utils-set-op.mts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,EAAE,GAAG,CAChB,MAAoB,EACpB,MAAoB,EACpB,QAAQ,GAA4B,MAAM,CAAC,EAAE,EACpC,EAAE,CACX,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM;IAC/B,oEAAoE;IACpE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAE,CAAC,CAAC,CAAC;AAElD;;;;GAIG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;AAExB;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CACtB,MAAqB,EACrB,MAAqB,EACZ,EAAE,CACX,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;AACjB,oEAAoE;AACpE,MAAM,CAAC,QAAQ,CAAC,CAAY,CAAC,CAC9B,CAAC;AAEJ;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,MAAqB,EACrB,MAAqB,EACZ,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEvC;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAI7B,MAAqB,EACrB,MAAqB,EACC,EAAE;AACxB,oEAAoE;AACnE,MAA+B,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;AAErE;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAC3B,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) =>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
export const size = (array) =>
|
|
2
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
3
|
+
array.length;
|
|
4
|
+
/**
|
|
5
|
+
* Alias for `size`.
|
|
6
|
+
*
|
|
7
|
+
* @see {@link size}
|
|
8
|
+
*/
|
|
9
|
+
export const length = size;
|
|
10
|
+
//# sourceMappingURL=array-utils-size.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array-utils-size.mjs","sources":["../../../src/array/impl/array-utils-size.mts"],"
|
|
1
|
+
{"version":3,"file":"array-utils-size.mjs","sourceRoot":"","sources":["../../../src/array/impl/array-utils-size.mts"],"names":[],"mappings":"AA0BA,MAAM,CAAC,MAAM,IAAI,GAAG,CAClB,KAAS,EAGM,EAAE;AACjB,oEAAoE;AACpE,KAAK,CAAC,MAAe,CAAC;AAExB;;;;GAIG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,CAAC"}
|
|
@@ -1,53 +1,16 @@
|
|
|
1
|
-
import '../../number/
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import '../../number/branded-types/non-negative-int16.mjs';
|
|
10
|
-
import '../../number/branded-types/non-negative-int32.mjs';
|
|
11
|
-
import '../../number/branded-types/non-positive-finite-number.mjs';
|
|
12
|
-
import '../../number/branded-types/non-positive-int.mjs';
|
|
13
|
-
import '../../number/branded-types/non-positive-safe-int.mjs';
|
|
14
|
-
import '../../number/branded-types/non-zero-finite-number.mjs';
|
|
15
|
-
import '../../number/branded-types/non-zero-int.mjs';
|
|
16
|
-
import '../../number/branded-types/non-zero-int16.mjs';
|
|
17
|
-
import '../../number/branded-types/non-zero-int32.mjs';
|
|
18
|
-
import '../../number/branded-types/non-zero-safe-int.mjs';
|
|
19
|
-
import '../../number/branded-types/non-zero-uint16.mjs';
|
|
20
|
-
import '../../number/branded-types/non-zero-uint32.mjs';
|
|
21
|
-
import '../../number/branded-types/positive-finite-number.mjs';
|
|
22
|
-
import '../../number/branded-types/positive-int.mjs';
|
|
23
|
-
import '../../number/branded-types/positive-int16.mjs';
|
|
24
|
-
import '../../number/branded-types/positive-int32.mjs';
|
|
25
|
-
import '../../number/branded-types/positive-safe-int.mjs';
|
|
26
|
-
import '../../number/branded-types/positive-uint16.mjs';
|
|
27
|
-
import '../../number/branded-types/positive-uint32.mjs';
|
|
28
|
-
import '../../number/branded-types/safe-int.mjs';
|
|
29
|
-
import '../../number/branded-types/safe-uint.mjs';
|
|
30
|
-
import '../../number/branded-types/uint.mjs';
|
|
31
|
-
import '../../number/branded-types/uint16.mjs';
|
|
32
|
-
import '../../number/branded-types/uint32.mjs';
|
|
33
|
-
import '../../number/enum/int8.mjs';
|
|
34
|
-
import '../../number/enum/uint8.mjs';
|
|
35
|
-
import { Num } from '../../number/num.mjs';
|
|
36
|
-
import '../../number/refined-number-utils.mjs';
|
|
37
|
-
|
|
38
|
-
function sliceClamped(...args) {
|
|
39
|
-
switch (args.length) {
|
|
40
|
-
case 3:
|
|
41
|
-
return sliceClampedImpl(...args);
|
|
42
|
-
case 2:
|
|
43
|
-
return (array) => sliceClampedImpl(array, ...args);
|
|
44
|
-
}
|
|
1
|
+
import { Num } from '../../number/index.mjs';
|
|
2
|
+
export function sliceClamped(...args) {
|
|
3
|
+
switch (args.length) {
|
|
4
|
+
case 3:
|
|
5
|
+
return sliceClampedImpl(...args);
|
|
6
|
+
case 2:
|
|
7
|
+
return (array) => sliceClampedImpl(array, ...args);
|
|
8
|
+
}
|
|
45
9
|
}
|
|
46
10
|
const sliceClampedImpl = (array, start, end) => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
11
|
+
const startClamped = Num.clamp(0, array.length)(start);
|
|
12
|
+
// Ensure endClamped is not less than startClamped.
|
|
13
|
+
const endClamped = Num.clamp(startClamped, array.length)(end);
|
|
14
|
+
return array.slice(startClamped, endClamped);
|
|
50
15
|
};
|
|
51
|
-
|
|
52
|
-
export { sliceClamped };
|
|
53
|
-
//# sourceMappingURL=array-utils-slice-clamped.mjs.map
|
|
16
|
+
//# sourceMappingURL=array-utils-slice-clamped.mjs.map
|