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,20 +1,30 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import { unknownToString } from '../../../others/unknown-to-string.mjs';
|
|
1
|
+
import { unknownToString } from '../../../others/index.mjs';
|
|
3
2
|
import { isWarn } from './ternary-result-is-warn.mjs';
|
|
4
3
|
import { variantName } from './variant-name.mjs';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Returns the Warn value or throws if the result is not Warn.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* const warnValue = TernaryResult.warn('pending', 'check logs');
|
|
11
|
+
*
|
|
12
|
+
* assert.strictEqual(TernaryResult.unwrapWarnThrow(warnValue), 'check logs');
|
|
13
|
+
*
|
|
14
|
+
* assert.throws(
|
|
15
|
+
* () => TernaryResult.unwrapWarnThrow(TernaryResult.err('err')),
|
|
16
|
+
* /Expected Warn/u,
|
|
17
|
+
* );
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export const unwrapWarnThrow = (result, toStr = unknownToString) => {
|
|
21
|
+
if (isWarn(result)) {
|
|
22
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
23
|
+
return result.warning;
|
|
24
|
+
}
|
|
25
|
+
const variant = variantName(result.$$tag);
|
|
26
|
+
throw new Error(`Expected Warn but got ${variant}: ${toStr(
|
|
27
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
28
|
+
result.value)}`);
|
|
17
29
|
};
|
|
18
|
-
|
|
19
|
-
export { unwrapWarnThrow };
|
|
20
|
-
//# sourceMappingURL=ternary-result-unwrap-warn-throw.mjs.map
|
|
30
|
+
//# sourceMappingURL=ternary-result-unwrap-warn-throw.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ternary-result-unwrap-warn-throw.mjs","sources":["../../../../src/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mts"],"
|
|
1
|
+
{"version":3,"file":"ternary-result-unwrap-warn-throw.mjs","sourceRoot":"","sources":["../../../../src/functional/ternary-result/impl/ternary-result-unwrap-warn-throw.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAE5D,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,MAAS,EACT,KAAK,GAAkD,eAAe,EACvD,EAAE;IACjB,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC;QACnB,oEAAoE;QACpE,OAAO,MAAM,CAAC,OAAwB,CAAC;IACzC,CAAC;IAED,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAE1C,MAAM,IAAI,KAAK,CACb,yBAAyB,OAAO,KAAK,KAAK;IACxC,oEAAoE;IACpE,MAAM,CAAC,KAAmC,CAC3C,EAAE,CACJ,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { isWarn } from './ternary-result-is-warn.mjs';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Safely unwraps the Warn value.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
*
|
|
7
|
+
* ```ts
|
|
8
|
+
* const warnValue = TernaryResult.warn('ok', 'careful');
|
|
9
|
+
*
|
|
10
|
+
* const okValue = TernaryResult.ok('ok');
|
|
11
|
+
*
|
|
12
|
+
* assert.strictEqual(TernaryResult.unwrapWarn(warnValue), 'careful');
|
|
13
|
+
*
|
|
14
|
+
* // eslint-disable-next-line @typescript-eslint/no-confusing-void-expression
|
|
15
|
+
* assert.strictEqual(TernaryResult.unwrapWarn(okValue), undefined);
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export const unwrapWarn = (result) =>
|
|
19
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
20
|
+
isWarn(result) ? result.warning : undefined;
|
|
21
|
+
//# sourceMappingURL=ternary-result-unwrap-warn.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ternary-result-unwrap-warn.mjs","sources":["../../../../src/functional/ternary-result/impl/ternary-result-unwrap-warn.mts"],"
|
|
1
|
+
{"version":3,"file":"ternary-result-unwrap-warn.mjs","sourceRoot":"","sources":["../../../../src/functional/ternary-result/impl/ternary-result-unwrap-warn.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAGtD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,MAAS,EACkB,EAAE;AAC7B,oEAAoE;AACpE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAE,MAAM,CAAC,OAAyB,CAAC,CAAC,CAAC,SAAS,CAAC"}
|
|
@@ -1,10 +1,23 @@
|
|
|
1
1
|
import { WarnTypeTagName } from './tag.mjs';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Creates a `TernaryResult.Warn` containing the provided success value and
|
|
4
|
+
* warning.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* const caution = TernaryResult.warn({ id: 1 }, 'Needs review');
|
|
10
|
+
*
|
|
11
|
+
* assert.deepStrictEqual(caution, {
|
|
12
|
+
* $$tag: 'ts-data-forge::Result.warn',
|
|
13
|
+
* value: { id: 1 },
|
|
14
|
+
* warning: 'Needs review',
|
|
15
|
+
* });
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export const warn = (value, warning) => ({
|
|
19
|
+
$$tag: WarnTypeTagName,
|
|
20
|
+
value,
|
|
21
|
+
warning,
|
|
7
22
|
});
|
|
8
|
-
|
|
9
|
-
export { warn };
|
|
10
|
-
//# sourceMappingURL=ternary-result-warn.mjs.map
|
|
23
|
+
//# sourceMappingURL=ternary-result-warn.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ternary-result-warn.mjs","sources":["../../../../src/functional/ternary-result/impl/ternary-result-warn.mts"],"
|
|
1
|
+
{"version":3,"file":"ternary-result-warn.mjs","sourceRoot":"","sources":["../../../../src/functional/ternary-result/impl/ternary-result-warn.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAClB,KAAQ,EACR,OAAU,EACS,EAAE,CACrB,CAAC;IACC,KAAK,EAAE,eAAe;IACtB,KAAK;IACL,OAAO;CACR,CAAU,CAAC"}
|
|
@@ -2,23 +2,51 @@ import { isErr } from './ternary-result-is-err.mjs';
|
|
|
2
2
|
import { isWarn } from './ternary-result-is-warn.mjs';
|
|
3
3
|
import { ok } from './ternary-result-ok.mjs';
|
|
4
4
|
import { warn } from './ternary-result-warn.mjs';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Combines two `TernaryResult`s, prioritising Err over Warn over Ok.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
*
|
|
10
|
+
* ```ts
|
|
11
|
+
* const okPair = TernaryResult.zip(
|
|
12
|
+
* TernaryResult.ok('left'),
|
|
13
|
+
* TernaryResult.ok(1),
|
|
14
|
+
* );
|
|
15
|
+
*
|
|
16
|
+
* const warnPair = TernaryResult.zip(
|
|
17
|
+
* TernaryResult.warn('left', 'warn'),
|
|
18
|
+
* TernaryResult.ok(1),
|
|
19
|
+
* );
|
|
20
|
+
*
|
|
21
|
+
* const errPair = TernaryResult.zip(
|
|
22
|
+
* TernaryResult.ok('left'),
|
|
23
|
+
* TernaryResult.err('err'),
|
|
24
|
+
* );
|
|
25
|
+
*
|
|
26
|
+
* assert.deepStrictEqual(okPair, TernaryResult.ok(['left', 1] as const));
|
|
27
|
+
*
|
|
28
|
+
* assert.deepStrictEqual(
|
|
29
|
+
* warnPair,
|
|
30
|
+
* TernaryResult.warn(['left', 1] as const, 'warn'),
|
|
31
|
+
* );
|
|
32
|
+
*
|
|
33
|
+
* assert.deepStrictEqual(errPair, TernaryResult.err('err'));
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export const zip = (resultA, resultB) => {
|
|
37
|
+
if (isErr(resultA)) {
|
|
38
|
+
return resultA;
|
|
39
|
+
}
|
|
40
|
+
if (isErr(resultB)) {
|
|
41
|
+
return resultB;
|
|
42
|
+
}
|
|
43
|
+
const pair = [resultA.value, resultB.value];
|
|
44
|
+
if (isWarn(resultA)) {
|
|
45
|
+
return warn(pair, resultA.warning);
|
|
46
|
+
}
|
|
47
|
+
if (isWarn(resultB)) {
|
|
48
|
+
return warn(pair, resultB.warning);
|
|
49
|
+
}
|
|
50
|
+
return ok(pair);
|
|
21
51
|
};
|
|
22
|
-
|
|
23
|
-
export { zip };
|
|
24
|
-
//# sourceMappingURL=ternary-result-zip.mjs.map
|
|
52
|
+
//# sourceMappingURL=ternary-result-zip.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ternary-result-zip.mjs","sources":["../../../../src/functional/ternary-result/impl/ternary-result-zip.mts"],"
|
|
1
|
+
{"version":3,"file":"ternary-result-zip.mjs","sourceRoot":"","sources":["../../../../src/functional/ternary-result/impl/ternary-result-zip.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,6BAA6B,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtD,OAAO,EAAE,EAAE,EAAE,MAAM,yBAAyB,CAAC;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,2BAA2B,CAAC;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,MAAM,GAAG,GAAG,CACjB,OAAkC,EAClC,OAAkC,EACkB,EAAE;IACtD,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACnB,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACnB,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAU,CAAC;IAErD,IAAI,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAED,IAAI,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;QACpB,OAAO,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;IACrC,CAAC;IAED,OAAO,EAAE,CAAC,IAAI,CAAC,CAAC;AAClB,CAAC,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
//# sourceMappingURL=types.mjs.map
|
|
1
|
+
export {};
|
|
2
|
+
//# sourceMappingURL=types.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.mjs","
|
|
1
|
+
{"version":3,"file":"types.mjs","sourceRoot":"","sources":["../../../../src/functional/ternary-result/impl/types.mts"],"names":[],"mappings":""}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { ErrTypeTagName,
|
|
2
|
-
|
|
3
|
-
const variantName = (tag) => {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { ErrTypeTagName, OkTypeTagName, WarnTypeTagName } from './tag.mjs';
|
|
2
|
+
/** @internal Returns the human readable variant label for the given tag. */
|
|
3
|
+
export const variantName = (tag) => {
|
|
4
|
+
switch (tag) {
|
|
5
|
+
case OkTypeTagName:
|
|
6
|
+
return 'Ok';
|
|
7
|
+
case WarnTypeTagName:
|
|
8
|
+
return 'Warn';
|
|
9
|
+
case ErrTypeTagName:
|
|
10
|
+
return 'Err';
|
|
11
|
+
}
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
export { variantName };
|
|
15
|
-
//# sourceMappingURL=variant-name.mjs.map
|
|
13
|
+
//# sourceMappingURL=variant-name.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variant-name.mjs","sources":["../../../../src/functional/ternary-result/impl/variant-name.mts"],"
|
|
1
|
+
{"version":3,"file":"variant-name.mjs","sourceRoot":"","sources":["../../../../src/functional/ternary-result/impl/variant-name.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE3E,4EAA4E;AAC5E,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,GAAkC,EACX,EAAE;IACzB,QAAQ,GAAG,EAAE,CAAC;QACZ,KAAK,aAAa;YAChB,OAAO,IAAI,CAAC;QAEd,KAAK,eAAe;YAClB,OAAO,MAAM,CAAC;QAEhB,KAAK,cAAc;YACjB,OAAO,KAAK,CAAC;IACjB,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
export * from './ternary-result.mjs';
|
|
2
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../../src/functional/ternary-result/index.mts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC"}
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
//# sourceMappingURL=ternary-result.mjs.map
|
|
1
|
+
export * as TernaryResult from './impl/index.mjs';
|
|
2
|
+
//# sourceMappingURL=ternary-result.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ternary-result.mjs","
|
|
1
|
+
{"version":3,"file":"ternary-result.mjs","sourceRoot":"","sources":["../../../src/functional/ternary-result/ternary-result.mts"],"names":[],"mappings":"AAiDA,OAAO,KAAK,aAAa,MAAM,kBAAkB,CAAC"}
|
package/dist/guard/has-key.mjs
CHANGED
|
@@ -1,4 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Type guard function that checks if an object has a specific key as its own
|
|
3
|
+
* property.
|
|
4
|
+
*
|
|
5
|
+
* This function uses `Object.hasOwn()` to check if the given object has the
|
|
6
|
+
* specified key as its own property (not inherited). It acts as a type guard
|
|
7
|
+
* that narrows the type of the object to guarantee the key exists, enabling
|
|
8
|
+
* type-safe property access.
|
|
9
|
+
*
|
|
10
|
+
* **Type Narrowing Behavior:**
|
|
11
|
+
*
|
|
12
|
+
* - When the guard returns `true`, TypeScript narrows the object type to include
|
|
13
|
+
* the checked key
|
|
14
|
+
* - For union types, only union members that contain the key are preserved
|
|
15
|
+
* - The key's value type is preserved from the original object type when possible
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
*
|
|
19
|
+
* ```ts
|
|
20
|
+
* const maybeUser: Readonly<{ id?: number; name?: string }> = {
|
|
21
|
+
* id: 42,
|
|
22
|
+
* } as const;
|
|
23
|
+
*
|
|
24
|
+
* if (hasKey(maybeUser, 'id')) {
|
|
25
|
+
* // `maybeUser` is now known to have an `id` property.
|
|
26
|
+
* assert.isTrue(maybeUser.id === 42);
|
|
27
|
+
* } else {
|
|
28
|
+
* assert.fail();
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @template R - The type of the input object, must extend UnknownRecord
|
|
33
|
+
* @template K - The type of the key to check for, must extend PropertyKey
|
|
34
|
+
* (string | number | symbol)
|
|
35
|
+
* @param obj - The object to check for the presence of the key
|
|
36
|
+
* @param key - The key to check for in the object
|
|
37
|
+
* @returns `true` if the object has the specified key as its own property,
|
|
38
|
+
* `false` otherwise. When `true`, TypeScript narrows the object type to
|
|
39
|
+
* guarantee the key exists.
|
|
40
|
+
* @see {@link keyIsIn} - Similar function that narrows the key type instead of the object type
|
|
41
|
+
*/
|
|
42
|
+
export const hasKey = (obj, key) => Object.hasOwn(obj, key);
|
|
43
|
+
//# sourceMappingURL=has-key.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"has-key.mjs","sources":["../../src/guard/has-key.mts"],"
|
|
1
|
+
{"version":3,"file":"has-key.mjs","sourceRoot":"","sources":["../../src/guard/has-key.mts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CAIpB,GAAM,EACN,GAAM,EACyB,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC"}
|
package/dist/guard/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
6
|
-
export
|
|
7
|
-
export
|
|
8
|
-
//# sourceMappingURL=index.mjs.map
|
|
1
|
+
export * from './has-key.mjs';
|
|
2
|
+
export * from './is-non-empty-string.mjs';
|
|
3
|
+
export * from './is-non-null-object.mjs';
|
|
4
|
+
export * from './is-primitive.mjs';
|
|
5
|
+
export * from './is-record.mjs';
|
|
6
|
+
export * from './is-type.mjs';
|
|
7
|
+
export * from './key-is-in.mjs';
|
|
8
|
+
//# sourceMappingURL=index.mjs.map
|
package/dist/guard/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/guard/index.mts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,iBAAiB,CAAC"}
|
|
@@ -1,4 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Type guard that checks if a value is a non-empty string.
|
|
3
|
+
*
|
|
4
|
+
* This function performs both a type check (ensuring the value is a string) and
|
|
5
|
+
* a length check (ensuring the string is not empty). It acts as a type guard
|
|
6
|
+
* that narrows the input type to exclude `null`, `undefined`, and empty
|
|
7
|
+
* strings.
|
|
8
|
+
*
|
|
9
|
+
* **Type Narrowing Behavior:**
|
|
10
|
+
*
|
|
11
|
+
* - Eliminates `null` and `undefined` from the type
|
|
12
|
+
* - Excludes empty string (`""`) from the type
|
|
13
|
+
* - Preserves literal string types when possible
|
|
14
|
+
* - Whitespace-only strings are considered non-empty
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* const words: readonly (string | undefined)[] = [
|
|
20
|
+
* 'Ada',
|
|
21
|
+
* undefined,
|
|
22
|
+
* '',
|
|
23
|
+
* 'Lovelace',
|
|
24
|
+
* ] as const;
|
|
25
|
+
*
|
|
26
|
+
* const nonEmpty = words.filter(isNonEmptyString);
|
|
27
|
+
*
|
|
28
|
+
* assert.deepStrictEqual(nonEmpty, ['Ada', 'Lovelace']);
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* @template S - The input type, which can include `string`, `null`, or
|
|
32
|
+
* `undefined`
|
|
33
|
+
* @param s - The value to check
|
|
34
|
+
* @returns `true` if `s` is a string with length > 0, `false` otherwise. When
|
|
35
|
+
* `true`, TypeScript narrows the type to exclude empty strings and nullish
|
|
36
|
+
* values.
|
|
37
|
+
*/
|
|
38
|
+
export const isNonEmptyString = (s) => typeof s === 'string' && s.length > 0;
|
|
39
|
+
//# sourceMappingURL=is-non-empty-string.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-non-empty-string.mjs","sources":["../../src/guard/is-non-empty-string.mts"],"
|
|
1
|
+
{"version":3,"file":"is-non-empty-string.mjs","sourceRoot":"","sources":["../../src/guard/is-non-empty-string.mts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,CAAI,EACsD,EAAE,CAC5D,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC"}
|
|
@@ -1,4 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Type guard that checks if a value is a non-null object.
|
|
3
|
+
*
|
|
4
|
+
* This function checks if a value has type `"object"` according to the `typeof`
|
|
5
|
+
* operator and is not `null`. This includes all object types such as plain
|
|
6
|
+
* objects, arrays, dates, regular expressions, and other object instances, but
|
|
7
|
+
* excludes functions.
|
|
8
|
+
*
|
|
9
|
+
* **Type Narrowing Behavior:**
|
|
10
|
+
*
|
|
11
|
+
* - Narrows `unknown` to `object`
|
|
12
|
+
* - Excludes `null`, `undefined`, and all primitive types
|
|
13
|
+
* - Excludes functions (they have `typeof` === `"function"`, not `"object"`)
|
|
14
|
+
* - Includes arrays, dates, regex, and other object instances
|
|
15
|
+
*
|
|
16
|
+
* **Note:** This function returns `true` for arrays. If you need
|
|
17
|
+
* record-oriented narrowing that excludes arrays, use `isRecord()` instead.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* const mixed: readonly unknown[] = [{ id: 1 }, null, 'Ada'] as const;
|
|
23
|
+
*
|
|
24
|
+
* const objects = mixed.filter(isNonNullObject);
|
|
25
|
+
*
|
|
26
|
+
* assert.deepStrictEqual(objects, [{ id: 1 }]);
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @param u - The value to check
|
|
30
|
+
* @returns `true` if `u` is an object and not `null`, `false` otherwise. When
|
|
31
|
+
* `true`, TypeScript narrows the type to `object`.
|
|
32
|
+
* @see {@link isRecord} - For record-oriented type narrowing (excludes arrays)
|
|
33
|
+
*/
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-restricted-types
|
|
35
|
+
export const isNonNullObject = (u) => typeof u === 'object' && u !== null;
|
|
36
|
+
//# sourceMappingURL=is-non-null-object.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-non-null-object.mjs","sources":["../../src/guard/is-non-null-object.mts"],"
|
|
1
|
+
{"version":3,"file":"is-non-null-object.mjs","sourceRoot":"","sources":["../../src/guard/is-non-null-object.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,kEAAkE;AAClE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAU,EAAe,EAAE,CACzD,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,CAAC"}
|
|
@@ -1,17 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* Type guard that checks if a value is a primitive type.
|
|
4
|
+
*
|
|
5
|
+
* This function identifies JavaScript primitive types, which are immutable data
|
|
6
|
+
* types that are not objects. The primitive types are: `string`, `number`,
|
|
7
|
+
* `boolean`, `undefined`, `symbol`, `bigint`, and `null`.
|
|
8
|
+
*
|
|
9
|
+
* **Important Note:** Although `null` has `typeof null === "object"` due to a
|
|
10
|
+
* historical JavaScript quirk, this function correctly identifies `null` as a
|
|
11
|
+
* primitive value.
|
|
12
|
+
*
|
|
13
|
+
* **Type Narrowing Behavior:**
|
|
14
|
+
*
|
|
15
|
+
* - Narrows the input type to `Primitive` (union of all primitive types)
|
|
16
|
+
* - Excludes object types, arrays, functions, and other non-primitive values
|
|
17
|
+
* - Includes `null` despite its misleading `typeof` result
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
*
|
|
21
|
+
* ```ts
|
|
22
|
+
* const values: readonly unknown[] = [42, 'Ada', null, { id: 1 }] as const;
|
|
23
|
+
*
|
|
24
|
+
* const primitives = values.filter(isPrimitive);
|
|
25
|
+
*
|
|
26
|
+
* assert.deepStrictEqual(primitives, [42, 'Ada', null]);
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @param u - The value to check
|
|
30
|
+
* @returns `true` if `u` is a primitive type, `false` otherwise. When `true`,
|
|
31
|
+
* TypeScript narrows the type to `Primitive`.
|
|
32
|
+
*/
|
|
33
|
+
export const isPrimitive = (u) => {
|
|
34
|
+
switch (typeof u) {
|
|
35
|
+
case 'string':
|
|
36
|
+
case 'number':
|
|
37
|
+
case 'boolean':
|
|
38
|
+
case 'undefined':
|
|
39
|
+
case 'symbol':
|
|
40
|
+
case 'bigint':
|
|
41
|
+
return true;
|
|
42
|
+
case 'function':
|
|
43
|
+
case 'object':
|
|
44
|
+
return u === null;
|
|
45
|
+
}
|
|
14
46
|
};
|
|
15
47
|
|
|
16
|
-
|
|
17
|
-
//# sourceMappingURL=is-primitive.mjs.map
|
|
48
|
+
//# sourceMappingURL=is-primitive.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"is-primitive.mjs","sources":["../../src/guard/is-primitive.mts"],"
|
|
1
|
+
{"version":3,"file":"is-primitive.mjs","sourceRoot":"","sources":["../../src/guard/is-primitive.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAU,EAAkB,EAAE;IACxD,QAAQ,OAAO,CAAC,EAAE,CAAC;QACjB,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,SAAS,CAAC;QACf,KAAK,WAAW,CAAC;QACjB,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ;YACX,OAAO,IAAI,CAAC;QACd,KAAK,UAAU,CAAC;QAChB,KAAK,QAAQ;YACX,OAAO,CAAC,KAAK,IAAI,CAAC;IACtB,CAAC;AACH,CAAC,CAAC;AAEF,UAAU,CAGR,GAAG,CAAC,CAAC"}
|