ts-data-forge 3.2.0 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -21
- package/dist/array/impl/array-utils-creation.d.mts +116 -0
- package/dist/array/impl/array-utils-creation.d.mts.map +1 -0
- package/dist/array/impl/array-utils-creation.mjs +110 -0
- package/dist/array/impl/array-utils-creation.mjs.map +1 -0
- package/dist/array/impl/array-utils-element-access.d.mts +61 -0
- package/dist/array/impl/array-utils-element-access.d.mts.map +1 -0
- package/dist/array/impl/array-utils-element-access.mjs +66 -0
- package/dist/array/impl/array-utils-element-access.mjs.map +1 -0
- package/dist/array/impl/array-utils-iterators.d.mts +59 -0
- package/dist/array/impl/array-utils-iterators.d.mts.map +1 -0
- package/dist/array/impl/array-utils-iterators.mjs +104 -0
- package/dist/array/impl/array-utils-iterators.mjs.map +1 -0
- package/dist/array/impl/array-utils-modification.d.mts +154 -0
- package/dist/array/impl/array-utils-modification.d.mts.map +1 -0
- package/dist/array/impl/array-utils-modification.mjs +139 -0
- package/dist/array/impl/array-utils-modification.mjs.map +1 -0
- package/dist/array/impl/array-utils-reducing-value.d.mts +214 -0
- package/dist/array/impl/array-utils-reducing-value.d.mts.map +1 -0
- package/dist/array/impl/array-utils-reducing-value.mjs +160 -0
- package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -0
- package/dist/array/impl/array-utils-search.d.mts +179 -0
- package/dist/array/impl/array-utils-search.d.mts.map +1 -0
- package/dist/array/impl/array-utils-search.mjs +153 -0
- package/dist/array/impl/array-utils-search.mjs.map +1 -0
- package/dist/array/impl/array-utils-set-op.d.mts +100 -0
- package/dist/array/impl/array-utils-set-op.d.mts.map +1 -0
- package/dist/array/impl/array-utils-set-op.mjs +137 -0
- package/dist/array/impl/array-utils-set-op.mjs.map +1 -0
- package/dist/array/impl/array-utils-size.d.mts +24 -0
- package/dist/array/impl/array-utils-size.d.mts.map +1 -0
- package/dist/array/impl/array-utils-size.mjs +28 -0
- package/dist/array/impl/array-utils-size.mjs.map +1 -0
- package/dist/array/impl/array-utils-slice-clamped.d.mts +18 -0
- package/dist/array/impl/array-utils-slice-clamped.d.mts.map +1 -0
- package/dist/array/impl/array-utils-slice-clamped.mjs +49 -0
- package/dist/array/impl/array-utils-slice-clamped.mjs.map +1 -0
- package/dist/array/impl/array-utils-slicing.d.mts +120 -0
- package/dist/array/impl/array-utils-slicing.d.mts.map +1 -0
- package/dist/array/impl/array-utils-slicing.mjs +140 -0
- package/dist/array/impl/array-utils-slicing.mjs.map +1 -0
- package/dist/array/impl/array-utils-transformation.d.mts +348 -0
- package/dist/array/impl/array-utils-transformation.d.mts.map +1 -0
- package/dist/array/impl/array-utils-transformation.mjs +331 -0
- package/dist/array/impl/array-utils-transformation.mjs.map +1 -0
- package/dist/array/impl/array-utils-validation.d.mts +149 -0
- package/dist/array/impl/array-utils-validation.d.mts.map +1 -0
- package/dist/array/impl/array-utils-validation.mjs +166 -0
- package/dist/array/impl/array-utils-validation.mjs.map +1 -0
- package/dist/array/impl/index.d.mts +13 -0
- package/dist/array/impl/index.d.mts.map +1 -0
- package/dist/array/impl/index.mjs +13 -0
- package/dist/array/impl/index.mjs.map +1 -0
- package/dist/array/index.d.mts +1 -1
- package/dist/array/index.d.mts.map +1 -1
- package/dist/array/index.mjs +2 -1
- package/dist/array/index.mjs.map +1 -1
- package/dist/collections/imap-mapped.d.mts +83 -253
- package/dist/collections/imap-mapped.d.mts.map +1 -1
- package/dist/collections/imap-mapped.mjs +33 -164
- package/dist/collections/imap-mapped.mjs.map +1 -1
- package/dist/collections/imap.d.mts +436 -163
- package/dist/collections/imap.d.mts.map +1 -1
- package/dist/collections/imap.mjs +74 -94
- package/dist/collections/imap.mjs.map +1 -1
- package/dist/collections/iset-mapped.d.mts +828 -345
- package/dist/collections/iset-mapped.d.mts.map +1 -1
- package/dist/collections/iset-mapped.mjs +200 -242
- package/dist/collections/iset-mapped.mjs.map +1 -1
- package/dist/collections/iset.d.mts +397 -205
- package/dist/collections/iset.d.mts.map +1 -1
- package/dist/collections/iset.mjs +102 -184
- package/dist/collections/iset.mjs.map +1 -1
- package/dist/collections/queue.d.mts +155 -135
- package/dist/collections/queue.d.mts.map +1 -1
- package/dist/collections/queue.mjs +55 -156
- package/dist/collections/queue.mjs.map +1 -1
- package/dist/collections/stack.d.mts +154 -154
- package/dist/collections/stack.d.mts.map +1 -1
- package/dist/collections/stack.mjs +54 -203
- package/dist/collections/stack.mjs.map +1 -1
- package/dist/entry-point.d.mts +3 -0
- package/dist/entry-point.d.mts.map +1 -0
- package/dist/entry-point.mjs +62 -0
- package/dist/entry-point.mjs.map +1 -0
- package/dist/expect-type.d.mts +43 -172
- package/dist/expect-type.d.mts.map +1 -1
- package/dist/expect-type.mjs +43 -172
- package/dist/expect-type.mjs.map +1 -1
- package/dist/functional/match.d.mts +35 -140
- package/dist/functional/match.d.mts.map +1 -1
- package/dist/functional/match.mjs.map +1 -1
- package/dist/functional/optional.d.mts +282 -160
- package/dist/functional/optional.d.mts.map +1 -1
- package/dist/functional/optional.mjs +131 -71
- package/dist/functional/optional.mjs.map +1 -1
- package/dist/functional/pipe.d.mts +59 -113
- package/dist/functional/pipe.d.mts.map +1 -1
- package/dist/functional/pipe.mjs.map +1 -1
- package/dist/functional/result.d.mts +433 -332
- package/dist/functional/result.d.mts.map +1 -1
- package/dist/functional/result.mjs +233 -239
- package/dist/functional/result.mjs.map +1 -1
- package/dist/globals.d.mts +12 -5
- package/dist/guard/has-key.d.mts +23 -74
- package/dist/guard/has-key.d.mts.map +1 -1
- package/dist/guard/has-key.mjs +23 -74
- package/dist/guard/has-key.mjs.map +1 -1
- package/dist/guard/is-non-empty-string.d.mts +20 -87
- package/dist/guard/is-non-empty-string.d.mts.map +1 -1
- package/dist/guard/is-non-empty-string.mjs +20 -87
- package/dist/guard/is-non-empty-string.mjs.map +1 -1
- package/dist/guard/is-non-null-object.d.mts +14 -84
- package/dist/guard/is-non-null-object.d.mts.map +1 -1
- package/dist/guard/is-non-null-object.mjs +14 -84
- package/dist/guard/is-non-null-object.mjs.map +1 -1
- package/dist/guard/is-primitive.d.mts +13 -126
- package/dist/guard/is-primitive.d.mts.map +1 -1
- package/dist/guard/is-primitive.mjs +13 -126
- package/dist/guard/is-primitive.mjs.map +1 -1
- package/dist/guard/is-record.d.mts +21 -132
- package/dist/guard/is-record.d.mts.map +1 -1
- package/dist/guard/is-record.mjs +21 -132
- package/dist/guard/is-record.mjs.map +1 -1
- package/dist/guard/is-type.d.mts +201 -238
- package/dist/guard/is-type.d.mts.map +1 -1
- package/dist/guard/is-type.mjs +201 -238
- package/dist/guard/is-type.mjs.map +1 -1
- package/dist/guard/key-is-in.d.mts +22 -139
- package/dist/guard/key-is-in.d.mts.map +1 -1
- package/dist/guard/key-is-in.mjs +22 -139
- package/dist/guard/key-is-in.mjs.map +1 -1
- package/dist/index.d.mts +0 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +0 -1
- package/dist/index.mjs.map +1 -1
- package/dist/iterator/range.d.mts +29 -62
- package/dist/iterator/range.d.mts.map +1 -1
- package/dist/iterator/range.mjs.map +1 -1
- package/dist/json/json.d.mts +191 -121
- package/dist/json/json.d.mts.map +1 -1
- package/dist/json/json.mjs +238 -136
- package/dist/json/json.mjs.map +1 -1
- package/dist/number/branded-types/finite-number.d.mts +24 -156
- package/dist/number/branded-types/finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/finite-number.mjs +27 -159
- package/dist/number/branded-types/finite-number.mjs.map +1 -1
- package/dist/number/branded-types/int.d.mts +122 -120
- package/dist/number/branded-types/int.d.mts.map +1 -1
- package/dist/number/branded-types/int.mjs +122 -120
- package/dist/number/branded-types/int.mjs.map +1 -1
- package/dist/number/branded-types/int16.d.mts +22 -30
- package/dist/number/branded-types/int16.d.mts.map +1 -1
- package/dist/number/branded-types/int16.mjs +22 -30
- package/dist/number/branded-types/int16.mjs.map +1 -1
- package/dist/number/branded-types/int32.d.mts +22 -31
- package/dist/number/branded-types/int32.d.mts.map +1 -1
- package/dist/number/branded-types/int32.mjs +22 -31
- package/dist/number/branded-types/int32.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-finite-number.d.mts +28 -36
- package/dist/number/branded-types/non-negative-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/non-negative-finite-number.mjs +31 -39
- package/dist/number/branded-types/non-negative-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-int16.d.mts +24 -34
- package/dist/number/branded-types/non-negative-int16.d.mts.map +1 -1
- package/dist/number/branded-types/non-negative-int16.mjs +24 -34
- package/dist/number/branded-types/non-negative-int16.mjs.map +1 -1
- package/dist/number/branded-types/non-negative-int32.d.mts +26 -35
- package/dist/number/branded-types/non-negative-int32.d.mts.map +1 -1
- package/dist/number/branded-types/non-negative-int32.mjs +26 -35
- package/dist/number/branded-types/non-negative-int32.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-finite-number.d.mts +22 -37
- package/dist/number/branded-types/non-zero-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-finite-number.mjs +25 -40
- package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int.d.mts +15 -30
- package/dist/number/branded-types/non-zero-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-int.mjs +15 -30
- package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int16.d.mts +27 -35
- package/dist/number/branded-types/non-zero-int16.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-int16.mjs +27 -35
- package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int32.d.mts +29 -36
- package/dist/number/branded-types/non-zero-int32.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-int32.mjs +29 -36
- package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-safe-int.d.mts +37 -38
- package/dist/number/branded-types/non-zero-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-safe-int.mjs +39 -40
- package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint16.d.mts +24 -35
- package/dist/number/branded-types/non-zero-uint16.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-uint16.mjs +24 -35
- package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint32.d.mts +24 -35
- package/dist/number/branded-types/non-zero-uint32.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-uint32.mjs +24 -35
- package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
- package/dist/number/branded-types/positive-finite-number.d.mts +26 -40
- package/dist/number/branded-types/positive-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/positive-finite-number.mjs +29 -43
- package/dist/number/branded-types/positive-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/positive-int.d.mts +133 -123
- package/dist/number/branded-types/positive-int.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int.mjs +133 -123
- package/dist/number/branded-types/positive-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-int16.d.mts +24 -35
- package/dist/number/branded-types/positive-int16.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int16.mjs +24 -35
- package/dist/number/branded-types/positive-int16.mjs.map +1 -1
- package/dist/number/branded-types/positive-int32.d.mts +24 -35
- package/dist/number/branded-types/positive-int32.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int32.mjs +24 -35
- package/dist/number/branded-types/positive-int32.mjs.map +1 -1
- package/dist/number/branded-types/positive-safe-int.d.mts +159 -33
- package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/positive-safe-int.mjs +160 -34
- package/dist/number/branded-types/positive-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/positive-uint16.d.mts +24 -35
- package/dist/number/branded-types/positive-uint16.d.mts.map +1 -1
- package/dist/number/branded-types/positive-uint16.mjs +24 -35
- package/dist/number/branded-types/positive-uint16.mjs.map +1 -1
- package/dist/number/branded-types/positive-uint32.d.mts +26 -36
- package/dist/number/branded-types/positive-uint32.d.mts.map +1 -1
- package/dist/number/branded-types/positive-uint32.mjs +26 -36
- package/dist/number/branded-types/positive-uint32.mjs.map +1 -1
- package/dist/number/branded-types/safe-int.d.mts +140 -99
- package/dist/number/branded-types/safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/safe-int.mjs +142 -101
- package/dist/number/branded-types/safe-int.mjs.map +1 -1
- package/dist/number/branded-types/safe-uint.d.mts +24 -33
- package/dist/number/branded-types/safe-uint.d.mts.map +1 -1
- package/dist/number/branded-types/safe-uint.mjs +25 -34
- package/dist/number/branded-types/safe-uint.mjs.map +1 -1
- package/dist/number/branded-types/uint.d.mts +121 -30
- package/dist/number/branded-types/uint.d.mts.map +1 -1
- package/dist/number/branded-types/uint.mjs +121 -30
- package/dist/number/branded-types/uint.mjs.map +1 -1
- package/dist/number/branded-types/uint16.d.mts +26 -34
- package/dist/number/branded-types/uint16.d.mts.map +1 -1
- package/dist/number/branded-types/uint16.mjs +26 -34
- package/dist/number/branded-types/uint16.mjs.map +1 -1
- package/dist/number/branded-types/uint32.d.mts +26 -68
- package/dist/number/branded-types/uint32.d.mts.map +1 -1
- package/dist/number/branded-types/uint32.mjs +26 -68
- package/dist/number/branded-types/uint32.mjs.map +1 -1
- package/dist/number/enum/int8.d.mts +37 -101
- package/dist/number/enum/int8.d.mts.map +1 -1
- package/dist/number/enum/int8.mjs +39 -170
- package/dist/number/enum/int8.mjs.map +1 -1
- package/dist/number/enum/uint8.d.mts +45 -55
- package/dist/number/enum/uint8.d.mts.map +1 -1
- package/dist/number/enum/uint8.mjs +46 -155
- package/dist/number/enum/uint8.mjs.map +1 -1
- package/dist/number/num.d.mts +145 -206
- package/dist/number/num.d.mts.map +1 -1
- package/dist/number/num.mjs +143 -199
- package/dist/number/num.mjs.map +1 -1
- package/dist/number/refined-number-utils.d.mts +97 -21
- package/dist/number/refined-number-utils.d.mts.map +1 -1
- package/dist/number/refined-number-utils.mjs +91 -20
- package/dist/number/refined-number-utils.mjs.map +1 -1
- package/dist/object/object.d.mts +126 -208
- package/dist/object/object.d.mts.map +1 -1
- package/dist/object/object.mjs +68 -102
- package/dist/object/object.mjs.map +1 -1
- package/dist/others/cast-mutable.d.mts +12 -88
- package/dist/others/cast-mutable.d.mts.map +1 -1
- package/dist/others/cast-mutable.mjs +13 -89
- package/dist/others/cast-mutable.mjs.map +1 -1
- package/dist/others/cast-readonly.d.mts +12 -168
- package/dist/others/cast-readonly.d.mts.map +1 -1
- package/dist/others/cast-readonly.mjs +13 -169
- package/dist/others/cast-readonly.mjs.map +1 -1
- package/dist/others/if-then.d.mts +6 -83
- package/dist/others/if-then.d.mts.map +1 -1
- package/dist/others/if-then.mjs +6 -83
- package/dist/others/if-then.mjs.map +1 -1
- package/dist/others/map-nullable.d.mts +12 -136
- package/dist/others/map-nullable.d.mts.map +1 -1
- package/dist/others/map-nullable.mjs.map +1 -1
- package/dist/others/memoize-function.d.mts +14 -157
- package/dist/others/memoize-function.d.mts.map +1 -1
- package/dist/others/memoize-function.mjs +14 -157
- package/dist/others/memoize-function.mjs.map +1 -1
- package/dist/others/tuple.d.mts +33 -151
- package/dist/others/tuple.d.mts.map +1 -1
- package/dist/others/tuple.mjs +33 -151
- package/dist/others/tuple.mjs.map +1 -1
- package/dist/others/unknown-to-string.d.mts +11 -125
- package/dist/others/unknown-to-string.d.mts.map +1 -1
- package/dist/others/unknown-to-string.mjs +14 -127
- package/dist/others/unknown-to-string.mjs.map +1 -1
- package/dist/promise/promise.d.mts +33 -20
- package/dist/promise/promise.d.mts.map +1 -1
- package/dist/promise/promise.mjs +34 -21
- package/dist/promise/promise.mjs.map +1 -1
- package/dist/types.d.mts +1 -1
- package/package.json +54 -50
- package/src/array/impl/array-utils-creation.mts +192 -0
- package/src/array/{array-utils-creation.test.mts → impl/array-utils-creation.test.mts} +121 -72
- package/src/array/impl/array-utils-element-access.mts +115 -0
- package/src/array/impl/array-utils-element-access.test.mts +151 -0
- package/src/array/impl/array-utils-iterators.mts +79 -0
- package/src/array/impl/array-utils-iterators.test.mts +98 -0
- package/src/array/impl/array-utils-modification.mts +434 -0
- package/src/array/{array-utils-modification.test.mts → impl/array-utils-modification.test.mts} +41 -28
- package/src/array/{array-utils-overload-type-error.test.mts → impl/array-utils-overload-type-error.test.mts} +33 -33
- package/src/array/impl/array-utils-reducing-value.mts +551 -0
- package/src/array/{array-utils-reducing-value.test.mts → impl/array-utils-reducing-value.test.mts} +45 -50
- package/src/array/impl/array-utils-search.mts +509 -0
- package/src/array/impl/array-utils-search.test.mts +346 -0
- package/src/array/impl/array-utils-set-op.mts +166 -0
- package/src/array/{array-utils-set-op.test.mts → impl/array-utils-set-op.test.mts} +42 -35
- package/src/array/impl/array-utils-size.mts +30 -0
- package/src/array/impl/array-utils-size.test.mts +9 -0
- package/src/array/impl/array-utils-slice-clamped.mts +51 -0
- package/src/array/{array-utils-slice-clamped.test.mts → impl/array-utils-slice-clamped.test.mts} +12 -12
- package/src/array/impl/array-utils-slicing.mts +275 -0
- package/src/array/impl/array-utils-slicing.test.mts +158 -0
- package/src/array/impl/array-utils-transformation.mts +746 -0
- package/src/array/{array-utils-transformation.test.mts → impl/array-utils-transformation.test.mts} +662 -889
- package/src/array/impl/array-utils-validation.mts +241 -0
- package/src/array/{array-utils-validation.test.mts → impl/array-utils-validation.test.mts} +194 -107
- package/src/array/{array.test.mts → impl/array.test.mts} +2 -2
- package/src/array/impl/index.mts +12 -0
- package/src/array/index.mts +1 -1
- package/src/collections/imap-mapped.mts +99 -265
- package/src/collections/imap.mts +477 -174
- package/src/collections/imap.test.mts +12 -19
- package/src/collections/iset-mapped.mts +892 -358
- package/src/collections/iset.mts +429 -213
- package/src/collections/queue.mts +174 -200
- package/src/collections/stack.mts +172 -245
- package/src/collections/stack.test.mts +9 -1
- package/src/entry-point.mts +2 -0
- package/src/expect-type.mts +43 -172
- package/src/functional/match.mts +35 -145
- package/src/functional/optional.mts +285 -163
- package/src/functional/optional.test.mts +4 -1
- package/src/functional/pipe.mts +60 -113
- package/src/functional/result.mts +452 -351
- package/src/functional/result.test.mts +9 -2
- package/src/globals.d.mts +12 -5
- package/src/guard/has-key.mts +23 -74
- package/src/guard/is-non-empty-string.mts +20 -87
- package/src/guard/is-non-null-object.mts +14 -84
- package/src/guard/is-non-null-object.test.mts +1 -1
- package/src/guard/is-primitive.mts +13 -126
- package/src/guard/is-primitive.test.mts +1 -1
- package/src/guard/is-record.mts +21 -132
- package/src/guard/is-record.test.mts +0 -1
- package/src/guard/is-type.mts +201 -238
- package/src/guard/is-type.test.mts +7 -7
- package/src/guard/key-is-in.mts +22 -139
- package/src/index.mts +0 -1
- package/src/iterator/range.mts +29 -62
- package/src/json/json.mts +202 -134
- package/src/json/json.test.mts +1 -3
- package/src/number/branded-types/finite-number.mts +27 -159
- package/src/number/branded-types/int.mts +122 -120
- package/src/number/branded-types/int16.mts +22 -30
- package/src/number/branded-types/int16.test.mts +24 -24
- package/src/number/branded-types/int32.mts +22 -31
- package/src/number/branded-types/int32.test.mts +39 -39
- package/src/number/branded-types/non-negative-finite-number.mts +31 -39
- package/src/number/branded-types/non-negative-int16.mts +24 -34
- package/src/number/branded-types/non-negative-int16.test.mts +16 -16
- package/src/number/branded-types/non-negative-int32.mts +26 -35
- package/src/number/branded-types/non-negative-int32.test.mts +30 -30
- package/src/number/branded-types/non-zero-finite-number.mts +25 -40
- package/src/number/branded-types/non-zero-int.mts +15 -30
- package/src/number/branded-types/non-zero-int16.mts +27 -35
- package/src/number/branded-types/non-zero-int16.test.mts +26 -26
- package/src/number/branded-types/non-zero-int32.mts +29 -36
- package/src/number/branded-types/non-zero-int32.test.mts +45 -42
- package/src/number/branded-types/non-zero-safe-int.mts +39 -40
- package/src/number/branded-types/non-zero-uint16.mts +24 -35
- package/src/number/branded-types/non-zero-uint16.test.mts +16 -16
- package/src/number/branded-types/non-zero-uint32.mts +24 -35
- package/src/number/branded-types/non-zero-uint32.test.mts +28 -28
- package/src/number/branded-types/positive-finite-number.mts +29 -43
- package/src/number/branded-types/positive-int.mts +134 -124
- package/src/number/branded-types/positive-int16.mts +24 -35
- package/src/number/branded-types/positive-int16.test.mts +14 -14
- package/src/number/branded-types/positive-int32.mts +24 -35
- package/src/number/branded-types/positive-int32.test.mts +26 -26
- package/src/number/branded-types/positive-safe-int.mts +160 -34
- package/src/number/branded-types/positive-uint16.mts +24 -35
- package/src/number/branded-types/positive-uint16.test.mts +16 -16
- package/src/number/branded-types/positive-uint32.mts +26 -36
- package/src/number/branded-types/positive-uint32.test.mts +31 -28
- package/src/number/branded-types/safe-int.mts +142 -101
- package/src/number/branded-types/safe-uint.mts +25 -34
- package/src/number/branded-types/uint.mts +121 -30
- package/src/number/branded-types/uint16.mts +26 -34
- package/src/number/branded-types/uint16.test.mts +16 -16
- package/src/number/branded-types/uint32.mts +26 -68
- package/src/number/branded-types/uint32.test.mts +28 -28
- package/src/number/enum/int8.mts +39 -170
- package/src/number/enum/uint8.mts +46 -155
- package/src/number/num.mts +157 -212
- package/src/number/num.test.mts +4 -4
- package/src/number/refined-number-utils.mts +109 -26
- package/src/object/object.mts +130 -212
- package/src/object/object.test.mts +29 -0
- package/src/others/cast-mutable.mts +13 -89
- package/src/others/cast-mutable.test.mts +80 -0
- package/src/others/cast-readonly.mts +13 -169
- package/src/others/if-then.mts +6 -83
- package/src/others/map-nullable.mts +12 -136
- package/src/others/map-nullable.test.mts +6 -6
- package/src/others/memoize-function.mts +14 -157
- package/src/others/tuple.mts +33 -151
- package/src/others/unknown-to-string.mts +15 -127
- package/src/others/unknown-to-string.test.mts +14 -2
- package/src/promise/promise.mts +34 -21
- package/src/promise/promise.test.mts +43 -0
- package/dist/array/array-utils.d.mts +0 -2956
- package/dist/array/array-utils.d.mts.map +0 -1
- package/dist/array/array-utils.mjs +0 -1838
- package/dist/array/array-utils.mjs.map +0 -1
- package/src/array/array-utils-search.test.mts +0 -169
- package/src/array/array-utils-slicing.test.mts +0 -274
- package/src/array/array-utils.mts +0 -4834
|
@@ -33,12 +33,13 @@ import '../number/num.mjs';
|
|
|
33
33
|
import '../number/refined-number-utils.mjs';
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
|
-
* Class implementation for a stack with LIFO (Last-In, First-Out) behavior
|
|
37
|
-
* This implementation provides O(1) amortized push and
|
|
38
|
-
* that grows as needed.
|
|
36
|
+
* Class implementation for a stack with LIFO (Last-In, First-Out) behavior
|
|
37
|
+
* using a dynamic array. This implementation provides O(1) amortized push and
|
|
38
|
+
* O(1) pop operations by using a resizable buffer that grows as needed.
|
|
39
39
|
*
|
|
40
|
-
* The underlying array automatically resizes when it becomes full, ensuring
|
|
41
|
-
* can grow to accommodate any number of elements while
|
|
40
|
+
* The underlying array automatically resizes when it becomes full, ensuring
|
|
41
|
+
* that the stack can grow to accommodate any number of elements while
|
|
42
|
+
* maintaining efficient operations.
|
|
42
43
|
*
|
|
43
44
|
* @template T The type of elements in the stack.
|
|
44
45
|
* @implements Stack
|
|
@@ -54,6 +55,7 @@ class StackClass {
|
|
|
54
55
|
static #INITIAL_CAPACITY = 8;
|
|
55
56
|
/**
|
|
56
57
|
* Constructs a new StackClass instance.
|
|
58
|
+
*
|
|
57
59
|
* @param initialValues Optional initial values to populate the stack.
|
|
58
60
|
*/
|
|
59
61
|
constructor(initialValues = []) {
|
|
@@ -77,50 +79,16 @@ class StackClass {
|
|
|
77
79
|
/**
|
|
78
80
|
* Removes and returns the element at the top of the stack (LIFO).
|
|
79
81
|
*
|
|
80
|
-
* This operation removes the element that was added most recently (last-in)
|
|
81
|
-
* If the stack is empty, returns `Optional.none`. The
|
|
82
|
-
* and does not require any array resizing
|
|
83
|
-
*
|
|
84
|
-
* **Time Complexity:** O(1) - constant time operation
|
|
85
|
-
* **Space Complexity:** O(1) - no additional memory allocation
|
|
86
|
-
*
|
|
87
|
-
* @returns An Optional containing the removed element, or `Optional.none` if the stack is empty.
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* ```typescript
|
|
91
|
-
* const stack = createStack<string>();
|
|
92
|
-
*
|
|
93
|
-
* // Add some elements
|
|
94
|
-
* stack.push("bottom");
|
|
95
|
-
* stack.push("middle");
|
|
96
|
-
* stack.push("top");
|
|
82
|
+
* This operation removes the element that was added most recently (last-in)
|
|
83
|
+
* and returns it. If the stack is empty, returns `Optional.none`. The
|
|
84
|
+
* operation is guaranteed to be O(1) and does not require any array resizing
|
|
85
|
+
* or memory reallocation.
|
|
97
86
|
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
* if (top.isSome) {
|
|
101
|
-
* console.log(top.value); // "top" (last pushed, first popped)
|
|
102
|
-
* }
|
|
87
|
+
* **Time Complexity:** O(1) - constant time operation **Space Complexity:**
|
|
88
|
+
* O(1) - no additional memory allocation
|
|
103
89
|
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* // Safe handling of empty stack
|
|
108
|
-
* const emptyStack = createStack<number>();
|
|
109
|
-
* const result = emptyStack.pop();
|
|
110
|
-
* if (result.isNone) {
|
|
111
|
-
* console.log("Stack is empty");
|
|
112
|
-
* }
|
|
113
|
-
*
|
|
114
|
-
* // Typical usage in algorithms
|
|
115
|
-
* const pathStack = createStack<string>();
|
|
116
|
-
* pathStack.push("/home");
|
|
117
|
-
* pathStack.push("/users");
|
|
118
|
-
* pathStack.push("/documents");
|
|
119
|
-
*
|
|
120
|
-
* // Backtrack one level
|
|
121
|
-
* const currentDir = pathStack.pop().unwrap(); // "/documents"
|
|
122
|
-
* const parentDir = pathStack.pop().unwrap(); // "/users"
|
|
123
|
-
* ```
|
|
90
|
+
* @returns An Optional containing the removed element, or `Optional.none` if
|
|
91
|
+
* the stack is empty.
|
|
124
92
|
*/
|
|
125
93
|
pop() {
|
|
126
94
|
if (this.isEmpty) {
|
|
@@ -135,60 +103,19 @@ class StackClass {
|
|
|
135
103
|
/**
|
|
136
104
|
* Adds an element to the top of the stack (LIFO).
|
|
137
105
|
*
|
|
138
|
-
* This operation adds the element to the top of the stack, where it will be
|
|
139
|
-
* to be popped (last-in, first-out ordering). The operation is
|
|
140
|
-
* meaning it's O(1) for most operations with occasional O(n)
|
|
106
|
+
* This operation adds the element to the top of the stack, where it will be
|
|
107
|
+
* the first to be popped (last-in, first-out ordering). The operation is
|
|
108
|
+
* amortized O(1), meaning it's O(1) for most operations with occasional O(n)
|
|
109
|
+
* when the buffer needs resizing.
|
|
141
110
|
*
|
|
142
|
-
* **Time Complexity:** O(1) amortized - O(n) only when buffer resize is
|
|
143
|
-
* **Space Complexity:** O(1) - constant additional memory per element
|
|
111
|
+
* **Time Complexity:** O(1) amortized - O(n) only when buffer resize is
|
|
112
|
+
* needed **Space Complexity:** O(1) - constant additional memory per element
|
|
144
113
|
*
|
|
145
|
-
* **Buffer Resizing:** When the internal buffer becomes full, it
|
|
146
|
-
* in size and copies existing elements to maintain the
|
|
114
|
+
* **Buffer Resizing:** When the internal buffer becomes full, it
|
|
115
|
+
* automatically doubles in size and copies existing elements to maintain the
|
|
116
|
+
* stack structure.
|
|
147
117
|
*
|
|
148
118
|
* @param value The element to add to the top of the stack.
|
|
149
|
-
*
|
|
150
|
-
* @example
|
|
151
|
-
* ```typescript
|
|
152
|
-
* const actionStack = createStack<string>();
|
|
153
|
-
*
|
|
154
|
-
* // Add actions in chronological order
|
|
155
|
-
* actionStack.push("open file"); // O(1)
|
|
156
|
-
* actionStack.push("edit content"); // O(1)
|
|
157
|
-
* actionStack.push("save file"); // O(1)
|
|
158
|
-
*
|
|
159
|
-
* console.log(actionStack.size); // 3
|
|
160
|
-
*
|
|
161
|
-
* // Actions will be undone in reverse order (LIFO)
|
|
162
|
-
* while (!actionStack.isEmpty) {
|
|
163
|
-
* const action = actionStack.pop().unwrap();
|
|
164
|
-
* console.log(`Undoing: ${action}`);
|
|
165
|
-
* }
|
|
166
|
-
* // Output:
|
|
167
|
-
* // Undoing: save file
|
|
168
|
-
* // Undoing: edit content
|
|
169
|
-
* // Undoing: open file
|
|
170
|
-
*
|
|
171
|
-
* // High-volume pushing (demonstrates amortized O(1) performance)
|
|
172
|
-
* const dataStack = createStack<number>();
|
|
173
|
-
*
|
|
174
|
-
* for (const i of range(1000000)) {
|
|
175
|
-
* dataStack.push(i); // Each operation is O(1) amortized
|
|
176
|
-
* }
|
|
177
|
-
*
|
|
178
|
-
* console.log(dataStack.size); // 1000000
|
|
179
|
-
*
|
|
180
|
-
* // Function call stack simulation
|
|
181
|
-
* type StackFrame = { function: string; variables: Record<string, any> };
|
|
182
|
-
* const callStack = createStack<StackFrame>();
|
|
183
|
-
*
|
|
184
|
-
* callStack.push({ function: "main", variables: { argc: 1, argv: ["program"] } });
|
|
185
|
-
* callStack.push({ function: "process", variables: { data: [1, 2, 3] } });
|
|
186
|
-
* callStack.push({ function: "validate", variables: { input: "test" } });
|
|
187
|
-
*
|
|
188
|
-
* // Current function context is at the top
|
|
189
|
-
* const currentFrame = callStack.pop().unwrap();
|
|
190
|
-
* console.log(`Current function: ${currentFrame.function}`);
|
|
191
|
-
* ```
|
|
192
119
|
*/
|
|
193
120
|
push(value) {
|
|
194
121
|
// Resize if buffer is full
|
|
@@ -215,13 +142,16 @@ class StackClass {
|
|
|
215
142
|
}
|
|
216
143
|
}
|
|
217
144
|
/**
|
|
218
|
-
* Creates a new Stack instance with LIFO (Last-In, First-Out) behavior using a
|
|
145
|
+
* Creates a new Stack instance with LIFO (Last-In, First-Out) behavior using a
|
|
146
|
+
* high-performance dynamic array.
|
|
219
147
|
*
|
|
220
|
-
* This factory function creates an optimized stack implementation that
|
|
221
|
-
* characteristics for both push and pop
|
|
222
|
-
*
|
|
148
|
+
* This factory function creates an optimized stack implementation that
|
|
149
|
+
* maintains excellent performance characteristics for both push and pop
|
|
150
|
+
* operations. The underlying dynamic array automatically resizes to accommodate
|
|
151
|
+
* growing workloads while providing predictable O(1) operations.
|
|
223
152
|
*
|
|
224
153
|
* **Implementation Features:**
|
|
154
|
+
*
|
|
225
155
|
* - **O(1) push operations** (amortized - occasionally O(n) when resizing)
|
|
226
156
|
* - **O(1) pop operations** (always)
|
|
227
157
|
* - **Automatic buffer resizing** - starts at 8 elements, doubles when full
|
|
@@ -229,121 +159,42 @@ class StackClass {
|
|
|
229
159
|
* - **Dynamic array design** - eliminates need for complex memory management
|
|
230
160
|
*
|
|
231
161
|
* **Performance Benefits:**
|
|
162
|
+
*
|
|
232
163
|
* - No array shifting required for stack operations
|
|
233
164
|
* - Minimal memory allocation overhead
|
|
234
165
|
* - Predictable performance under high load
|
|
235
166
|
* - Efficient memory usage with automatic cleanup
|
|
236
167
|
*
|
|
237
|
-
* @template T The type of elements stored in the stack.
|
|
238
|
-
* @param initialValues Optional array of initial elements to populate the stack.
|
|
239
|
-
* Elements will be popped in reverse order of how they appear in the array
|
|
240
|
-
* (last array element will be popped first).
|
|
241
|
-
* If provided, the initial buffer capacity will be at least twice the array length.
|
|
242
|
-
* @returns A new Stack instance optimized for high-performance LIFO operations.
|
|
243
|
-
*
|
|
244
168
|
* @example
|
|
245
|
-
* ```typescript
|
|
246
|
-
* import { createStack } from './stack';
|
|
247
|
-
*
|
|
248
|
-
* // Example 1: Function call simulation
|
|
249
|
-
* type FunctionCall = { name: string; args: any[]; context: any };
|
|
250
|
-
* const callStack = createStack<FunctionCall>();
|
|
251
|
-
*
|
|
252
|
-
* // Simulate function calls (push onto stack)
|
|
253
|
-
* callStack.push({ name: "main", args: [], context: {} }); // O(1)
|
|
254
|
-
* callStack.push({ name: "processData", args: [data], context: {} }); // O(1)
|
|
255
|
-
* callStack.push({ name: "validateInput", args: [input], context: {} }); // O(1)
|
|
256
|
-
*
|
|
257
|
-
* // Simulate function returns (pop from stack)
|
|
258
|
-
* while (!callStack.isEmpty) {
|
|
259
|
-
* const call = callStack.pop().unwrap(); // O(1)
|
|
260
|
-
* console.log(`Returning from: ${call.name}`);
|
|
261
|
-
* }
|
|
262
|
-
* // Output:
|
|
263
|
-
* // Returning from: validateInput
|
|
264
|
-
* // Returning from: processData
|
|
265
|
-
* // Returning from: main
|
|
266
|
-
*
|
|
267
|
-
* // Example 2: Expression evaluation with operator precedence
|
|
268
|
-
* const operatorStack = createStack<string>();
|
|
269
|
-
* const operandStack = createStack<number>();
|
|
270
|
-
*
|
|
271
|
-
* // Simulate parsing "3 + 4 * 2"
|
|
272
|
-
* operandStack.push(3);
|
|
273
|
-
* operatorStack.push("+");
|
|
274
|
-
* operandStack.push(4);
|
|
275
|
-
* operatorStack.push("*"); // Higher precedence
|
|
276
|
-
* operandStack.push(2);
|
|
277
169
|
*
|
|
278
|
-
*
|
|
279
|
-
* const
|
|
280
|
-
* const b = operandStack.pop().unwrap(); // 2
|
|
281
|
-
* const a = operandStack.pop().unwrap(); // 4
|
|
282
|
-
* operandStack.push(a * b); // Push result: 8
|
|
170
|
+
* ```ts
|
|
171
|
+
* const stack = createStack<string>();
|
|
283
172
|
*
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
* type: 'insert' | 'delete' | 'modify';
|
|
287
|
-
* position: number;
|
|
288
|
-
* oldValue: string;
|
|
289
|
-
* newValue: string;
|
|
290
|
-
* };
|
|
173
|
+
* assert.ok(stack.isEmpty);
|
|
174
|
+
* assert(stack.size === 0);
|
|
291
175
|
*
|
|
292
|
-
*
|
|
293
|
-
*
|
|
176
|
+
* stack.push('first');
|
|
177
|
+
* // eslint-disable-next-line unicorn/prefer-single-call
|
|
178
|
+
* stack.push('second');
|
|
294
179
|
*
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
*
|
|
180
|
+
* assert.notOk(stack.isEmpty);
|
|
181
|
+
* assert(stack.size === 2);
|
|
182
|
+
* assert.deepStrictEqual(stack.pop(), Optional.some('second'));
|
|
183
|
+
* assert.deepStrictEqual(stack.pop(), Optional.some('first'));
|
|
184
|
+
* assert.deepStrictEqual(stack.pop(), Optional.none);
|
|
298
185
|
*
|
|
299
|
-
*
|
|
300
|
-
* undoStack.push(edit2);
|
|
186
|
+
* const seededStack = createStack([10, 20, 30]);
|
|
301
187
|
*
|
|
302
|
-
*
|
|
303
|
-
*
|
|
304
|
-
* const lastEdit = undoStack.pop().unwrap();
|
|
305
|
-
* redoStack.push(lastEdit);
|
|
306
|
-
* console.log(`Undid: ${lastEdit.type} at position ${lastEdit.position}`);
|
|
307
|
-
* }
|
|
308
|
-
*
|
|
309
|
-
* // Example 4: High-throughput data processing
|
|
310
|
-
* const processingStack = createStack<number>();
|
|
311
|
-
*
|
|
312
|
-
* // Add large amount of data (demonstrates amortized O(1) performance)
|
|
313
|
-
* for (const i of range(100000)) {
|
|
314
|
-
* processingStack.push(i); // Each push is O(1) amortized
|
|
315
|
-
* }
|
|
316
|
-
*
|
|
317
|
-
* // Process data in LIFO order
|
|
318
|
-
* let processedCount = 0;
|
|
319
|
-
* while (!processingStack.isEmpty) {
|
|
320
|
-
* const value = processingStack.pop().unwrap(); // O(1)
|
|
321
|
-
* // Process value...
|
|
322
|
-
* processedCount++;
|
|
323
|
-
* }
|
|
324
|
-
* console.log(`Processed ${processedCount} items`); // 100000
|
|
325
|
-
*
|
|
326
|
-
* // Example 5: Stack with pre-populated data
|
|
327
|
-
* const historyStack = createStack<string>([
|
|
328
|
-
* "page1.html",
|
|
329
|
-
* "page2.html",
|
|
330
|
-
* "page3.html",
|
|
331
|
-
* "page4.html"
|
|
332
|
-
* ]);
|
|
333
|
-
*
|
|
334
|
-
* console.log(historyStack.size); // Output: 4
|
|
335
|
-
*
|
|
336
|
-
* // Navigate back through history (LIFO order)
|
|
337
|
-
* while (!historyStack.isEmpty) {
|
|
338
|
-
* const page = historyStack.pop().unwrap();
|
|
339
|
-
* console.log(`Going back to: ${page}`);
|
|
340
|
-
* }
|
|
341
|
-
* // Output:
|
|
342
|
-
* // Going back to: page4.html (last added, first removed)
|
|
343
|
-
* // Going back to: page3.html
|
|
344
|
-
* // Going back to: page2.html
|
|
345
|
-
* // Going back to: page1.html
|
|
188
|
+
* assert(seededStack.size === 3);
|
|
189
|
+
* assert.deepStrictEqual(seededStack.pop(), Optional.some(30));
|
|
346
190
|
* ```
|
|
191
|
+
*
|
|
192
|
+
* @template T The type of elements stored in the stack.
|
|
193
|
+
* @param initialValues Optional array of initial elements to populate the
|
|
194
|
+
* stack. Elements will be popped in reverse order of how they appear in the
|
|
195
|
+
* array (last array element will be popped first). If provided, the initial
|
|
196
|
+
* buffer capacity will be at least twice the array length.
|
|
197
|
+
* @returns A new Stack instance optimized for high-performance LIFO operations.
|
|
347
198
|
*/
|
|
348
199
|
const createStack = (initialValues) => new StackClass(initialValues);
|
|
349
200
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stack.mjs","sources":["../../src/collections/stack.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"stack.mjs","sources":["../../src/collections/stack.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgKA;;;;;;;;;;;AAWG;AACH,MAAM,UAAU,CAAA;;AAEd,IAAA,OAAO;;AAGP,IAAA,SAAS;;AAGT,IAAA,SAAS;;AAGT,IAAA,OAAgB,iBAAiB,GAAG,CAAC;AAErC;;;;AAIG;AACH,IAAA,WAAA,CAAY,gBAA8B,EAAE,EAAA;AAC1C,QAAA,MAAM,eAAe,GAAG,QAAQ,CAC9B,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,iBAAiB,EAAE,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC,CACjE;AAED,QAAA,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,IAAI,CACvB,EAAE,MAAM,EAAE,eAAe,EAAE,EAC3B,MAAM,SAAS,CAChB;AACD,QAAA,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAC;AAC5B,QAAA,IAAI,CAAC,SAAS,GAAG,eAAe;;AAGhC,QAAA,KAAK,MAAM,KAAK,IAAI,aAAa,EAAE;AACjC,YAAA,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;QAClB;IACF;;AAGA,IAAA,IAAI,OAAO,GAAA;AACT,QAAA,OAAO,IAAI,CAAC,SAAS,KAAK,CAAC;IAC7B;;AAGA,IAAA,IAAI,IAAI,GAAA;AACN,QAAA,OAAO,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC;IACjC;AAEA;;;;;;;;;;;;;AAaG;IACH,GAAG,GAAA;AACD,QAAA,IAAI,IAAI,CAAC,OAAO,EAAE;YAChB,OAAO,QAAQ,CAAC,IAAI;QACtB;AAEA,QAAA,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;;QAE9C,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAE;QAC7C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;AAEzC,QAAA,OAAO,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC;IAC/B;AAEA;;;;;;;;;;;;;;;;AAgBG;AACH,IAAA,IAAI,CAAC,KAAQ,EAAA;;QAEX,IAAI,IAAI,CAAC,SAAS,KAAK,IAAI,CAAC,SAAS,EAAE;YACrC,IAAI,CAAC,OAAO,EAAE;QAChB;QAEA,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,KAAK;AACpC,QAAA,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC;IAChD;AAEA;;;;AAIG;IACH,OAAO,GAAA;QACL,MAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,GAAG,CAAC,CAAC;AAChD,QAAA,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAC1B,EAAE,MAAM,EAAE,WAAW,EAAE,EACvB,MAAM,SAAS,CAChB;;QAGD,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE;YACrC,SAAS,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;QAChC;AAEA,QAAA,IAAI,CAAC,OAAO,GAAG,SAAS;AACxB,QAAA,IAAI,CAAC,SAAS,GAAG,WAAW;IAC9B;;AAGF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsDG;AACI,MAAM,WAAW,GAAG,CAAK,aAA4B,KAC1D,IAAI,UAAU,CAAI,aAAa;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry-point.d.mts","sourceRoot":"","sources":["../src/entry-point.mts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as index from './array/impl/index.mjs';
|
|
2
|
+
export { index as Arr };
|
|
3
|
+
export { IMapMapped } from './collections/imap-mapped.mjs';
|
|
4
|
+
export { IMap } from './collections/imap.mjs';
|
|
5
|
+
export { ISetMapped } from './collections/iset-mapped.mjs';
|
|
6
|
+
export { ISet } from './collections/iset.mjs';
|
|
7
|
+
export { createQueue } from './collections/queue.mjs';
|
|
8
|
+
export { createStack } from './collections/stack.mjs';
|
|
9
|
+
export { expectType } from './expect-type.mjs';
|
|
10
|
+
export { match } from './functional/match.mjs';
|
|
11
|
+
export { Optional } from './functional/optional.mjs';
|
|
12
|
+
export { pipe } from './functional/pipe.mjs';
|
|
13
|
+
export { Result } from './functional/result.mjs';
|
|
14
|
+
export { hasKey } from './guard/has-key.mjs';
|
|
15
|
+
export { isNonEmptyString } from './guard/is-non-empty-string.mjs';
|
|
16
|
+
export { isNonNullObject } from './guard/is-non-null-object.mjs';
|
|
17
|
+
export { isPrimitive } from './guard/is-primitive.mjs';
|
|
18
|
+
export { isRecord } from './guard/is-record.mjs';
|
|
19
|
+
export { isBigint, isBoolean, isNonNullish, isNotBigint, isNotBoolean, isNotNull, isNotNumber, isNotString, isNotSymbol, isNotUndefined, isNull, isNullish, isNumber, isString, isSymbol, isUndefined } from './guard/is-type.mjs';
|
|
20
|
+
export { keyIsIn } from './guard/key-is-in.mjs';
|
|
21
|
+
export { range } from './iterator/range.mjs';
|
|
22
|
+
export { Json } from './json/json.mjs';
|
|
23
|
+
export { FiniteNumber, asFiniteNumber, isFiniteNumber } from './number/branded-types/finite-number.mjs';
|
|
24
|
+
export { Int, asInt, isInt } from './number/branded-types/int.mjs';
|
|
25
|
+
export { Int16, asInt16, isInt16 } from './number/branded-types/int16.mjs';
|
|
26
|
+
export { Int32, asInt32, isInt32 } from './number/branded-types/int32.mjs';
|
|
27
|
+
export { NonNegativeFiniteNumber, asNonNegativeFiniteNumber, isNonNegativeFiniteNumber } from './number/branded-types/non-negative-finite-number.mjs';
|
|
28
|
+
export { NonNegativeInt16, asNonNegativeInt16, isNonNegativeInt16 } from './number/branded-types/non-negative-int16.mjs';
|
|
29
|
+
export { NonNegativeInt32, asNonNegativeInt32, isNonNegativeInt32 } from './number/branded-types/non-negative-int32.mjs';
|
|
30
|
+
export { NonZeroFiniteNumber, asNonZeroFiniteNumber, isNonZeroFiniteNumber } from './number/branded-types/non-zero-finite-number.mjs';
|
|
31
|
+
export { NonZeroInt, asNonZeroInt, isNonZeroInt } from './number/branded-types/non-zero-int.mjs';
|
|
32
|
+
export { NonZeroInt16, asNonZeroInt16, isNonZeroInt16 } from './number/branded-types/non-zero-int16.mjs';
|
|
33
|
+
export { NonZeroInt32, asNonZeroInt32, isNonZeroInt32 } from './number/branded-types/non-zero-int32.mjs';
|
|
34
|
+
export { NonZeroSafeInt, asNonZeroSafeInt, isNonZeroSafeInt } from './number/branded-types/non-zero-safe-int.mjs';
|
|
35
|
+
export { NonZeroUint16, asNonZeroUint16, isNonZeroUint16 } from './number/branded-types/non-zero-uint16.mjs';
|
|
36
|
+
export { NonZeroUint32, asNonZeroUint32, isNonZeroUint32 } from './number/branded-types/non-zero-uint32.mjs';
|
|
37
|
+
export { PositiveFiniteNumber, asPositiveFiniteNumber, isPositiveFiniteNumber } from './number/branded-types/positive-finite-number.mjs';
|
|
38
|
+
export { PositiveInt, asPositiveInt, isPositiveInt } from './number/branded-types/positive-int.mjs';
|
|
39
|
+
export { PositiveInt16, asPositiveInt16, isPositiveInt16 } from './number/branded-types/positive-int16.mjs';
|
|
40
|
+
export { PositiveInt32, asPositiveInt32, isPositiveInt32 } from './number/branded-types/positive-int32.mjs';
|
|
41
|
+
export { PositiveSafeInt, asPositiveSafeInt, isPositiveSafeInt } from './number/branded-types/positive-safe-int.mjs';
|
|
42
|
+
export { PositiveUint16, asPositiveUint16, isPositiveUint16 } from './number/branded-types/positive-uint16.mjs';
|
|
43
|
+
export { PositiveUint32, asPositiveUint32, isPositiveUint32 } from './number/branded-types/positive-uint32.mjs';
|
|
44
|
+
export { SafeInt, asSafeInt, isSafeInt } from './number/branded-types/safe-int.mjs';
|
|
45
|
+
export { SafeUint, asSafeUint, isSafeUint } from './number/branded-types/safe-uint.mjs';
|
|
46
|
+
export { Uint, asUint, isUint } from './number/branded-types/uint.mjs';
|
|
47
|
+
export { Uint16, asUint16, isUint16 } from './number/branded-types/uint16.mjs';
|
|
48
|
+
export { Uint32, asUint32, isUint32 } from './number/branded-types/uint32.mjs';
|
|
49
|
+
export { Int8, asInt8, isInt8 } from './number/enum/int8.mjs';
|
|
50
|
+
export { Uint8, asUint8, isUint8 } from './number/enum/uint8.mjs';
|
|
51
|
+
export { Num } from './number/num.mjs';
|
|
52
|
+
export { TsDataForgeInternals } from './number/refined-number-utils.mjs';
|
|
53
|
+
export { Obj } from './object/object.mjs';
|
|
54
|
+
export { castDeepMutable, castMutable } from './others/cast-mutable.mjs';
|
|
55
|
+
export { castDeepReadonly, castReadonly } from './others/cast-readonly.mjs';
|
|
56
|
+
export { ifThen } from './others/if-then.mjs';
|
|
57
|
+
export { mapNullable } from './others/map-nullable.mjs';
|
|
58
|
+
export { memoizeFunction } from './others/memoize-function.mjs';
|
|
59
|
+
export { tp } from './others/tuple.mjs';
|
|
60
|
+
export { unknownToString } from './others/unknown-to-string.mjs';
|
|
61
|
+
export { createPromise } from './promise/promise.mjs';
|
|
62
|
+
//# sourceMappingURL=entry-point.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry-point.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/expect-type.d.mts
CHANGED
|
@@ -1,199 +1,70 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Compile-time type assertion utility for TypeScript type testing.
|
|
3
3
|
*
|
|
4
|
-
* This function performs static type relationship checking at compile-time and
|
|
5
|
-
* It is primarily used in test files to verify that
|
|
6
|
-
*
|
|
4
|
+
* This function performs static type relationship checking at compile-time and
|
|
5
|
+
* has no runtime effect. It is primarily used in test files to verify that
|
|
6
|
+
* TypeScript's type inference and type relationships work as expected. The
|
|
7
|
+
* function will cause TypeScript compilation errors if the specified type
|
|
7
8
|
* relationship does not hold.
|
|
8
9
|
*
|
|
9
10
|
* ## Supported Type Relations
|
|
10
11
|
*
|
|
11
12
|
* ### Equality Relations
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
13
|
+
*
|
|
14
|
+
* - **`"="` (strict equality)**: Asserts that types `A` and `B` are exactly the
|
|
15
|
+
* same type. Uses TypeScript's internal type equality checking.
|
|
16
|
+
* - **`"!="` (strict inequality)**: Asserts that types `A` and `B` are not
|
|
17
|
+
* exactly the same type.
|
|
15
18
|
*
|
|
16
19
|
* ### Assignability Relations
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
20
|
+
*
|
|
21
|
+
* - **`"~="` (mutual assignability)**: Asserts that `A` extends `B` AND `B`
|
|
22
|
+
* extends `A`. Types are structurally equivalent and mutually assignable.
|
|
23
|
+
* - **`"<="` (subtype relation)**: Asserts that type `A` extends (is assignable
|
|
24
|
+
* to) type `B`. Type `A` is a subtype of `B`.
|
|
25
|
+
* - **`">="` (supertype relation)**: Asserts that type `B` extends (is assignable
|
|
26
|
+
* to) type `A`. Type `A` is a supertype of `B`.
|
|
23
27
|
*
|
|
24
28
|
* ### Negative Assignability Relations
|
|
29
|
+
*
|
|
25
30
|
* - **`"!<="` (not subtype)**: Asserts that type `A` does NOT extend type `B`.
|
|
26
31
|
* - **`"!>="` (not supertype)**: Asserts that type `B` does NOT extend type `A`.
|
|
27
32
|
*
|
|
28
33
|
* ## Type Parameter Constraints
|
|
29
34
|
*
|
|
30
|
-
* @
|
|
35
|
+
* @since 1.0.0
|
|
36
|
+
* @template A - The first type for comparison. Can be any TypeScript type
|
|
37
|
+
* including:
|
|
38
|
+
*
|
|
31
39
|
* - Primitive types (string, number, boolean, etc.)
|
|
32
40
|
* - Object types and interfaces
|
|
33
41
|
* - Union and intersection types
|
|
34
42
|
* - Generic types and type parameters
|
|
35
43
|
* - Literal types and branded types
|
|
36
44
|
* - Function types and return types
|
|
37
|
-
* @template B - The second type for comparison. Same constraints as type `A`.
|
|
38
|
-
*
|
|
39
|
-
* @param _relation - A string literal representing the expected type relationship.
|
|
40
|
-
* TypeScript's type system automatically infers and restricts the available operators
|
|
41
|
-
* based on the actual relationship between types `A` and `B`. If an invalid relationship
|
|
42
|
-
* is specified, TypeScript will show a compilation error.
|
|
43
|
-
*
|
|
44
|
-
* ## Usage Patterns
|
|
45
|
-
*
|
|
46
|
-
* ### Basic Type Testing
|
|
47
|
-
* @example
|
|
48
|
-
* ```typescript
|
|
49
|
-
* import { expectType } from './expect-type.mjs';
|
|
50
|
-
*
|
|
51
|
-
* // Primitive type equality
|
|
52
|
-
* expectType<string, string>("="); // ✓ exact match
|
|
53
|
-
* expectType<number, string>("!="); // ✓ different types
|
|
54
|
-
* expectType<42, number>("<="); // ✓ literal extends primitive
|
|
55
|
-
* expectType<number, 42>(">="); // ✓ primitive is supertype
|
|
56
|
-
*
|
|
57
|
-
* // Type assertions will cause compilation errors for wrong relationships:
|
|
58
|
-
* // expectType<string, number>("="); // ❌ TypeScript error
|
|
59
|
-
* // expectType<number, string>("<="); // ❌ TypeScript error
|
|
60
|
-
* ```
|
|
61
|
-
*
|
|
62
|
-
* ### Array and Tuple Type Validation
|
|
63
|
-
* @example
|
|
64
|
-
* ```typescript
|
|
65
|
-
* // Testing array utility function return types
|
|
66
|
-
* const zeros = Arr.zeros(3);
|
|
67
|
-
* expectType<typeof zeros, readonly [0, 0, 0]>("=");
|
|
68
|
-
*
|
|
69
|
-
* const sequence = Arr.seq(5);
|
|
70
|
-
* expectType<typeof sequence, readonly [0, 1, 2, 3, 4]>("=");
|
|
71
|
-
*
|
|
72
|
-
* // Dynamic length arrays
|
|
73
|
-
* const dynamicArray = Arr.zeros(someLength);
|
|
74
|
-
* expectType<typeof dynamicArray, readonly 0[]>("=");
|
|
75
|
-
* ```
|
|
76
|
-
*
|
|
77
|
-
* ### Function Return Type Testing
|
|
78
|
-
* @example
|
|
79
|
-
* ```typescript
|
|
80
|
-
* // Testing function return types
|
|
81
|
-
* const createUser = () => ({ id: 1, name: 'John' });
|
|
82
|
-
* expectType<ReturnType<typeof createUser>, { id: number; name: string }>("~=");
|
|
83
|
-
*
|
|
84
|
-
* // Generic function type inference
|
|
85
|
-
* const identity = <T>(x: T): T => x;
|
|
86
|
-
* const result = identity('hello');
|
|
87
|
-
* expectType<typeof result, string>("=");
|
|
88
|
-
* ```
|
|
89
|
-
*
|
|
90
|
-
* ### Union and Intersection Types
|
|
91
|
-
* @example
|
|
92
|
-
* ```typescript
|
|
93
|
-
* // Union type relationships
|
|
94
|
-
* expectType<string, string | number>("<="); // string extends union
|
|
95
|
-
* expectType<string | number, string>(">="); // union contains string
|
|
96
|
-
* expectType<string | number, number>(">="); // union contains number
|
|
97
|
-
*
|
|
98
|
-
* // Intersection type relationships
|
|
99
|
-
* type A = { a: number };
|
|
100
|
-
* type B = { b: string };
|
|
101
|
-
* expectType<A & B, A>(">="); // intersection extends component
|
|
102
|
-
* expectType<A, A & B>("<="); // component extends intersection
|
|
103
|
-
* ```
|
|
104
45
|
*
|
|
105
|
-
*
|
|
106
|
-
* @
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
125
|
-
*
|
|
126
|
-
*
|
|
127
|
-
* if (Optional.isNone(optional)) {
|
|
128
|
-
* expectType<typeof optional, Optional.None>("<=");
|
|
129
|
-
* }
|
|
130
|
-
*
|
|
131
|
-
* // Result type validation
|
|
132
|
-
* const result: Result<string, Error> = Result.ok('success');
|
|
133
|
-
* expectType<typeof result, Result<string, Error>>("<=");
|
|
134
|
-
* ```
|
|
135
|
-
*
|
|
136
|
-
* ### Type Guard and Validation Testing
|
|
137
|
-
* @example
|
|
138
|
-
* ```typescript
|
|
139
|
-
* // Testing type guard functions
|
|
140
|
-
* if (isRecord(value)) {
|
|
141
|
-
* expectType<typeof value, UnknownRecord>("<=");
|
|
142
|
-
* }
|
|
143
|
-
*
|
|
144
|
-
* // Testing compile-time type predicates
|
|
145
|
-
* const obj = { key: 'value' };
|
|
146
|
-
* if (hasKey(obj, 'key')) {
|
|
147
|
-
* expectType<typeof obj.key, unknown>("<=");
|
|
148
|
-
* }
|
|
149
|
-
* ```
|
|
150
|
-
*
|
|
151
|
-
* ## Common Testing Patterns
|
|
152
|
-
*
|
|
153
|
-
* ### Dual Testing Strategy
|
|
154
|
-
* Combine `expectType` with runtime assertions for comprehensive testing:
|
|
155
|
-
*
|
|
156
|
-
* @example
|
|
157
|
-
* ```typescript
|
|
158
|
-
* describe('Arr.zeros', () => {
|
|
159
|
-
* test('should create array of zeros with correct type', () => {
|
|
160
|
-
* const result = Arr.zeros(3);
|
|
161
|
-
*
|
|
162
|
-
* // Compile-time type assertion
|
|
163
|
-
* expectType<typeof result, readonly [0, 0, 0]>("=");
|
|
164
|
-
*
|
|
165
|
-
* // Runtime behavior assertion
|
|
166
|
-
* expect(result).toStrictEqual([0, 0, 0]);
|
|
167
|
-
* });
|
|
168
|
-
* });
|
|
169
|
-
* ```
|
|
170
|
-
*
|
|
171
|
-
* ### Type Relationship Validation
|
|
172
|
-
* Test complex type hierarchies and relationships:
|
|
173
|
-
*
|
|
174
|
-
* @example
|
|
175
|
-
* ```typescript
|
|
176
|
-
* // Ensure proper type hierarchy
|
|
177
|
-
* expectType<PositiveInt, Int>("<="); // positive is subset of int
|
|
178
|
-
* expectType<Int, FiniteNumber>("<="); // int is subset of finite
|
|
179
|
-
* expectType<FiniteNumber, number>("<="); // finite is subset of number
|
|
180
|
-
*
|
|
181
|
-
* // Verify mutual exclusion
|
|
182
|
-
* expectType<PositiveInt, NegativeInt>("!="); // different int types
|
|
183
|
-
* expectType<PositiveInt, NegativeInt>("!<="); // neither extends the other
|
|
184
|
-
* expectType<NegativeInt, PositiveInt>("!<=");
|
|
185
|
-
* ```
|
|
186
|
-
*
|
|
187
|
-
* ## Important Notes
|
|
188
|
-
*
|
|
189
|
-
* - **Compile-time only**: This function has no runtime behavior and will be optimized away.
|
|
190
|
-
* - **Type inference**: The available relation operators are automatically inferred by TypeScript
|
|
191
|
-
* based on the actual type relationship between `A` and `B`.
|
|
192
|
-
* - **Error feedback**: Invalid type relationships will cause clear TypeScript compilation errors.
|
|
193
|
-
* - **Test organization**: Typically used in `.test.mts` files alongside runtime assertions.
|
|
194
|
-
* - **Performance**: Has zero runtime overhead as it's purely a compile-time construct.
|
|
195
|
-
*
|
|
196
|
-
* @since 1.0.0
|
|
46
|
+
* @template B - The second type for comparison. Same constraints as type `A`.
|
|
47
|
+
* @param _relation - A string literal representing the expected type
|
|
48
|
+
* relationship. TypeScript's type system automatically infers and restricts
|
|
49
|
+
* the available operators based on the actual relationship between types `A`
|
|
50
|
+
* and `B`. If an invalid relationship is specified, TypeScript will show a
|
|
51
|
+
* compilation error.
|
|
52
|
+
*
|
|
53
|
+
* Combine `expectType` with runtime assertions for comprehensive testing:
|
|
54
|
+
*
|
|
55
|
+
* ## Important Notes
|
|
56
|
+
*
|
|
57
|
+
* - **Compile-time only**: This function has no runtime behavior and will be
|
|
58
|
+
* optimized away.
|
|
59
|
+
* - **Type inference**: The available relation operators are automatically
|
|
60
|
+
* inferred by TypeScript based on the actual type relationship between
|
|
61
|
+
* `A` and `B`.
|
|
62
|
+
* - **Error feedback**: Invalid type relationships will cause clear TypeScript
|
|
63
|
+
* compilation errors.
|
|
64
|
+
* - **Test organization**: Typically used in `.test.mts` files alongside runtime
|
|
65
|
+
* assertions.
|
|
66
|
+
* - **Performance**: Has zero runtime overhead as it's purely a compile-time
|
|
67
|
+
* construct.
|
|
197
68
|
*/
|
|
198
69
|
export declare const expectType: <A, B>(_relation: TypeEq<A, B> extends true ? "<=" | "=" | ">=" | "~=" : "!=" | (TypeExtends<A, B> extends true ? "<=" | (TypeExtends<B, A> extends true ? ">=" | "~=" : "!>=") : "!<=" | (TypeExtends<B, A> extends true ? ">=" : "!>="))) => void;
|
|
199
70
|
//# sourceMappingURL=expect-type.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"expect-type.d.mts","sourceRoot":"","sources":["../src/expect-type.mts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"expect-type.d.mts","sourceRoot":"","sources":["../src/expect-type.mts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,eAAO,MAAM,UAAU,GAAI,CAAC,EAAE,CAAC,EAC7B,WAAW,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,SAAS,IAAI,GAChC,IAAI,GAAG,GAAG,GAAG,IAAI,GAAG,IAAI,GAEpB,IAAI,GACJ,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,SAAS,IAAI,GAC3B,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC,GAC7D,KAAK,GAAG,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC,CAAC,KACnE,IAAiB,CAAC"}
|