ts-data-forge 6.13.1 → 7.0.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 +2 -2
- package/dist/array/impl/array-utils-creation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-creation.mjs +1 -1
- package/dist/array/impl/array-utils-creation.mjs.map +1 -1
- package/dist/array/impl/array-utils-iterators.mjs +7 -1
- package/dist/array/impl/array-utils-iterators.mjs.map +1 -1
- package/dist/array/impl/array-utils-modification.mjs +6 -0
- package/dist/array/impl/array-utils-modification.mjs.map +1 -1
- package/dist/array/impl/array-utils-reducing-value.d.mts +1 -1
- package/dist/array/impl/array-utils-reducing-value.d.mts.map +1 -1
- package/dist/array/impl/array-utils-reducing-value.mjs +6 -1
- package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
- package/dist/array/impl/array-utils-search.d.mts +0 -2
- package/dist/array/impl/array-utils-search.d.mts.map +1 -1
- package/dist/array/impl/array-utils-search.mjs +6 -0
- package/dist/array/impl/array-utils-search.mjs.map +1 -1
- package/dist/array/impl/array-utils-set-op.d.mts.map +1 -1
- package/dist/array/impl/array-utils-set-op.mjs +0 -1
- package/dist/array/impl/array-utils-set-op.mjs.map +1 -1
- package/dist/array/impl/array-utils-slice-clamped.mjs +6 -0
- package/dist/array/impl/array-utils-slice-clamped.mjs.map +1 -1
- package/dist/array/impl/array-utils-slicing.mjs +6 -0
- package/dist/array/impl/array-utils-slicing.mjs.map +1 -1
- package/dist/array/impl/array-utils-transformation.d.mts +1 -1
- package/dist/array/impl/array-utils-transformation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-transformation.mjs +8 -4
- package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
- package/dist/array/impl/array-utils-validation.d.mts.map +1 -1
- package/dist/array/impl/array-utils-validation.mjs +9 -9
- package/dist/array/impl/array-utils-validation.mjs.map +1 -1
- package/dist/collections/imap-mapped.d.mts +622 -3
- package/dist/collections/imap-mapped.d.mts.map +1 -1
- package/dist/collections/imap-mapped.mjs +117 -18
- package/dist/collections/imap-mapped.mjs.map +1 -1
- package/dist/collections/imap.d.mts +3 -3
- package/dist/collections/imap.d.mts.map +1 -1
- package/dist/collections/imap.mjs +12 -5
- package/dist/collections/imap.mjs.map +1 -1
- package/dist/collections/iset-mapped.d.mts +4 -4
- package/dist/collections/iset-mapped.d.mts.map +1 -1
- package/dist/collections/iset-mapped.mjs +14 -4
- package/dist/collections/iset-mapped.mjs.map +1 -1
- package/dist/collections/iset.d.mts +2 -2
- package/dist/collections/iset.d.mts.map +1 -1
- package/dist/collections/iset.mjs +11 -2
- package/dist/collections/iset.mjs.map +1 -1
- package/dist/collections/queue.mjs +26 -20
- package/dist/collections/queue.mjs.map +1 -1
- package/dist/collections/stack.mjs +23 -17
- package/dist/collections/stack.mjs.map +1 -1
- package/dist/entry-point.mjs +6 -0
- package/dist/entry-point.mjs.map +1 -1
- package/dist/functional/optional/impl/optional-flat-map.d.mts +2 -2
- package/dist/functional/pipe.d.mts.map +1 -1
- package/dist/functional/pipe.mjs.map +1 -1
- package/dist/functional/result/impl/result-flat-map.d.mts +2 -2
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.d.mts +5 -3
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.d.mts.map +1 -1
- package/dist/functional/ternary-result/impl/ternary-result-flat-map.mjs.map +1 -1
- package/dist/guard/has-key.d.mts.map +1 -1
- package/dist/guard/has-key.mjs +1 -3
- package/dist/guard/has-key.mjs.map +1 -1
- package/dist/guard/is-non-null-object.d.mts.map +1 -1
- package/dist/guard/is-non-null-object.mjs +1 -3
- package/dist/guard/is-non-null-object.mjs.map +1 -1
- package/dist/guard/key-is-in.d.mts.map +1 -1
- package/dist/guard/key-is-in.mjs +1 -3
- package/dist/guard/key-is-in.mjs.map +1 -1
- package/dist/index.mjs +6 -0
- package/dist/index.mjs.map +1 -1
- package/dist/iterator/range.mjs +6 -0
- package/dist/iterator/range.mjs.map +1 -1
- package/dist/json/json.mjs +11 -7
- package/dist/json/json.mjs.map +1 -1
- package/dist/number/branded-types/finite-number.d.mts +1 -1
- package/dist/number/branded-types/index.d.mts +6 -0
- package/dist/number/branded-types/index.d.mts.map +1 -1
- package/dist/number/branded-types/index.mjs +6 -0
- package/dist/number/branded-types/index.mjs.map +1 -1
- package/dist/number/branded-types/int.d.mts +1 -2
- package/dist/number/branded-types/int.d.mts.map +1 -1
- package/dist/number/branded-types/int16.d.mts +2 -3
- package/dist/number/branded-types/int16.d.mts.map +1 -1
- package/dist/number/branded-types/int32.d.mts +2 -3
- package/dist/number/branded-types/int32.d.mts.map +1 -1
- package/dist/number/branded-types/negative-finite-number.d.mts +143 -0
- package/dist/number/branded-types/negative-finite-number.d.mts.map +1 -0
- package/dist/number/branded-types/negative-finite-number.mjs +156 -0
- package/dist/number/branded-types/negative-finite-number.mjs.map +1 -0
- package/dist/number/branded-types/negative-int.d.mts +120 -0
- package/dist/number/branded-types/negative-int.d.mts.map +1 -0
- package/dist/number/branded-types/negative-int.mjs +125 -0
- package/dist/number/branded-types/negative-int.mjs.map +1 -0
- package/dist/number/branded-types/negative-safe-int.d.mts +132 -0
- package/dist/number/branded-types/negative-safe-int.d.mts.map +1 -0
- package/dist/number/branded-types/negative-safe-int.mjs +136 -0
- package/dist/number/branded-types/negative-safe-int.mjs.map +1 -0
- package/dist/number/branded-types/non-negative-finite-number.d.mts +1 -1
- package/dist/number/branded-types/non-negative-int16.d.mts +1 -1
- package/dist/number/branded-types/non-negative-int32.d.mts +1 -1
- package/dist/number/branded-types/non-positive-finite-number.d.mts +130 -0
- package/dist/number/branded-types/non-positive-finite-number.d.mts.map +1 -0
- package/dist/number/branded-types/non-positive-finite-number.mjs +134 -0
- package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -0
- package/dist/number/branded-types/non-positive-int.d.mts +224 -0
- package/dist/number/branded-types/non-positive-int.d.mts.map +1 -0
- package/dist/number/branded-types/non-positive-int.mjs +222 -0
- package/dist/number/branded-types/non-positive-int.mjs.map +1 -0
- package/dist/number/branded-types/non-positive-safe-int.d.mts +119 -0
- package/dist/number/branded-types/non-positive-safe-int.d.mts.map +1 -0
- package/dist/number/branded-types/non-positive-safe-int.mjs +116 -0
- package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -0
- package/dist/number/branded-types/non-zero-finite-number.d.mts +5 -17
- package/dist/number/branded-types/non-zero-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-finite-number.mjs +5 -17
- package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int.d.mts +5 -33
- package/dist/number/branded-types/non-zero-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-int.mjs +5 -25
- package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int16.d.mts +6 -43
- package/dist/number/branded-types/non-zero-int16.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-int16.mjs +5 -25
- package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int32.d.mts +6 -39
- package/dist/number/branded-types/non-zero-int32.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-int32.mjs +5 -25
- package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-safe-int.d.mts +5 -37
- package/dist/number/branded-types/non-zero-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-safe-int.mjs +7 -30
- package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint16.d.mts +6 -33
- package/dist/number/branded-types/non-zero-uint16.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-uint16.mjs +5 -17
- package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint32.d.mts +6 -31
- package/dist/number/branded-types/non-zero-uint32.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-uint32.mjs +5 -17
- package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
- package/dist/number/branded-types/positive-finite-number.d.mts +4 -2
- package/dist/number/branded-types/positive-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int.d.mts +4 -2
- package/dist/number/branded-types/positive-int.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int16.d.mts +4 -2
- package/dist/number/branded-types/positive-int16.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int32.d.mts +4 -2
- package/dist/number/branded-types/positive-int32.d.mts.map +1 -1
- package/dist/number/branded-types/positive-safe-int.d.mts +4 -2
- package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/positive-safe-int.mjs +1 -1
- package/dist/number/branded-types/positive-uint16.d.mts +4 -2
- package/dist/number/branded-types/positive-uint16.d.mts.map +1 -1
- package/dist/number/branded-types/positive-uint32.d.mts +4 -2
- package/dist/number/branded-types/positive-uint32.d.mts.map +1 -1
- package/dist/number/branded-types/safe-int.d.mts +1 -2
- package/dist/number/branded-types/safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/safe-int.mjs +2 -2
- package/dist/number/branded-types/safe-uint.d.mts +1 -1
- package/dist/number/branded-types/safe-uint.mjs +1 -1
- package/dist/number/branded-types/uint.d.mts +1 -1
- package/dist/number/branded-types/uint16.d.mts +1 -1
- package/dist/number/branded-types/uint32.d.mts +1 -1
- package/dist/number/index.d.mts +1 -0
- package/dist/number/index.d.mts.map +1 -1
- package/dist/number/index.mjs +6 -0
- package/dist/number/index.mjs.map +1 -1
- package/dist/number/num-arithmetic-types.d.mts +74 -0
- package/dist/number/num-arithmetic-types.d.mts.map +1 -0
- package/dist/number/num-arithmetic-types.mjs +2 -0
- package/dist/number/num-arithmetic-types.mjs.map +1 -0
- package/dist/number/num.d.mts +53 -9
- package/dist/number/num.d.mts.map +1 -1
- package/dist/number/num.mjs +67 -15
- package/dist/number/num.mjs.map +1 -1
- package/dist/number/refined-number-utils.d.mts +12 -9
- package/dist/number/refined-number-utils.d.mts.map +1 -1
- package/dist/number/refined-number-utils.mjs.map +1 -1
- package/dist/object/object.mjs +7 -1
- package/dist/object/object.mjs.map +1 -1
- package/dist/others/fast-deep-equal.d.mts.map +1 -1
- package/dist/others/fast-deep-equal.mjs +0 -1
- package/dist/others/fast-deep-equal.mjs.map +1 -1
- package/dist/others/unknown-to-string.mjs +2 -2
- package/dist/others/unknown-to-string.mjs.map +1 -1
- package/package.json +6 -6
- package/src/array/impl/array-utils-creation.mts +1 -1
- package/src/array/impl/array-utils-iterators.mts +1 -1
- package/src/array/impl/array-utils-reducing-value.mts +1 -2
- package/src/array/impl/array-utils-search.mts +0 -2
- package/src/array/impl/array-utils-set-op.mts +0 -1
- package/src/array/impl/array-utils-transformation.mts +8 -6
- package/src/array/impl/array-utils-validation.mts +1 -5
- package/src/collections/imap-mapped.mts +696 -34
- package/src/collections/imap-mapped.test.mts +61 -13
- package/src/collections/imap.mts +20 -9
- package/src/collections/imap.test.mts +9 -8
- package/src/collections/iset-mapped.mts +18 -10
- package/src/collections/iset-mapped.test.mts +6 -1
- package/src/collections/iset.mts +11 -4
- package/src/collections/iset.test.mts +6 -8
- package/src/collections/queue.mts +32 -32
- package/src/collections/stack.mts +26 -26
- package/src/functional/optional/impl/optional-flat-map.mts +2 -2
- package/src/functional/optional.test.mts +6 -4
- package/src/functional/pipe.mts +0 -1
- package/src/functional/pipe.test.mts +2 -1
- package/src/functional/result/impl/result-flat-map.mts +2 -2
- package/src/functional/result.test.mts +3 -2
- package/src/functional/ternary-result/impl/ternary-result-flat-map.mts +5 -3
- package/src/functional/ternary-result.test.mts +8 -3
- package/src/guard/has-key.mts +1 -3
- package/src/guard/is-non-null-object.mts +0 -1
- package/src/guard/key-is-in.mts +1 -3
- package/src/json/json.mts +5 -8
- package/src/json/json.test.mts +2 -2
- package/src/number/branded-types/index.mts +6 -0
- package/src/number/branded-types/negative-finite-number.mts +210 -0
- package/src/number/branded-types/negative-finite-number.test.mts +172 -0
- package/src/number/branded-types/negative-int.mts +160 -0
- package/src/number/branded-types/negative-int.test.mts +146 -0
- package/src/number/branded-types/negative-safe-int.mts +173 -0
- package/src/number/branded-types/negative-safe-int.test.mts +120 -0
- package/src/number/branded-types/non-positive-finite-number.mts +191 -0
- package/src/number/branded-types/non-positive-finite-number.test.mts +286 -0
- package/src/number/branded-types/non-positive-int.mts +251 -0
- package/src/number/branded-types/non-positive-int.test.mts +197 -0
- package/src/number/branded-types/non-positive-safe-int.mts +147 -0
- package/src/number/branded-types/non-positive-safe-int.test.mts +223 -0
- package/src/number/branded-types/non-zero-finite-number.mts +14 -22
- package/src/number/branded-types/non-zero-finite-number.test.mts +0 -12
- package/src/number/branded-types/non-zero-int.mts +10 -32
- package/src/number/branded-types/non-zero-int.test.mts +0 -20
- package/src/number/branded-types/non-zero-int16.mts +8 -32
- package/src/number/branded-types/non-zero-int16.test.mts +0 -30
- package/src/number/branded-types/non-zero-int32.mts +8 -32
- package/src/number/branded-types/non-zero-int32.test.mts +0 -30
- package/src/number/branded-types/non-zero-safe-int.mts +10 -37
- package/src/number/branded-types/non-zero-safe-int.test.mts +0 -32
- package/src/number/branded-types/non-zero-uint16.mts +8 -22
- package/src/number/branded-types/non-zero-uint16.test.mts +0 -16
- package/src/number/branded-types/non-zero-uint32.mts +8 -22
- package/src/number/branded-types/non-zero-uint32.test.mts +0 -16
- package/src/number/branded-types/positive-safe-int.mts +1 -1
- package/src/number/branded-types/safe-int.mts +2 -2
- package/src/number/branded-types/safe-uint.mts +1 -1
- package/src/number/index.mts +1 -0
- package/src/number/num-arithmetic-types.mts +265 -0
- package/src/number/num-arithmetic-types.test.mts +130 -0
- package/src/number/num-arithmetic.test.mts +102 -0
- package/src/number/num.mts +99 -18
- package/src/number/num.test.mts +2 -2
- package/src/number/refined-number-utils.mts +19 -9
- package/src/object/object.mts +2 -2
- package/src/others/fast-deep-equal.mts +0 -2
- package/src/others/map-nullable.test.mts +4 -3
- package/src/others/unknown-to-string.mts +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"int.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/int.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,IAAI,eAAe,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"int.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/int.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,IAAI,eAAe,EAAE,MAAM,eAAe,CAAC;AAI5D,MAAM,MAAM,GAAG,GAAG,eAAe,CAAC;AA6BlC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,KAAK,qCAAK,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,KAAK;;;;;;MAAW,CAAC;AAE9B;;;;;;;;;;GAUG;AACH,eAAO,MAAM,GAAG;IACd;;;;;;;;;;;;;;;;OAgBG;;IAGH;;;;;;;;;;;;;;;;;;;;;OAqBG;;IAGH;;;;;;;;;;;;;OAaG;;IAGH;;;;;;;;;;;;;OAaG;;IAGH;;;;;;;;;;;;;;;;;;;;;;;OAuBG;;IAGH;;;;;;;;;;;;;;;;;;OAkBG;;IAGH;;;;;;;;;;;;;;OAcG;;IAGH;;;;;;;;;;;;;;OAcG;;IAGH;;;;;;;;;;;;;;OAcG;;IAGH;;;;;;;;;;;;;;;;;;;;;OAqBG;;;;;;;;;CAEK,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type Int16 as TtfImported_Int16 } from 'ts-type-forge';
|
|
2
|
-
import { TsDataForgeInternals } from '../refined-number-utils.mjs';
|
|
3
2
|
export type Int16 = TtfImported_Int16;
|
|
4
3
|
/**
|
|
5
4
|
* Checks if a number is an Int16 (16-bit signed integer in the range [-2^15,
|
|
@@ -66,7 +65,7 @@ export declare const Int16: {
|
|
|
66
65
|
* @param a The Int16 value.
|
|
67
66
|
* @returns The absolute value as an Int16, clamped to valid range.
|
|
68
67
|
*/
|
|
69
|
-
readonly abs: (x: import("ts-type-forge").WithSmallInt<TtfImported_Int16>) =>
|
|
68
|
+
readonly abs: (x: import("ts-type-forge").WithSmallInt<TtfImported_Int16>) => import("ts-type-forge").IntersectBrand<TtfImported_Int16, import("ts-type-forge").NonNegativeNumber>;
|
|
70
69
|
/**
|
|
71
70
|
* Returns the smaller of two Int16 values.
|
|
72
71
|
*
|
|
@@ -139,11 +138,11 @@ export declare const Int16: {
|
|
|
139
138
|
readonly NaNValue: false;
|
|
140
139
|
readonly Finite: true;
|
|
141
140
|
readonly Int: true;
|
|
142
|
-
readonly "!=0": true;
|
|
143
141
|
readonly "> -2^16": true;
|
|
144
142
|
readonly "> -2^32": true;
|
|
145
143
|
readonly ">= -2^15": true;
|
|
146
144
|
readonly ">= -2^31": true;
|
|
145
|
+
readonly "!=0": true;
|
|
147
146
|
readonly "< 2^15": true;
|
|
148
147
|
readonly "< 2^16": true;
|
|
149
148
|
readonly "< 2^31": true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"int16.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/int16.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"int16.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/int16.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAIhE,MAAM,MAAM,KAAK,GAAG,iBAAiB,CAAC;AAgCtC;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,uCAAK,CAAC;AAE1B;;;;;;GAMG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;MAAW,CAAC;AAEhC;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK;IAChB;;;;;OAKG;;IAGH;;;;OAIG;;IAGH;;;;OAIG;;IAGH;;;;;OAKG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;IAGH;;;;;OAKG;;IAGH;;;;OAIG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;;;;;;;;;;;;;;;;;CAEK,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type Int32 as TtfImported_Int32 } from 'ts-type-forge';
|
|
2
|
-
import { TsDataForgeInternals } from '../refined-number-utils.mjs';
|
|
3
2
|
export type Int32 = TtfImported_Int32;
|
|
4
3
|
/**
|
|
5
4
|
* Checks if a number is an Int32 (32-bit signed integer in the range [-2^31,
|
|
@@ -62,7 +61,7 @@ export declare const Int32: {
|
|
|
62
61
|
* @param a The Int32 value.
|
|
63
62
|
* @returns The absolute value as an Int32, clamped to valid range.
|
|
64
63
|
*/
|
|
65
|
-
readonly abs: (x: import("ts-type-forge").WithSmallInt<TtfImported_Int32>) =>
|
|
64
|
+
readonly abs: (x: import("ts-type-forge").WithSmallInt<TtfImported_Int32>) => import("ts-type-forge").IntersectBrand<TtfImported_Int32, import("ts-type-forge").NonNegativeNumber>;
|
|
66
65
|
/**
|
|
67
66
|
* Returns the smaller of two Int32 values.
|
|
68
67
|
*
|
|
@@ -135,9 +134,9 @@ export declare const Int32: {
|
|
|
135
134
|
readonly NaNValue: false;
|
|
136
135
|
readonly Finite: true;
|
|
137
136
|
readonly Int: true;
|
|
138
|
-
readonly "!=0": true;
|
|
139
137
|
readonly "> -2^32": true;
|
|
140
138
|
readonly ">= -2^31": true;
|
|
139
|
+
readonly "!=0": true;
|
|
141
140
|
readonly "< 2^31": true;
|
|
142
141
|
readonly "< 2^32": true;
|
|
143
142
|
readonly SafeInt: true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"int32.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/int32.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"int32.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/int32.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,IAAI,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAIhE,MAAM,MAAM,KAAK,GAAG,iBAAiB,CAAC;AAgCtC;;;;;;GAMG;AACH,eAAO,MAAM,OAAO,uCAAK,CAAC;AAE1B;;;;;;GAMG;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;MAAW,CAAC;AAEhC;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK;IAChB;;;;;OAKG;;IAGH;;;;OAIG;;IAGH;;;;OAIG;;IAGH;;;;;OAKG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;IAGH;;;;;OAKG;;IAGH;;;;OAIG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;;;;;;;;;;;;;CAEK,CAAC"}
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { type NegativeFiniteNumber as TtfImported_NegativeFiniteNumber } from 'ts-type-forge';
|
|
2
|
+
import { TsDataForgeInternals } from '../refined-number-utils.mjs';
|
|
3
|
+
import { PositiveFiniteNumber } from './positive-finite-number.mjs';
|
|
4
|
+
export type NegativeFiniteNumber = TtfImported_NegativeFiniteNumber;
|
|
5
|
+
type ElementType = NegativeFiniteNumber;
|
|
6
|
+
/**
|
|
7
|
+
* Checks if a number is a NegativeFiniteNumber (a finite number `< 0`).
|
|
8
|
+
*
|
|
9
|
+
* @param value The value to check.
|
|
10
|
+
* @returns `true` if the value is a NegativeFiniteNumber, `false` otherwise.
|
|
11
|
+
*/
|
|
12
|
+
export declare const isNegativeFiniteNumber: (a: number) => a is TtfImported_NegativeFiniteNumber;
|
|
13
|
+
/**
|
|
14
|
+
* Casts a number to a NegativeFiniteNumber type.
|
|
15
|
+
*
|
|
16
|
+
* @param value The value to cast.
|
|
17
|
+
* @returns The value as a NegativeFiniteNumber type.
|
|
18
|
+
* @throws {TypeError} If the value is not a negative finite number.
|
|
19
|
+
*/
|
|
20
|
+
export declare const asNegativeFiniteNumber: <N extends number>(x: N) => number & {
|
|
21
|
+
readonly NaNValue: false;
|
|
22
|
+
readonly Finite: true;
|
|
23
|
+
readonly ">=0": false;
|
|
24
|
+
readonly "!=0": true;
|
|
25
|
+
readonly "<=0": true;
|
|
26
|
+
readonly "< 2^15": true;
|
|
27
|
+
readonly "< 2^16": true;
|
|
28
|
+
readonly "< 2^31": true;
|
|
29
|
+
readonly "< 2^32": true;
|
|
30
|
+
} & Readonly<{
|
|
31
|
+
'TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3': unknown;
|
|
32
|
+
}> & N;
|
|
33
|
+
/**
|
|
34
|
+
* Namespace providing type-safe arithmetic operations for negative finite
|
|
35
|
+
* numbers.
|
|
36
|
+
*
|
|
37
|
+
* All operations keep results finite (excluding NaN and Infinity). Operations
|
|
38
|
+
* that stay within the negative finite numbers clamp their results to the valid
|
|
39
|
+
* range, while operations whose result leaves the set (`mul`, `div`, `abs`) are
|
|
40
|
+
* typed to reflect the actual sign of the result.
|
|
41
|
+
*/
|
|
42
|
+
export declare const NegativeFiniteNumber: {
|
|
43
|
+
/**
|
|
44
|
+
* Type guard to check if a value is a NegativeFiniteNumber.
|
|
45
|
+
*
|
|
46
|
+
* @param value The value to check.
|
|
47
|
+
* @returns `true` if the value is a negative finite number, `false`
|
|
48
|
+
* otherwise.
|
|
49
|
+
*/
|
|
50
|
+
readonly is: (a: number) => a is TtfImported_NegativeFiniteNumber;
|
|
51
|
+
/**
|
|
52
|
+
* The maximum value for a negative finite number.
|
|
53
|
+
*
|
|
54
|
+
* @readonly
|
|
55
|
+
*/
|
|
56
|
+
readonly MAX_VALUE: number;
|
|
57
|
+
/**
|
|
58
|
+
* Returns the absolute value of a negative finite number.
|
|
59
|
+
*
|
|
60
|
+
* @param a The negative finite number.
|
|
61
|
+
* @returns The absolute value as a PositiveFiniteNumber.
|
|
62
|
+
*/
|
|
63
|
+
readonly abs: (x: ElementType) => PositiveFiniteNumber;
|
|
64
|
+
/**
|
|
65
|
+
* Returns the smaller of two NegativeFiniteNumber values.
|
|
66
|
+
*
|
|
67
|
+
* @param a The first NegativeFiniteNumber.
|
|
68
|
+
* @param b The second NegativeFiniteNumber.
|
|
69
|
+
* @returns The minimum value as a NegativeFiniteNumber.
|
|
70
|
+
*/
|
|
71
|
+
readonly min: (...values: readonly TtfImported_NegativeFiniteNumber[]) => TtfImported_NegativeFiniteNumber;
|
|
72
|
+
/**
|
|
73
|
+
* Returns the larger of two NegativeFiniteNumber values.
|
|
74
|
+
*
|
|
75
|
+
* @param a The first NegativeFiniteNumber.
|
|
76
|
+
* @param b The second NegativeFiniteNumber.
|
|
77
|
+
* @returns The maximum value as a NegativeFiniteNumber.
|
|
78
|
+
*/
|
|
79
|
+
readonly max: (...values: readonly TtfImported_NegativeFiniteNumber[]) => TtfImported_NegativeFiniteNumber;
|
|
80
|
+
/**
|
|
81
|
+
* Clamps a number to the negative finite range.
|
|
82
|
+
*
|
|
83
|
+
* @param value The number to clamp.
|
|
84
|
+
* @returns The value clamped to `(-∞, 0)` as a NegativeFiniteNumber.
|
|
85
|
+
*/
|
|
86
|
+
readonly clamp: (x: number) => TtfImported_NegativeFiniteNumber;
|
|
87
|
+
/**
|
|
88
|
+
* Rounds down a NegativeFiniteNumber to the nearest integer.
|
|
89
|
+
*
|
|
90
|
+
* @param x The NegativeFiniteNumber to round down.
|
|
91
|
+
* @returns The floor value as a NegativeInt (always `<= -1`).
|
|
92
|
+
*/
|
|
93
|
+
readonly floor: (x: ElementType) => TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>;
|
|
94
|
+
/**
|
|
95
|
+
* Rounds up a NegativeFiniteNumber to the nearest integer.
|
|
96
|
+
*
|
|
97
|
+
* @param x The NegativeFiniteNumber to round up.
|
|
98
|
+
* @returns The ceiling value as a NonPositiveInt (can be 0).
|
|
99
|
+
*/
|
|
100
|
+
readonly ceil: (x: ElementType) => TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>>;
|
|
101
|
+
/**
|
|
102
|
+
* Rounds a NegativeFiniteNumber to the nearest integer.
|
|
103
|
+
*
|
|
104
|
+
* @param x The NegativeFiniteNumber to round.
|
|
105
|
+
* @returns The rounded value as a NonPositiveInt (can be 0 if x > -0.5).
|
|
106
|
+
*/
|
|
107
|
+
readonly round: (x: ElementType) => TsDataForgeInternals.RefinedNumberUtils.RemoveNonZeroBrandKey<TsDataForgeInternals.RefinedNumberUtils.ToInt<ElementType>>;
|
|
108
|
+
/**
|
|
109
|
+
* Generates a random NegativeFiniteNumber value.
|
|
110
|
+
*
|
|
111
|
+
* @returns A random negative finite number.
|
|
112
|
+
*/
|
|
113
|
+
readonly random: (min?: TtfImported_NegativeFiniteNumber | undefined, max?: TtfImported_NegativeFiniteNumber | undefined) => TtfImported_NegativeFiniteNumber;
|
|
114
|
+
/**
|
|
115
|
+
* Raises a NegativeFiniteNumber to the power of another NegativeFiniteNumber.
|
|
116
|
+
*
|
|
117
|
+
* @param a The base NegativeFiniteNumber.
|
|
118
|
+
* @param b The exponent NegativeFiniteNumber.
|
|
119
|
+
* @returns `a ** b` clamped to `(-∞, 0)` as a NegativeFiniteNumber.
|
|
120
|
+
*/
|
|
121
|
+
readonly pow: (x: TtfImported_NegativeFiniteNumber, y: TtfImported_NegativeFiniteNumber) => TtfImported_NegativeFiniteNumber;
|
|
122
|
+
/**
|
|
123
|
+
* Adds two NegativeFiniteNumber values.
|
|
124
|
+
*
|
|
125
|
+
* @param a The first NegativeFiniteNumber.
|
|
126
|
+
* @param b The second NegativeFiniteNumber.
|
|
127
|
+
* @returns `a + b` as a NegativeFiniteNumber.
|
|
128
|
+
*/
|
|
129
|
+
readonly add: (x: TtfImported_NegativeFiniteNumber, y: TtfImported_NegativeFiniteNumber) => TtfImported_NegativeFiniteNumber;
|
|
130
|
+
/**
|
|
131
|
+
* Subtracts one NegativeFiniteNumber from another.
|
|
132
|
+
*
|
|
133
|
+
* The mathematical result can be positive, so it is clamped to the negative
|
|
134
|
+
* finite range (maximum `-Number.MIN_VALUE`).
|
|
135
|
+
*
|
|
136
|
+
* @param a The minuend NegativeFiniteNumber.
|
|
137
|
+
* @param b The subtrahend NegativeFiniteNumber.
|
|
138
|
+
* @returns `a - b` clamped to `(-∞, 0)` as a NegativeFiniteNumber.
|
|
139
|
+
*/
|
|
140
|
+
readonly sub: (x: TtfImported_NegativeFiniteNumber, y: TtfImported_NegativeFiniteNumber) => TtfImported_NegativeFiniteNumber;
|
|
141
|
+
};
|
|
142
|
+
export {};
|
|
143
|
+
//# sourceMappingURL=negative-finite-number.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"negative-finite-number.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/negative-finite-number.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oBAAoB,IAAI,gCAAgC,EAAE,MAAM,eAAe,CAAC;AAC9F,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAEpE,MAAM,MAAM,oBAAoB,GAAG,gCAAgC,CAAC;AAEpE,KAAK,WAAW,GAAG,oBAAoB,CAAC;AAkExC;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,sDAAK,CAAC;AAEzC;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;MAAW,CAAC;AAE/C;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB;IAC/B;;;;;;OAMG;;IAGH;;;;OAIG;;IAGH;;;;;OAKG;sBA/EW,WAAW,KAAG,oBAAoB;IAkFhD;;;;;;OAMG;;IAGH;;;;;;OAMG;;IAGH;;;;;OAKG;;IAGH;;;;;OAKG;wBA7GA,WAAW,KACb,oBAAoB,CAAC,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC;IA+G3D;;;;;OAKG;uBA/GA,WAAW,KACb,oBAAoB,CAAC,kBAAkB,CAAC,qBAAqB,CAC9D,oBAAoB,CAAC,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC,CAC3D;IA+GC;;;;;OAKG;wBA7GA,WAAW,KACb,oBAAoB,CAAC,kBAAkB,CAAC,qBAAqB,CAC9D,oBAAoB,CAAC,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC,CAC3D;IA6GC;;;;OAIG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;IAGH;;;;;;;;;OASG;;CAEK,CAAC"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { TsDataForgeInternals } from '../refined-number-utils.mjs';
|
|
2
|
+
import { PositiveFiniteNumber } from './positive-finite-number.mjs';
|
|
3
|
+
|
|
4
|
+
const typeNameInMessage = 'a negative finite number';
|
|
5
|
+
const { MAX_VALUE, add, castType, clamp, is, max: max_, min: min_, pow, random, sub, } = TsDataForgeInternals.RefinedNumberUtils.operatorsForFloat({
|
|
6
|
+
nonZero: true,
|
|
7
|
+
MIN_VALUE: -Number.MAX_VALUE,
|
|
8
|
+
MAX_VALUE: -Number.MIN_VALUE,
|
|
9
|
+
typeNameInMessage,
|
|
10
|
+
});
|
|
11
|
+
/**
|
|
12
|
+
* Returns the absolute value of a negative finite number.
|
|
13
|
+
*
|
|
14
|
+
* The absolute value of a negative finite number is always a positive finite
|
|
15
|
+
* number, so the result is typed as a {@link PositiveFiniteNumber}.
|
|
16
|
+
*
|
|
17
|
+
* @param x - The negative finite number.
|
|
18
|
+
* @returns `|x|` as a PositiveFiniteNumber.
|
|
19
|
+
*/
|
|
20
|
+
const abs = (x) => PositiveFiniteNumber.clamp(Math.abs(x));
|
|
21
|
+
const floor = (x) =>
|
|
22
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
23
|
+
Math.floor(x);
|
|
24
|
+
const ceil = (x) =>
|
|
25
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
26
|
+
Math.ceil(x);
|
|
27
|
+
const round = (x) =>
|
|
28
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
29
|
+
Math.round(x);
|
|
30
|
+
/**
|
|
31
|
+
* Checks if a number is a NegativeFiniteNumber (a finite number `< 0`).
|
|
32
|
+
*
|
|
33
|
+
* @param value The value to check.
|
|
34
|
+
* @returns `true` if the value is a NegativeFiniteNumber, `false` otherwise.
|
|
35
|
+
*/
|
|
36
|
+
const isNegativeFiniteNumber = is;
|
|
37
|
+
/**
|
|
38
|
+
* Casts a number to a NegativeFiniteNumber type.
|
|
39
|
+
*
|
|
40
|
+
* @param value The value to cast.
|
|
41
|
+
* @returns The value as a NegativeFiniteNumber type.
|
|
42
|
+
* @throws {TypeError} If the value is not a negative finite number.
|
|
43
|
+
*/
|
|
44
|
+
const asNegativeFiniteNumber = castType;
|
|
45
|
+
/**
|
|
46
|
+
* Namespace providing type-safe arithmetic operations for negative finite
|
|
47
|
+
* numbers.
|
|
48
|
+
*
|
|
49
|
+
* All operations keep results finite (excluding NaN and Infinity). Operations
|
|
50
|
+
* that stay within the negative finite numbers clamp their results to the valid
|
|
51
|
+
* range, while operations whose result leaves the set (`mul`, `div`, `abs`) are
|
|
52
|
+
* typed to reflect the actual sign of the result.
|
|
53
|
+
*/
|
|
54
|
+
const NegativeFiniteNumber = {
|
|
55
|
+
/**
|
|
56
|
+
* Type guard to check if a value is a NegativeFiniteNumber.
|
|
57
|
+
*
|
|
58
|
+
* @param value The value to check.
|
|
59
|
+
* @returns `true` if the value is a negative finite number, `false`
|
|
60
|
+
* otherwise.
|
|
61
|
+
*/
|
|
62
|
+
is,
|
|
63
|
+
/**
|
|
64
|
+
* The maximum value for a negative finite number.
|
|
65
|
+
*
|
|
66
|
+
* @readonly
|
|
67
|
+
*/
|
|
68
|
+
MAX_VALUE,
|
|
69
|
+
/**
|
|
70
|
+
* Returns the absolute value of a negative finite number.
|
|
71
|
+
*
|
|
72
|
+
* @param a The negative finite number.
|
|
73
|
+
* @returns The absolute value as a PositiveFiniteNumber.
|
|
74
|
+
*/
|
|
75
|
+
abs,
|
|
76
|
+
/**
|
|
77
|
+
* Returns the smaller of two NegativeFiniteNumber values.
|
|
78
|
+
*
|
|
79
|
+
* @param a The first NegativeFiniteNumber.
|
|
80
|
+
* @param b The second NegativeFiniteNumber.
|
|
81
|
+
* @returns The minimum value as a NegativeFiniteNumber.
|
|
82
|
+
*/
|
|
83
|
+
min: min_,
|
|
84
|
+
/**
|
|
85
|
+
* Returns the larger of two NegativeFiniteNumber values.
|
|
86
|
+
*
|
|
87
|
+
* @param a The first NegativeFiniteNumber.
|
|
88
|
+
* @param b The second NegativeFiniteNumber.
|
|
89
|
+
* @returns The maximum value as a NegativeFiniteNumber.
|
|
90
|
+
*/
|
|
91
|
+
max: max_,
|
|
92
|
+
/**
|
|
93
|
+
* Clamps a number to the negative finite range.
|
|
94
|
+
*
|
|
95
|
+
* @param value The number to clamp.
|
|
96
|
+
* @returns The value clamped to `(-∞, 0)` as a NegativeFiniteNumber.
|
|
97
|
+
*/
|
|
98
|
+
clamp,
|
|
99
|
+
/**
|
|
100
|
+
* Rounds down a NegativeFiniteNumber to the nearest integer.
|
|
101
|
+
*
|
|
102
|
+
* @param x The NegativeFiniteNumber to round down.
|
|
103
|
+
* @returns The floor value as a NegativeInt (always `<= -1`).
|
|
104
|
+
*/
|
|
105
|
+
floor,
|
|
106
|
+
/**
|
|
107
|
+
* Rounds up a NegativeFiniteNumber to the nearest integer.
|
|
108
|
+
*
|
|
109
|
+
* @param x The NegativeFiniteNumber to round up.
|
|
110
|
+
* @returns The ceiling value as a NonPositiveInt (can be 0).
|
|
111
|
+
*/
|
|
112
|
+
ceil,
|
|
113
|
+
/**
|
|
114
|
+
* Rounds a NegativeFiniteNumber to the nearest integer.
|
|
115
|
+
*
|
|
116
|
+
* @param x The NegativeFiniteNumber to round.
|
|
117
|
+
* @returns The rounded value as a NonPositiveInt (can be 0 if x > -0.5).
|
|
118
|
+
*/
|
|
119
|
+
round,
|
|
120
|
+
/**
|
|
121
|
+
* Generates a random NegativeFiniteNumber value.
|
|
122
|
+
*
|
|
123
|
+
* @returns A random negative finite number.
|
|
124
|
+
*/
|
|
125
|
+
random,
|
|
126
|
+
/**
|
|
127
|
+
* Raises a NegativeFiniteNumber to the power of another NegativeFiniteNumber.
|
|
128
|
+
*
|
|
129
|
+
* @param a The base NegativeFiniteNumber.
|
|
130
|
+
* @param b The exponent NegativeFiniteNumber.
|
|
131
|
+
* @returns `a ** b` clamped to `(-∞, 0)` as a NegativeFiniteNumber.
|
|
132
|
+
*/
|
|
133
|
+
pow,
|
|
134
|
+
/**
|
|
135
|
+
* Adds two NegativeFiniteNumber values.
|
|
136
|
+
*
|
|
137
|
+
* @param a The first NegativeFiniteNumber.
|
|
138
|
+
* @param b The second NegativeFiniteNumber.
|
|
139
|
+
* @returns `a + b` as a NegativeFiniteNumber.
|
|
140
|
+
*/
|
|
141
|
+
add,
|
|
142
|
+
/**
|
|
143
|
+
* Subtracts one NegativeFiniteNumber from another.
|
|
144
|
+
*
|
|
145
|
+
* The mathematical result can be positive, so it is clamped to the negative
|
|
146
|
+
* finite range (maximum `-Number.MIN_VALUE`).
|
|
147
|
+
*
|
|
148
|
+
* @param a The minuend NegativeFiniteNumber.
|
|
149
|
+
* @param b The subtrahend NegativeFiniteNumber.
|
|
150
|
+
* @returns `a - b` clamped to `(-∞, 0)` as a NegativeFiniteNumber.
|
|
151
|
+
*/
|
|
152
|
+
sub,
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
export { NegativeFiniteNumber, asNegativeFiniteNumber, isNegativeFiniteNumber };
|
|
156
|
+
//# sourceMappingURL=negative-finite-number.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"negative-finite-number.mjs","sources":["../../../src/number/branded-types/negative-finite-number.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAQA,MAAM,iBAAiB,GAAG,0BAA0B;AAEpD,MAAM,EACJ,SAAS,EACT,GAAG,EACH,QAAQ,EACR,KAAK,EACL,EAAE,EACF,GAAG,EAAE,IAAI,EACT,GAAG,EAAE,IAAI,EACT,GAAG,EACH,MAAM,EACN,GAAG,GACJ,GAAG,oBAAoB,CAAC,kBAAkB,CAAC,iBAAiB,CAI3D;AACA,IAAA,OAAO,EAAE,IAAI;AACb,IAAA,SAAS,EAAE,CAAC,MAAM,CAAC,SAAS;AAC5B,IAAA,SAAS,EAAE,CAAC,MAAM,CAAC,SAAS;IAC5B,iBAAiB;AACT,CAAA,CAAC;AAEX;;;;;;;;AAQG;AACH,MAAM,GAAG,GAAG,CAAC,CAAc,KACzB,oBAAoB,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAEzC,MAAM,KAAK,GAAG,CACZ,CAAc;AAEd;AACA,IAAI,CAAC,KAAK,CAAC,CAAC,CAA+D;AAE7E,MAAM,IAAI,GAAG,CACX,CAAc;AAId;AACA,IAAI,CAAC,IAAI,CAAC,CAAC,CAEV;AAEH,MAAM,KAAK,GAAG,CACZ,CAAc;AAId;AACA,IAAI,CAAC,KAAK,CACR,CAAC,CAGF;AAEH;;;;;AAKG;AACI,MAAM,sBAAsB,GAAG;AAEtC;;;;;;AAMG;AACI,MAAM,sBAAsB,GAAG;AAEtC;;;;;;;;AAQG;AACI,MAAM,oBAAoB,GAAG;AAClC;;;;;;AAMG;IACH,EAAE;AAEF;;;;AAIG;IACH,SAAS;AAET;;;;;AAKG;IACH,GAAG;AAEH;;;;;;AAMG;AACH,IAAA,GAAG,EAAE,IAAI;AAET;;;;;;AAMG;AACH,IAAA,GAAG,EAAE,IAAI;AAET;;;;;AAKG;IACH,KAAK;AAEL;;;;;AAKG;IACH,KAAK;AAEL;;;;;AAKG;IACH,IAAI;AAEJ;;;;;AAKG;IACH,KAAK;AAEL;;;;AAIG;IACH,MAAM;AAEN;;;;;;AAMG;IACH,GAAG;AAEH;;;;;;AAMG;IACH,GAAG;AAEH;;;;;;;;;AASG;IACH,GAAG;;;;;"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { type NegativeInt as TtfImported_NegativeInt, type WithSmallInt } from 'ts-type-forge';
|
|
2
|
+
import { PositiveInt } from './positive-int.mjs';
|
|
3
|
+
export type NegativeInt = TtfImported_NegativeInt;
|
|
4
|
+
type ElementType = NegativeInt;
|
|
5
|
+
/**
|
|
6
|
+
* Checks if a number is a NegativeInt (a negative integer `<= -1`).
|
|
7
|
+
*
|
|
8
|
+
* @param value The value to check.
|
|
9
|
+
* @returns `true` if the value is a NegativeInt, `false` otherwise.
|
|
10
|
+
*/
|
|
11
|
+
export declare const isNegativeInt: (a: number) => a is TtfImported_NegativeInt;
|
|
12
|
+
/**
|
|
13
|
+
* Casts a number to a NegativeInt type.
|
|
14
|
+
*
|
|
15
|
+
* @param value The value to cast.
|
|
16
|
+
* @returns The value as a NegativeInt type.
|
|
17
|
+
* @throws {TypeError} If the value is not a negative integer.
|
|
18
|
+
*/
|
|
19
|
+
export declare const asNegativeInt: <N extends number>(x: N) => number & {
|
|
20
|
+
readonly NaNValue: false;
|
|
21
|
+
readonly Finite: true;
|
|
22
|
+
readonly Int: true;
|
|
23
|
+
readonly ">=0": false;
|
|
24
|
+
readonly "!=0": true;
|
|
25
|
+
readonly "<=0": true;
|
|
26
|
+
readonly "< 2^15": true;
|
|
27
|
+
readonly "< 2^16": true;
|
|
28
|
+
readonly "< 2^31": true;
|
|
29
|
+
readonly "< 2^32": true;
|
|
30
|
+
} & Readonly<{
|
|
31
|
+
'TSTypeForgeInternals--edd2f9ce-7ca5-45b0-9d1a-bd61b9b5d9c3': unknown;
|
|
32
|
+
}> & N;
|
|
33
|
+
/**
|
|
34
|
+
* Namespace providing type-safe arithmetic operations for negative integers.
|
|
35
|
+
*
|
|
36
|
+
* NegativeInt represents integers that are strictly less than zero (`<= -1`).
|
|
37
|
+
* Operations that stay within the negative integers (such as `add`) clamp their
|
|
38
|
+
* results to the valid range, while operations whose result leaves the set
|
|
39
|
+
* (`mul`, `div`, `abs`) are typed to reflect the actual sign of the result.
|
|
40
|
+
*/
|
|
41
|
+
export declare const NegativeInt: {
|
|
42
|
+
/**
|
|
43
|
+
* Type guard to check if a value is a NegativeInt.
|
|
44
|
+
*
|
|
45
|
+
* @param value The value to check.
|
|
46
|
+
* @returns `true` if the value is a negative integer, `false` otherwise.
|
|
47
|
+
*/
|
|
48
|
+
readonly is: (a: number) => a is TtfImported_NegativeInt;
|
|
49
|
+
/**
|
|
50
|
+
* The maximum value for a negative integer.
|
|
51
|
+
*
|
|
52
|
+
* @readonly
|
|
53
|
+
*/
|
|
54
|
+
readonly MAX_VALUE: -1;
|
|
55
|
+
/**
|
|
56
|
+
* Returns the absolute value of a negative integer.
|
|
57
|
+
*
|
|
58
|
+
* @param a The negative integer.
|
|
59
|
+
* @returns The absolute value as a PositiveInt.
|
|
60
|
+
*/
|
|
61
|
+
readonly abs: (x: WithSmallInt<ElementType>) => PositiveInt;
|
|
62
|
+
/**
|
|
63
|
+
* Returns the smaller of two negative integers.
|
|
64
|
+
*
|
|
65
|
+
* @param a The first negative integer.
|
|
66
|
+
* @param b The second negative integer.
|
|
67
|
+
* @returns The minimum value as a NegativeInt.
|
|
68
|
+
*/
|
|
69
|
+
readonly min: (...values: readonly WithSmallInt<TtfImported_NegativeInt>[]) => TtfImported_NegativeInt;
|
|
70
|
+
/**
|
|
71
|
+
* Returns the larger of two negative integers.
|
|
72
|
+
*
|
|
73
|
+
* @param a The first negative integer.
|
|
74
|
+
* @param b The second negative integer.
|
|
75
|
+
* @returns The maximum value as a NegativeInt.
|
|
76
|
+
*/
|
|
77
|
+
readonly max: (...values: readonly WithSmallInt<TtfImported_NegativeInt>[]) => TtfImported_NegativeInt;
|
|
78
|
+
/**
|
|
79
|
+
* Clamps a number to the negative integer range.
|
|
80
|
+
*
|
|
81
|
+
* @param value The number to clamp.
|
|
82
|
+
* @returns The value clamped to `[-∞, -1]` as a NegativeInt.
|
|
83
|
+
*/
|
|
84
|
+
readonly clamp: (x: number) => TtfImported_NegativeInt;
|
|
85
|
+
/**
|
|
86
|
+
* Generates a random NegativeInt value within the valid range.
|
|
87
|
+
*
|
|
88
|
+
* @returns A random negative integer.
|
|
89
|
+
*/
|
|
90
|
+
readonly random: (min?: WithSmallInt<TtfImported_NegativeInt> | undefined, max?: WithSmallInt<TtfImported_NegativeInt> | undefined) => TtfImported_NegativeInt;
|
|
91
|
+
/**
|
|
92
|
+
* Raises a negative integer to the power of another negative integer.
|
|
93
|
+
*
|
|
94
|
+
* @param a The base negative integer.
|
|
95
|
+
* @param b The exponent negative integer.
|
|
96
|
+
* @returns `a ** b` clamped to the negative integer range.
|
|
97
|
+
*/
|
|
98
|
+
readonly pow: (x: WithSmallInt<TtfImported_NegativeInt>, y: WithSmallInt<TtfImported_NegativeInt>) => TtfImported_NegativeInt;
|
|
99
|
+
/**
|
|
100
|
+
* Adds two negative integers.
|
|
101
|
+
*
|
|
102
|
+
* @param a The first negative integer.
|
|
103
|
+
* @param b The second negative integer.
|
|
104
|
+
* @returns `a + b` as a NegativeInt.
|
|
105
|
+
*/
|
|
106
|
+
readonly add: (x: WithSmallInt<TtfImported_NegativeInt>, y: WithSmallInt<TtfImported_NegativeInt>) => TtfImported_NegativeInt;
|
|
107
|
+
/**
|
|
108
|
+
* Subtracts one negative integer from another.
|
|
109
|
+
*
|
|
110
|
+
* The mathematical result can be positive, so it is clamped to the negative
|
|
111
|
+
* integer range (maximum `-1`).
|
|
112
|
+
*
|
|
113
|
+
* @param a The minuend negative integer.
|
|
114
|
+
* @param b The subtrahend negative integer.
|
|
115
|
+
* @returns `a - b` clamped to the negative integer range.
|
|
116
|
+
*/
|
|
117
|
+
readonly sub: (x: WithSmallInt<TtfImported_NegativeInt>, y: WithSmallInt<TtfImported_NegativeInt>) => TtfImported_NegativeInt;
|
|
118
|
+
};
|
|
119
|
+
export {};
|
|
120
|
+
//# sourceMappingURL=negative-int.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"negative-int.d.mts","sourceRoot":"","sources":["../../../src/number/branded-types/negative-int.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,WAAW,IAAI,uBAAuB,EAC3C,KAAK,YAAY,EAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD,MAAM,MAAM,WAAW,GAAG,uBAAuB,CAAC;AAElD,KAAK,WAAW,GAAG,WAAW,CAAC;AAuC/B;;;;;GAKG;AACH,eAAO,MAAM,aAAa,6CAAK,CAAC;AAEhC;;;;;;GAMG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;MAAW,CAAC;AAEtC;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW;IACtB;;;;;OAKG;;IAGH;;;;OAIG;;IAGH;;;;;OAKG;sBAjDW,YAAY,CAAC,WAAW,CAAC,KAAG,WAAW;IAoDrD;;;;;;OAMG;;IAGH;;;;;;OAMG;;IAGH;;;;;OAKG;;IAGH;;;;OAIG;;IAGH;;;;;;OAMG;;IAGH;;;;;;OAMG;;IAGH;;;;;;;;;OASG;;CAEK,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { TsDataForgeInternals } from '../refined-number-utils.mjs';
|
|
2
|
+
import { PositiveInt } from './positive-int.mjs';
|
|
3
|
+
|
|
4
|
+
const typeNameInMessage = 'a negative integer';
|
|
5
|
+
const { MAX_VALUE, add, castType, clamp, is, max: max_, min: min_, pow, random, sub, } = TsDataForgeInternals.RefinedNumberUtils.operatorsForInteger({
|
|
6
|
+
integerOrSafeInteger: 'Integer',
|
|
7
|
+
nonZero: true,
|
|
8
|
+
MIN_VALUE: -Number.MAX_VALUE,
|
|
9
|
+
MAX_VALUE: -1,
|
|
10
|
+
typeNameInMessage,
|
|
11
|
+
});
|
|
12
|
+
/**
|
|
13
|
+
* Returns the absolute value of a negative integer.
|
|
14
|
+
*
|
|
15
|
+
* The absolute value of a negative integer is always a positive integer
|
|
16
|
+
* (`>= 1`), so the result is typed as a {@link PositiveInt}.
|
|
17
|
+
*
|
|
18
|
+
* @param x - The negative integer.
|
|
19
|
+
* @returns `|x|` as a PositiveInt.
|
|
20
|
+
*/
|
|
21
|
+
const abs = (x) => PositiveInt.clamp(Math.abs(x));
|
|
22
|
+
/**
|
|
23
|
+
* Checks if a number is a NegativeInt (a negative integer `<= -1`).
|
|
24
|
+
*
|
|
25
|
+
* @param value The value to check.
|
|
26
|
+
* @returns `true` if the value is a NegativeInt, `false` otherwise.
|
|
27
|
+
*/
|
|
28
|
+
const isNegativeInt = is;
|
|
29
|
+
/**
|
|
30
|
+
* Casts a number to a NegativeInt type.
|
|
31
|
+
*
|
|
32
|
+
* @param value The value to cast.
|
|
33
|
+
* @returns The value as a NegativeInt type.
|
|
34
|
+
* @throws {TypeError} If the value is not a negative integer.
|
|
35
|
+
*/
|
|
36
|
+
const asNegativeInt = castType;
|
|
37
|
+
/**
|
|
38
|
+
* Namespace providing type-safe arithmetic operations for negative integers.
|
|
39
|
+
*
|
|
40
|
+
* NegativeInt represents integers that are strictly less than zero (`<= -1`).
|
|
41
|
+
* Operations that stay within the negative integers (such as `add`) clamp their
|
|
42
|
+
* results to the valid range, while operations whose result leaves the set
|
|
43
|
+
* (`mul`, `div`, `abs`) are typed to reflect the actual sign of the result.
|
|
44
|
+
*/
|
|
45
|
+
const NegativeInt = {
|
|
46
|
+
/**
|
|
47
|
+
* Type guard to check if a value is a NegativeInt.
|
|
48
|
+
*
|
|
49
|
+
* @param value The value to check.
|
|
50
|
+
* @returns `true` if the value is a negative integer, `false` otherwise.
|
|
51
|
+
*/
|
|
52
|
+
is,
|
|
53
|
+
/**
|
|
54
|
+
* The maximum value for a negative integer.
|
|
55
|
+
*
|
|
56
|
+
* @readonly
|
|
57
|
+
*/
|
|
58
|
+
MAX_VALUE,
|
|
59
|
+
/**
|
|
60
|
+
* Returns the absolute value of a negative integer.
|
|
61
|
+
*
|
|
62
|
+
* @param a The negative integer.
|
|
63
|
+
* @returns The absolute value as a PositiveInt.
|
|
64
|
+
*/
|
|
65
|
+
abs,
|
|
66
|
+
/**
|
|
67
|
+
* Returns the smaller of two negative integers.
|
|
68
|
+
*
|
|
69
|
+
* @param a The first negative integer.
|
|
70
|
+
* @param b The second negative integer.
|
|
71
|
+
* @returns The minimum value as a NegativeInt.
|
|
72
|
+
*/
|
|
73
|
+
min: min_,
|
|
74
|
+
/**
|
|
75
|
+
* Returns the larger of two negative integers.
|
|
76
|
+
*
|
|
77
|
+
* @param a The first negative integer.
|
|
78
|
+
* @param b The second negative integer.
|
|
79
|
+
* @returns The maximum value as a NegativeInt.
|
|
80
|
+
*/
|
|
81
|
+
max: max_,
|
|
82
|
+
/**
|
|
83
|
+
* Clamps a number to the negative integer range.
|
|
84
|
+
*
|
|
85
|
+
* @param value The number to clamp.
|
|
86
|
+
* @returns The value clamped to `[-∞, -1]` as a NegativeInt.
|
|
87
|
+
*/
|
|
88
|
+
clamp,
|
|
89
|
+
/**
|
|
90
|
+
* Generates a random NegativeInt value within the valid range.
|
|
91
|
+
*
|
|
92
|
+
* @returns A random negative integer.
|
|
93
|
+
*/
|
|
94
|
+
random,
|
|
95
|
+
/**
|
|
96
|
+
* Raises a negative integer to the power of another negative integer.
|
|
97
|
+
*
|
|
98
|
+
* @param a The base negative integer.
|
|
99
|
+
* @param b The exponent negative integer.
|
|
100
|
+
* @returns `a ** b` clamped to the negative integer range.
|
|
101
|
+
*/
|
|
102
|
+
pow,
|
|
103
|
+
/**
|
|
104
|
+
* Adds two negative integers.
|
|
105
|
+
*
|
|
106
|
+
* @param a The first negative integer.
|
|
107
|
+
* @param b The second negative integer.
|
|
108
|
+
* @returns `a + b` as a NegativeInt.
|
|
109
|
+
*/
|
|
110
|
+
add,
|
|
111
|
+
/**
|
|
112
|
+
* Subtracts one negative integer from another.
|
|
113
|
+
*
|
|
114
|
+
* The mathematical result can be positive, so it is clamped to the negative
|
|
115
|
+
* integer range (maximum `-1`).
|
|
116
|
+
*
|
|
117
|
+
* @param a The minuend negative integer.
|
|
118
|
+
* @param b The subtrahend negative integer.
|
|
119
|
+
* @returns `a - b` clamped to the negative integer range.
|
|
120
|
+
*/
|
|
121
|
+
sub,
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
export { NegativeInt, asNegativeInt, isNegativeInt };
|
|
125
|
+
//# sourceMappingURL=negative-int.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"negative-int.mjs","sources":["../../../src/number/branded-types/negative-int.mts"],"sourcesContent":[null],"names":[],"mappings":";;;AAWA,MAAM,iBAAiB,GAAG,oBAAoB;AAE9C,MAAM,EACJ,SAAS,EACT,GAAG,EACH,QAAQ,EACR,KAAK,EACL,EAAE,EACF,GAAG,EAAE,IAAI,EACT,GAAG,EAAE,IAAI,EACT,GAAG,EACH,MAAM,EACN,GAAG,GACJ,GAAG,oBAAoB,CAAC,kBAAkB,CAAC,mBAAmB,CAI7D;AACA,IAAA,oBAAoB,EAAE,SAAS;AAC/B,IAAA,OAAO,EAAE,IAAI;AACb,IAAA,SAAS,EAAE,CAAC,MAAM,CAAC,SAAS;IAC5B,SAAS,EAAE,EAAE;IACb,iBAAiB;AACT,CAAA,CAAC;AAEX;;;;;;;;AAQG;AACH,MAAM,GAAG,GAAG,CAAC,CAA4B,KACvC,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAEhC;;;;;AAKG;AACI,MAAM,aAAa,GAAG;AAE7B;;;;;;AAMG;AACI,MAAM,aAAa,GAAG;AAE7B;;;;;;;AAOG;AACI,MAAM,WAAW,GAAG;AACzB;;;;;AAKG;IACH,EAAE;AAEF;;;;AAIG;IACH,SAAS;AAET;;;;;AAKG;IACH,GAAG;AAEH;;;;;;AAMG;AACH,IAAA,GAAG,EAAE,IAAI;AAET;;;;;;AAMG;AACH,IAAA,GAAG,EAAE,IAAI;AAET;;;;;AAKG;IACH,KAAK;AAEL;;;;AAIG;IACH,MAAM;AAEN;;;;;;AAMG;IACH,GAAG;AAEH;;;;;;AAMG;IACH,GAAG;AAEH;;;;;;;;;AASG;IACH,GAAG;;;;;"}
|