@obinexusmk2/hypernum 0.1.0

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.
Files changed (108) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +256 -0
  3. package/dist/index.cjs +3425 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.ts +1449 -0
  6. package/dist/index.js +3284 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/index.umd.js +8 -0
  9. package/dist/index.umd.js.map +1 -0
  10. package/dist/types/config/config-loader.d.ts +56 -0
  11. package/dist/types/config/config-loader.d.ts.map +1 -0
  12. package/dist/types/config/config-parser.d.ts +28 -0
  13. package/dist/types/config/config-parser.d.ts.map +1 -0
  14. package/dist/types/config/config-resolver.d.ts +21 -0
  15. package/dist/types/config/config-resolver.d.ts.map +1 -0
  16. package/dist/types/config/config-source.d.ts +27 -0
  17. package/dist/types/config/config-source.d.ts.map +1 -0
  18. package/dist/types/config/index.d.ts +68 -0
  19. package/dist/types/config/index.d.ts.map +1 -0
  20. package/dist/types/core/common.d.ts +169 -0
  21. package/dist/types/core/common.d.ts.map +1 -0
  22. package/dist/types/core/config.d.ts +197 -0
  23. package/dist/types/core/config.d.ts.map +1 -0
  24. package/dist/types/core/constants.d.ts +88 -0
  25. package/dist/types/core/constants.d.ts.map +1 -0
  26. package/dist/types/core/errors.d.ts +97 -0
  27. package/dist/types/core/errors.d.ts.map +1 -0
  28. package/dist/types/core/hypernum.d.ts +60 -0
  29. package/dist/types/core/hypernum.d.ts.map +1 -0
  30. package/dist/types/core/index.d.ts +6 -0
  31. package/dist/types/core/index.d.ts.map +1 -0
  32. package/dist/types/index.d.ts +33 -0
  33. package/dist/types/index.d.ts.map +1 -0
  34. package/dist/types/operations/arithmetic.d.ts +72 -0
  35. package/dist/types/operations/arithmetic.d.ts.map +1 -0
  36. package/dist/types/operations/bitwise.d.ts +98 -0
  37. package/dist/types/operations/bitwise.d.ts.map +1 -0
  38. package/dist/types/operations/comparison.d.ts +94 -0
  39. package/dist/types/operations/comparison.d.ts.map +1 -0
  40. package/dist/types/operations/conversion.d.ts +79 -0
  41. package/dist/types/operations/conversion.d.ts.map +1 -0
  42. package/dist/types/operations/factorial.d.ts +58 -0
  43. package/dist/types/operations/factorial.d.ts.map +1 -0
  44. package/dist/types/operations/index.d.ts +6 -0
  45. package/dist/types/operations/index.d.ts.map +1 -0
  46. package/dist/types/operations/power.d.ts +49 -0
  47. package/dist/types/operations/power.d.ts.map +1 -0
  48. package/dist/types/storage/Heap.d.ts +95 -0
  49. package/dist/types/storage/Heap.d.ts.map +1 -0
  50. package/dist/types/storage/index.d.ts +2 -0
  51. package/dist/types/storage/index.d.ts.map +1 -0
  52. package/dist/types/structures/ackermann.d.ts +74 -0
  53. package/dist/types/structures/ackermann.d.ts.map +1 -0
  54. package/dist/types/structures/big-array.d.ts +102 -0
  55. package/dist/types/structures/big-array.d.ts.map +1 -0
  56. package/dist/types/structures/index.d.ts +5 -0
  57. package/dist/types/structures/index.d.ts.map +1 -0
  58. package/dist/types/structures/number-tree.d.ts +114 -0
  59. package/dist/types/structures/number-tree.d.ts.map +1 -0
  60. package/dist/types/structures/power-tower.d.ts +74 -0
  61. package/dist/types/structures/power-tower.d.ts.map +1 -0
  62. package/dist/types/utils/formatting.d.ts +45 -0
  63. package/dist/types/utils/formatting.d.ts.map +1 -0
  64. package/dist/types/utils/index.d.ts +5 -0
  65. package/dist/types/utils/index.d.ts.map +1 -0
  66. package/dist/types/utils/parser.d.ts +39 -0
  67. package/dist/types/utils/parser.d.ts.map +1 -0
  68. package/dist/types/utils/precision.d.ts +57 -0
  69. package/dist/types/utils/precision.d.ts.map +1 -0
  70. package/dist/types/utils/validation.d.ts +28 -0
  71. package/dist/types/utils/validation.d.ts.map +1 -0
  72. package/package.json +164 -0
  73. package/rollup.config.js +162 -0
  74. package/src/config/config-loader.ts +226 -0
  75. package/src/config/config-parser.ts +161 -0
  76. package/src/config/config-resolver.ts +52 -0
  77. package/src/config/config-source.ts +32 -0
  78. package/src/config/index.ts +159 -0
  79. package/src/core/common.ts +185 -0
  80. package/src/core/config.ts +393 -0
  81. package/src/core/constants.ts +102 -0
  82. package/src/core/errors.ts +203 -0
  83. package/src/core/hypernum.ts +241 -0
  84. package/src/core/index.ts +5 -0
  85. package/src/index.ts +183 -0
  86. package/src/operations/arithmetic.ts +333 -0
  87. package/src/operations/bitwise.ts +367 -0
  88. package/src/operations/comparison.ts +272 -0
  89. package/src/operations/conversion.ts +400 -0
  90. package/src/operations/factorial.ts +279 -0
  91. package/src/operations/index.ts +5 -0
  92. package/src/operations/power.ts +316 -0
  93. package/src/storage/Heap.ts +238 -0
  94. package/src/storage/index.ts +1 -0
  95. package/src/structures/ackermann.ts +233 -0
  96. package/src/structures/big-array.ts +306 -0
  97. package/src/structures/index.ts +4 -0
  98. package/src/structures/number-tree.ts +404 -0
  99. package/src/structures/power-tower.ts +278 -0
  100. package/src/types/common.d.ts +357 -0
  101. package/src/types/core.d.ts +161 -0
  102. package/src/types/index.d.ts +2 -0
  103. package/src/utils/formatting.ts +246 -0
  104. package/src/utils/index.ts +4 -0
  105. package/src/utils/parser.ts +245 -0
  106. package/src/utils/precision.ts +217 -0
  107. package/src/utils/validation.ts +183 -0
  108. package/tsconfig.json +84 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 obnexusmk2
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,256 @@
1
+ # @obinexuscomputing/hypernum - Computing from the Heart
2
+
3
+ ![Logo ](./favicon.svg)
4
+
5
+ A comprehensive TypeScript/JavaScript library for handling large number operations with BigInt support.
6
+
7
+ ## Features
8
+
9
+ - High-precision arithmetic operations
10
+ - Bitwise operations
11
+ - Special mathematical functions (factorial, GCD, LCM, etc.)
12
+ - Advanced data structures for large number manipulation
13
+ - Configurable precision and overflow handling
14
+ - Type-safe implementation in TypeScript
15
+
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install @obinexuscomputing/hypernum
20
+ ```
21
+
22
+ ## Basic Usage
23
+
24
+ ```typescript
25
+ import { createHypernum } from '@obinexuscomputing/hypernum';
26
+
27
+ // Create a Hypernum instance with default configuration
28
+ const hypernum = createHypernum();
29
+
30
+ // Basic arithmetic operations
31
+ const sum = hypernum.add("12345678901234567890", "98765432109876543210");
32
+ const product = hypernum.multiply(2n, "1000000000000000000");
33
+ ```
34
+
35
+ ## Configuration
36
+
37
+ You can configure Hypernum with various options:
38
+
39
+ ```typescript
40
+ const customHypernum = createHypernum({
41
+ precision: 10, // Decimal precision
42
+ roundingMode: 'HALF_EVEN', // Rounding strategy
43
+ checkOverflow: true, // Enable overflow checking
44
+ maxSteps: 1000 // Maximum computation steps
45
+ });
46
+ ```
47
+
48
+ ## Core Operations
49
+
50
+ ### Arithmetic
51
+
52
+ ```typescript
53
+ const hypernum = createHypernum();
54
+
55
+ // Addition
56
+ const sum = hypernum.add(a, b);
57
+
58
+ // Subtraction
59
+ const difference = hypernum.subtract(a, b);
60
+
61
+ // Multiplication
62
+ const product = hypernum.multiply(a, b);
63
+
64
+ // Division
65
+ const quotient = hypernum.divide(a, b);
66
+
67
+ // Modulo
68
+ const remainder = hypernum.mod(a, b);
69
+ ```
70
+
71
+ ### Bitwise Operations
72
+
73
+ ```typescript
74
+ // Bitwise AND
75
+ const andResult = hypernum.and(x, y);
76
+
77
+ // Bitwise OR
78
+ const orResult = hypernum.or(x, y);
79
+
80
+ // Bitwise XOR
81
+ const xorResult = hypernum.xor(x, y);
82
+
83
+ // Bitwise NOT
84
+ const notResult = hypernum.not(x);
85
+ ```
86
+
87
+ ### Power Operations
88
+
89
+ ```typescript
90
+ // Power
91
+ const powered = hypernum.power(base, exponent);
92
+
93
+ // Square root
94
+ const sqrt = hypernum.sqrt(value);
95
+
96
+ // Nth root
97
+ const root = hypernum.nthRoot(value, n);
98
+ ```
99
+
100
+ ## Advanced Features
101
+
102
+ ### Data Structures
103
+
104
+ #### BigArray
105
+
106
+ A specialized array implementation for handling large numbers efficiently:
107
+
108
+ ```typescript
109
+ import { BigArray } from '@obinexuscomputing/hypernum';
110
+
111
+ const array = new BigArray<bigint>();
112
+ array.push(12345678901234567890n);
113
+ array.push(98765432109876543210n);
114
+
115
+ // Range queries
116
+ const max = array.queryRange(0, 1);
117
+ ```
118
+
119
+ #### NumberTree
120
+
121
+ An AVL tree implementation optimized for large number operations:
122
+
123
+ ```typescript
124
+ import { NumberTree } from '@obinexuscomputing/hypernum';
125
+
126
+ const tree = new NumberTree();
127
+ tree.insert(12345678901234567890n);
128
+ tree.insert(98765432109876543210n);
129
+
130
+ // Tree operations
131
+ const found = tree.find(12345678901234567890n);
132
+ const values = tree.traverse('inOrder');
133
+ ```
134
+
135
+ #### PowerTower
136
+
137
+ Handles power tower (tetration) computations:
138
+
139
+ ```typescript
140
+ import { PowerTower } from '@obinexuscomputing/hypernum';
141
+
142
+ const tower = new PowerTower();
143
+ tower.build(2n, 4); // Computes 2↑↑4
144
+ const result = tower.evaluate();
145
+ ```
146
+
147
+ #### AckermannStructure
148
+
149
+ Computes and manages Ackermann function values:
150
+
151
+ ```typescript
152
+ import { AckermannStructure } from '@obinexuscomputing/hypernum';
153
+
154
+ const ackermann = new AckermannStructure();
155
+ const result = ackermann.computeAckermann(3, 2);
156
+ ```
157
+
158
+ ### Special Functions
159
+
160
+ ```typescript
161
+ // Greatest Common Divisor
162
+ const gcd = hypernum.gcd(48n, 18n);
163
+
164
+ // Least Common Multiple
165
+ const lcm = hypernum.lcm(48n, 18n);
166
+
167
+ // Factorial
168
+ import { factorial } from '@obinexuscomputing/hypernum';
169
+ const fact = factorial(10n);
170
+
171
+ // Binomial coefficient
172
+ import { binomial } from '@obinexuscomputing/hypernum';
173
+ const combination = binomial(10n, 5n);
174
+ ```
175
+
176
+ ### Number Format Conversions
177
+
178
+ ```typescript
179
+ import {
180
+ toBinary,
181
+ toHexadecimal,
182
+ toRoman,
183
+ fromRoman
184
+ } from '@obinexuscomputing/hypernum';
185
+
186
+ // Convert to different bases
187
+ const binary = toBinary(123456789n);
188
+ const hex = toHexadecimal(123456789n);
189
+
190
+ // Roman numeral conversion
191
+ const roman = toRoman(3549);
192
+ const number = fromRoman("MMMDXLIX");
193
+ ```
194
+
195
+ ## Error Handling
196
+
197
+ The library provides specific error types for different scenarios:
198
+
199
+ ```typescript
200
+ import {
201
+ HypernumError,
202
+ OverflowError,
203
+ ValidationError
204
+ } from '@obinexuscomputing/hypernum';
205
+
206
+ try {
207
+ const result = hypernum.power(2n, 1000n);
208
+ } catch (error) {
209
+ if (error instanceof OverflowError) {
210
+ console.error('Computation would overflow');
211
+ } else if (error instanceof ValidationError) {
212
+ console.error('Invalid input values');
213
+ }
214
+ }
215
+ ```
216
+
217
+ ## Performance Considerations
218
+
219
+ - Use BigInt literals (with 'n' suffix) for direct number input
220
+ - Enable overflow checking only when necessary
221
+ - Configure precision based on actual requirements
222
+ - Use appropriate data structures for your use case
223
+ - Consider using the built-in caching mechanisms for repeated computations
224
+
225
+ ## Type Safety
226
+
227
+ The library is written in TypeScript and provides full type definitions:
228
+
229
+ ```typescript
230
+ import type {
231
+ HypernumConfig,
232
+ NumericInput,
233
+ OperationOptions
234
+ } from '@obinexuscomputing/hypernum';
235
+
236
+ // Type-safe configuration
237
+ const config: HypernumConfig = {
238
+ precision: 10,
239
+ checkOverflow: true
240
+ };
241
+
242
+ // Type-safe numeric input
243
+ const input: NumericInput = "12345678901234567890";
244
+ ```
245
+
246
+ ## Environment Support
247
+
248
+ - Node.js ≥ 16.0.0
249
+ - Modern browsers with BigInt support
250
+ - TypeScript ≥ 4.5.0
251
+
252
+ ## License
253
+
254
+ ISC License
255
+
256
+ For more information, visit the [GitHub repository](https://github.com/obinexuscomputing/hypernum).