@obinexusmk2/hypernum 0.1.0 → 0.1.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/LICENSE +21 -21
- package/README.md +355 -256
- package/dist/index.cjs +4 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +4 -7
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/types/{config → src/config}/config-loader.d.ts +0 -0
- package/dist/types/src/config/config-loader.d.ts.map +1 -0
- package/dist/types/{config → src/config}/config-parser.d.ts +0 -0
- package/dist/types/src/config/config-parser.d.ts.map +1 -0
- package/dist/types/{config → src/config}/config-resolver.d.ts +0 -0
- package/dist/types/src/config/config-resolver.d.ts.map +1 -0
- package/dist/types/{config → src/config}/config-source.d.ts +0 -0
- package/dist/types/src/config/config-source.d.ts.map +1 -0
- package/dist/types/{config → src/config}/index.d.ts +0 -0
- package/dist/types/src/config/index.d.ts.map +1 -0
- package/dist/types/{core → src/core}/common.d.ts +0 -0
- package/dist/types/src/core/common.d.ts.map +1 -0
- package/dist/types/{core → src/core}/config.d.ts +0 -0
- package/dist/types/src/core/config.d.ts.map +1 -0
- package/dist/types/{core → src/core}/constants.d.ts +0 -0
- package/dist/types/src/core/constants.d.ts.map +1 -0
- package/dist/types/{core → src/core}/errors.d.ts +0 -0
- package/dist/types/src/core/errors.d.ts.map +1 -0
- package/dist/types/{core → src/core}/hypernum.d.ts +0 -0
- package/dist/types/src/core/hypernum.d.ts.map +1 -0
- package/dist/types/{core → src/core}/index.d.ts +0 -0
- package/dist/types/src/core/index.d.ts.map +1 -0
- package/dist/types/{index.d.ts → src/index.d.ts} +1 -1
- package/dist/types/src/index.d.ts.map +1 -0
- package/dist/types/{operations → src/operations}/arithmetic.d.ts +0 -0
- package/dist/types/src/operations/arithmetic.d.ts.map +1 -0
- package/dist/types/{operations → src/operations}/bitwise.d.ts +0 -0
- package/dist/types/src/operations/bitwise.d.ts.map +1 -0
- package/dist/types/{operations → src/operations}/comparison.d.ts +0 -0
- package/dist/types/src/operations/comparison.d.ts.map +1 -0
- package/dist/types/{operations → src/operations}/conversion.d.ts +0 -0
- package/dist/types/src/operations/conversion.d.ts.map +1 -0
- package/dist/types/{operations → src/operations}/factorial.d.ts +0 -0
- package/dist/types/src/operations/factorial.d.ts.map +1 -0
- package/dist/types/{operations → src/operations}/index.d.ts +0 -0
- package/dist/types/src/operations/index.d.ts.map +1 -0
- package/dist/types/{operations → src/operations}/power.d.ts +0 -0
- package/dist/types/src/operations/power.d.ts.map +1 -0
- package/dist/types/{storage → src/storage}/Heap.d.ts +0 -0
- package/dist/types/src/storage/Heap.d.ts.map +1 -0
- package/dist/types/{storage → src/storage}/index.d.ts +0 -0
- package/dist/types/src/storage/index.d.ts.map +1 -0
- package/dist/types/{structures → src/structures}/ackermann.d.ts +0 -0
- package/dist/types/src/structures/ackermann.d.ts.map +1 -0
- package/dist/types/{structures → src/structures}/big-array.d.ts +0 -0
- package/dist/types/src/structures/big-array.d.ts.map +1 -0
- package/dist/types/{structures → src/structures}/index.d.ts +0 -0
- package/dist/types/src/structures/index.d.ts.map +1 -0
- package/dist/types/{structures → src/structures}/number-tree.d.ts +0 -0
- package/dist/types/src/structures/number-tree.d.ts.map +1 -0
- package/dist/types/{structures → src/structures}/power-tower.d.ts +0 -0
- package/dist/types/src/structures/power-tower.d.ts.map +1 -0
- package/dist/types/{utils → src/utils}/formatting.d.ts +0 -0
- package/dist/types/src/utils/formatting.d.ts.map +1 -0
- package/dist/types/{utils → src/utils}/index.d.ts +0 -0
- package/dist/types/src/utils/index.d.ts.map +1 -0
- package/dist/types/{utils → src/utils}/parser.d.ts +0 -0
- package/dist/types/src/utils/parser.d.ts.map +1 -0
- package/dist/types/{utils → src/utils}/precision.d.ts +0 -0
- package/dist/types/src/utils/precision.d.ts.map +1 -0
- package/dist/types/{utils → src/utils}/validation.d.ts +0 -0
- package/dist/types/src/utils/validation.d.ts.map +1 -0
- package/package.json +169 -164
- package/rollup.config.js +163 -161
- package/src/cli/hypernum.js +272 -0
- package/src/config/config-loader.ts +0 -0
- package/src/config/config-parser.ts +160 -160
- package/src/config/config-resolver.ts +0 -0
- package/src/config/config-source.ts +0 -0
- package/src/config/index.ts +0 -0
- package/src/core/common.ts +184 -184
- package/src/core/config.ts +392 -392
- package/src/core/constants.ts +101 -101
- package/src/core/errors.ts +202 -202
- package/src/core/hypernum.ts +240 -240
- package/src/core/index.ts +4 -4
- package/src/index.ts +179 -182
- package/src/operations/arithmetic.ts +332 -332
- package/src/operations/bitwise.ts +366 -366
- package/src/operations/comparison.ts +271 -271
- package/src/operations/conversion.ts +399 -399
- package/src/operations/factorial.ts +278 -278
- package/src/operations/index.ts +4 -4
- package/src/operations/power.ts +315 -315
- package/src/storage/Heap.ts +237 -237
- package/src/storage/index.ts +0 -0
- package/src/structures/ackermann.ts +232 -232
- package/src/structures/big-array.ts +305 -305
- package/src/structures/index.ts +3 -3
- package/src/structures/number-tree.ts +403 -403
- package/src/structures/power-tower.ts +277 -277
- package/src/types/common.d.ts +356 -356
- package/src/types/core.d.ts +160 -160
- package/src/types/index.d.ts +1 -1
- package/src/utils/formatting.ts +245 -245
- package/src/utils/index.ts +4 -4
- package/src/utils/parser.ts +244 -244
- package/src/utils/precision.ts +216 -216
- package/src/utils/validation.ts +182 -182
- package/tsconfig.json +83 -83
- package/dist/types/config/config-loader.d.ts.map +0 -1
- package/dist/types/config/config-parser.d.ts.map +0 -1
- package/dist/types/config/config-resolver.d.ts.map +0 -1
- package/dist/types/config/config-source.d.ts.map +0 -1
- package/dist/types/config/index.d.ts.map +0 -1
- package/dist/types/core/common.d.ts.map +0 -1
- package/dist/types/core/config.d.ts.map +0 -1
- package/dist/types/core/constants.d.ts.map +0 -1
- package/dist/types/core/errors.d.ts.map +0 -1
- package/dist/types/core/hypernum.d.ts.map +0 -1
- package/dist/types/core/index.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/operations/arithmetic.d.ts.map +0 -1
- package/dist/types/operations/bitwise.d.ts.map +0 -1
- package/dist/types/operations/comparison.d.ts.map +0 -1
- package/dist/types/operations/conversion.d.ts.map +0 -1
- package/dist/types/operations/factorial.d.ts.map +0 -1
- package/dist/types/operations/index.d.ts.map +0 -1
- package/dist/types/operations/power.d.ts.map +0 -1
- package/dist/types/storage/Heap.d.ts.map +0 -1
- package/dist/types/storage/index.d.ts.map +0 -1
- package/dist/types/structures/ackermann.d.ts.map +0 -1
- package/dist/types/structures/big-array.d.ts.map +0 -1
- package/dist/types/structures/index.d.ts.map +0 -1
- package/dist/types/structures/number-tree.d.ts.map +0 -1
- package/dist/types/structures/power-tower.d.ts.map +0 -1
- package/dist/types/utils/formatting.d.ts.map +0 -1
- package/dist/types/utils/index.d.ts.map +0 -1
- package/dist/types/utils/parser.d.ts.map +0 -1
- package/dist/types/utils/precision.d.ts.map +0 -1
- package/dist/types/utils/validation.d.ts.map +0 -1
package/src/index.ts
CHANGED
|
@@ -1,183 +1,180 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hypernum - A TypeScript/JavaScript library for large number operations
|
|
3
|
-
*/
|
|
4
|
-
import { HypernumConfig, mergeConfig, validateConfig } from './core';
|
|
5
|
-
import { Hypernum } from './core/hypernum';
|
|
6
|
-
import { RoundingMode } from './utils/precision';
|
|
7
|
-
|
|
8
|
-
// Version
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export
|
|
17
|
-
|
|
18
|
-
export
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
} from './
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
export {
|
|
38
|
-
export {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
export {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
? mergedConfig.arithmetic.
|
|
158
|
-
: mergedConfig.
|
|
159
|
-
|
|
160
|
-
? mergedConfig.arithmetic.
|
|
161
|
-
:
|
|
162
|
-
|
|
163
|
-
? mergedConfig.arithmetic.
|
|
164
|
-
: mergedConfig.
|
|
165
|
-
|
|
166
|
-
? mergedConfig.
|
|
167
|
-
:
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
//
|
|
177
|
-
export
|
|
178
|
-
|
|
179
|
-
//
|
|
180
|
-
export { VERSION };
|
|
181
|
-
|
|
182
|
-
// Default export
|
|
1
|
+
/**
|
|
2
|
+
* Hypernum - A TypeScript/JavaScript library for large number operations
|
|
3
|
+
*/
|
|
4
|
+
import { HypernumConfig, mergeConfig, validateConfig } from './core';
|
|
5
|
+
import { Hypernum } from './core/hypernum';
|
|
6
|
+
import { RoundingMode } from './utils/precision';
|
|
7
|
+
|
|
8
|
+
// Version — inlined at build time via @rollup/plugin-json
|
|
9
|
+
import pkg from '../package.json';
|
|
10
|
+
const VERSION = pkg.version;
|
|
11
|
+
|
|
12
|
+
// Core exports
|
|
13
|
+
export { Hypernum } from './core/hypernum';
|
|
14
|
+
export * from './core/constants';
|
|
15
|
+
export * from './core/common';
|
|
16
|
+
export * from './core/config';
|
|
17
|
+
|
|
18
|
+
// Re-export errors with explicit names to avoid conflicts
|
|
19
|
+
export {
|
|
20
|
+
HypernumError,
|
|
21
|
+
ComputationLimitError,
|
|
22
|
+
DataStructureError,
|
|
23
|
+
DivisionByZeroError,
|
|
24
|
+
FormatError,
|
|
25
|
+
HeapPropertyError,
|
|
26
|
+
IndexError,
|
|
27
|
+
PrecisionError,
|
|
28
|
+
RomanNumeralError,
|
|
29
|
+
TreeError,
|
|
30
|
+
UnderflowError
|
|
31
|
+
} from './core/errors';
|
|
32
|
+
|
|
33
|
+
// Data structures with explicit imports and exports
|
|
34
|
+
export { AckermannStructure } from './structures/ackermann';
|
|
35
|
+
export { BigArray, type BigArrayOptions } from './structures/big-array';
|
|
36
|
+
export { NumberTree } from './structures/number-tree';
|
|
37
|
+
export { PowerTower } from './structures/power-tower';
|
|
38
|
+
export { MinHeap, MaxHeap, type Comparator } from './storage/';
|
|
39
|
+
|
|
40
|
+
// Operations with explicit exports
|
|
41
|
+
export {
|
|
42
|
+
add,
|
|
43
|
+
subtract,
|
|
44
|
+
multiply,
|
|
45
|
+
divide,
|
|
46
|
+
remainder,
|
|
47
|
+
abs,
|
|
48
|
+
sign,
|
|
49
|
+
gcd,
|
|
50
|
+
lcm
|
|
51
|
+
} from './operations/arithmetic';
|
|
52
|
+
|
|
53
|
+
export {
|
|
54
|
+
and,
|
|
55
|
+
or,
|
|
56
|
+
xor,
|
|
57
|
+
not,
|
|
58
|
+
leftShift,
|
|
59
|
+
rightShift,
|
|
60
|
+
unsignedRightShift,
|
|
61
|
+
rotateLeft,
|
|
62
|
+
rotateRight,
|
|
63
|
+
popCount,
|
|
64
|
+
trailingZeros,
|
|
65
|
+
leadingZeros,
|
|
66
|
+
getBit,
|
|
67
|
+
setBit,
|
|
68
|
+
clearBit,
|
|
69
|
+
toggleBit
|
|
70
|
+
} from './operations/bitwise';
|
|
71
|
+
|
|
72
|
+
export {
|
|
73
|
+
compare,
|
|
74
|
+
equals,
|
|
75
|
+
lessThan,
|
|
76
|
+
lessThanOrEqual,
|
|
77
|
+
greaterThan,
|
|
78
|
+
greaterThanOrEqual,
|
|
79
|
+
between,
|
|
80
|
+
max,
|
|
81
|
+
min,
|
|
82
|
+
clamp,
|
|
83
|
+
allEqual,
|
|
84
|
+
isAscending,
|
|
85
|
+
isDescending,
|
|
86
|
+
createComparator
|
|
87
|
+
} from './operations/comparison';
|
|
88
|
+
|
|
89
|
+
export {
|
|
90
|
+
toBinary,
|
|
91
|
+
toOctal,
|
|
92
|
+
toHexadecimal,
|
|
93
|
+
toBase,
|
|
94
|
+
fromBase,
|
|
95
|
+
toFraction,
|
|
96
|
+
fromFraction,
|
|
97
|
+
fromScientific,
|
|
98
|
+
toScientific,
|
|
99
|
+
fromRoman,
|
|
100
|
+
toRoman
|
|
101
|
+
} from './operations/conversion';
|
|
102
|
+
|
|
103
|
+
export {
|
|
104
|
+
factorial,
|
|
105
|
+
binomial,
|
|
106
|
+
subfactorial,
|
|
107
|
+
risingFactorial,
|
|
108
|
+
fallingFactorial,
|
|
109
|
+
multiFactorial,
|
|
110
|
+
primorial
|
|
111
|
+
} from './operations/factorial';
|
|
112
|
+
|
|
113
|
+
export {
|
|
114
|
+
power,
|
|
115
|
+
sqrt,
|
|
116
|
+
nthRoot,
|
|
117
|
+
tetration,
|
|
118
|
+
superRoot
|
|
119
|
+
} from './operations/power';
|
|
120
|
+
|
|
121
|
+
// Utils with explicit exports
|
|
122
|
+
export {
|
|
123
|
+
toBigInt,
|
|
124
|
+
validateNonNegative,
|
|
125
|
+
validatePositive,
|
|
126
|
+
checkAdditionOverflow,
|
|
127
|
+
checkMultiplicationOverflow,
|
|
128
|
+
checkPowerOverflow
|
|
129
|
+
} from './utils/validation';
|
|
130
|
+
|
|
131
|
+
export {
|
|
132
|
+
formatBigInt,
|
|
133
|
+
parseBigIntString,
|
|
134
|
+
normalizeNumberString
|
|
135
|
+
} from './utils/formatting';
|
|
136
|
+
|
|
137
|
+
export {
|
|
138
|
+
RoundingMode,
|
|
139
|
+
round,
|
|
140
|
+
scaleByPowerOfTen,
|
|
141
|
+
scaledDivision,
|
|
142
|
+
normalizePrecision
|
|
143
|
+
} from './utils/precision';
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Creates a new Hypernum instance with custom configuration
|
|
147
|
+
*/
|
|
148
|
+
export function createHypernum(config?: Partial<HypernumConfig>): Hypernum {
|
|
149
|
+
const mergedConfig = mergeConfig(config || {});
|
|
150
|
+
validateConfig(mergedConfig);
|
|
151
|
+
|
|
152
|
+
const instanceConfig = {
|
|
153
|
+
precision: 'arithmetic' in mergedConfig
|
|
154
|
+
? mergedConfig.arithmetic.defaultPrecision
|
|
155
|
+
: mergedConfig.precision ?? 0,
|
|
156
|
+
roundingMode: 'arithmetic' in mergedConfig
|
|
157
|
+
? mergedConfig.arithmetic.defaultRoundingMode
|
|
158
|
+
: (mergedConfig.roundingMode as RoundingMode) ?? RoundingMode.HALF_EVEN,
|
|
159
|
+
checkOverflow: 'arithmetic' in mergedConfig
|
|
160
|
+
? mergedConfig.arithmetic.checkOverflow
|
|
161
|
+
: mergedConfig.checkOverflow ?? true,
|
|
162
|
+
maxSteps: 'arithmetic' in mergedConfig
|
|
163
|
+
? mergedConfig.arithmetic.maxComputationSteps
|
|
164
|
+
: mergedConfig.maxSteps ?? 1000,
|
|
165
|
+
debug: 'debug' in mergedConfig && typeof mergedConfig.debug === 'object'
|
|
166
|
+
? mergedConfig.debug.verbose
|
|
167
|
+
: false
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
return new Hypernum(instanceConfig);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Default instance
|
|
174
|
+
export const defaultHypernum = createHypernum();
|
|
175
|
+
|
|
176
|
+
// Export version
|
|
177
|
+
export { VERSION };
|
|
178
|
+
|
|
179
|
+
// Default export
|
|
183
180
|
export default Hypernum;
|