@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
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Interface for power tower computation options
3
+ */
4
+ interface PowerTowerOptions {
5
+ maxHeight?: number;
6
+ maxValue?: bigint;
7
+ checkOverflow?: boolean;
8
+ precision?: number;
9
+ }
10
+ /**
11
+ * Class representing a power tower (tetration) computation structure
12
+ * Handles expressions of the form: a↑↑b = a^(a^(a^...)) (b times)
13
+ */
14
+ export declare class PowerTower {
15
+ private readonly options;
16
+ private head;
17
+ private tail;
18
+ private size;
19
+ constructor(options?: PowerTowerOptions);
20
+ /**
21
+ * Creates a new power tower node
22
+ */
23
+ private createNode;
24
+ /**
25
+ * Validates power tower height
26
+ */
27
+ private validateHeight;
28
+ /**
29
+ * Validates value for computation
30
+ */
31
+ private validateValue;
32
+ /**
33
+ * Computes power with overflow checking
34
+ */
35
+ private computePower;
36
+ /**
37
+ * Builds a power tower of specified height with given base
38
+ */
39
+ build(base: bigint | number | string, height: number): void;
40
+ /**
41
+ * Evaluates the power tower up to specified height
42
+ */
43
+ evaluate(height?: number): bigint;
44
+ /**
45
+ * Gets the current height of the power tower
46
+ */
47
+ getHeight(): number;
48
+ /**
49
+ * Checks if the tower can be evaluated to a given height
50
+ */
51
+ isComputable(height?: number): boolean;
52
+ /**
53
+ * Gets the computation state at each level
54
+ */
55
+ getState(): {
56
+ height: number;
57
+ value: bigint;
58
+ evaluated: boolean;
59
+ }[];
60
+ /**
61
+ * Clears the power tower
62
+ */
63
+ clear(): void;
64
+ /**
65
+ * Gets the maximum computationally feasible height for a given base
66
+ */
67
+ static getMaxFeasibleHeight(base: bigint | number | string): number;
68
+ /**
69
+ * Creates a string representation of the power tower
70
+ */
71
+ toString(): string;
72
+ }
73
+ export default PowerTower;
74
+ //# sourceMappingURL=power-tower.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"power-tower.d.ts","sourceRoot":"","sources":["../../../src/structures/power-tower.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,UAAU,iBAAiB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAuBD;;;GAGG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8B;IACtD,OAAO,CAAC,IAAI,CAAwB;IACpC,OAAO,CAAC,IAAI,CAAwB;IACpC,OAAO,CAAC,IAAI,CAAS;gBAET,OAAO,GAAE,iBAAsB;IAO3C;;OAEG;IACH,OAAO,CAAC,UAAU;IAUlB;;OAEG;IACH,OAAO,CAAC,cAAc;IAStB;;OAEG;IACH,OAAO,CAAC,aAAa;IAOrB;;OAEG;IACH,OAAO,CAAC,YAAY;IAwBpB;;OAEG;IACI,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAqBlE;;OAEG;IACI,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM;IAmCxC;;OAEG;IACI,SAAS,IAAI,MAAM;IAI1B;;OAEG;IACI,YAAY,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO;IA8B7C;;OAEG;IACI,QAAQ,IAAI;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,OAAO,CAAA;KAAE,EAAE;IAgB1E;;OAEG;IACI,KAAK,IAAI,IAAI;IAMpB;;OAEG;WACW,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM;IAY1E;;OAEG;IACI,QAAQ,IAAI,MAAM;CAe1B;AAED,eAAe,UAAU,CAAC"}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Formatting utilities for Hypernum library
3
+ * Provides functions for formatting large numbers and converting between different representations
4
+ */
5
+ export interface FormatOptions {
6
+ notation?: 'standard' | 'scientific' | 'engineering' | 'compact';
7
+ precision?: number;
8
+ grouping?: boolean;
9
+ groupSize?: number;
10
+ decimalSeparator?: string;
11
+ groupSeparator?: string;
12
+ }
13
+ export interface ScientificNotation {
14
+ coefficient: string;
15
+ exponent: number;
16
+ }
17
+ export interface ScientificNotation {
18
+ coefficient: string;
19
+ exponent: number;
20
+ }
21
+ /**
22
+ * Formats a BigInt value according to specified options
23
+ */
24
+ export declare const formatBigInt: (value: bigint, options?: FormatOptions) => string;
25
+ /**
26
+ * Parses a formatted string back to BigInt
27
+ */
28
+ export declare const parseBigIntString: (str: string, options?: FormatOptions) => bigint;
29
+ /**
30
+ * Normalizes a string representation for comparison
31
+ */
32
+ export declare const normalizeNumberString: (str: string) => string;
33
+ /**
34
+ * Formats a number for display in a tree structure
35
+ */
36
+ export declare const formatTreeValue: (value: bigint, depth?: number) => string;
37
+ /**
38
+ * Formats a range of numbers for display
39
+ */
40
+ export declare const formatRange: (start: bigint, end: bigint, options?: FormatOptions) => string;
41
+ /**
42
+ * Formats a percentage
43
+ */
44
+ export declare const formatPercentage: (value: bigint, total: bigint, precision?: number) => string;
45
+ //# sourceMappingURL=formatting.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatting.d.ts","sourceRoot":"","sources":["../../../src/utils/formatting.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,UAAU,GAAG,YAAY,GAAG,aAAa,GAAG,SAAS,CAAC;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,kBAAkB;IACjC,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAYD;;GAEG;AACH,eAAO,MAAM,YAAY,UAAW,MAAM,YAAW,aAAa,KAAQ,MAwBzE,CAAC;AAoGF;;GAEG;AACH,eAAO,MAAM,iBAAiB,QAAS,MAAM,YAAW,aAAa,KAAQ,MAiC5E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,qBAAqB,QAAS,MAAM,KAAG,MAanD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,UAAW,MAAM,UAAS,MAAM,KAAO,MAGlE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,WAAW,UAAW,MAAM,OAAO,MAAM,YAAW,aAAa,KAAQ,MAErF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,UAAW,MAAM,SAAS,MAAM,cAAa,MAAM,KAAO,MAOtF,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './validation';
2
+ export * from './precision';
3
+ export * from './formatting';
4
+ export * from './parser';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Parser utilities for Hypernum library
3
+ * Provides functions for parsing various number formats and notations
4
+ */
5
+ import { RoundingMode } from './precision';
6
+ /**
7
+ * Supported number format types
8
+ */
9
+ export declare enum NumberFormat {
10
+ STANDARD = "STANDARD",// Regular decimal notation
11
+ SCIENTIFIC = "SCIENTIFIC",// Scientific notation (e.g., 1.23e4)
12
+ ENGINEERING = "ENGINEERING",// Engineering notation (e.g., 1.23e6)
13
+ COMPACT = "COMPACT",// Compact notation with suffixes (e.g., 1.23M)
14
+ FRACTION = "FRACTION",// Fractional notation (e.g., 1/3)
15
+ PERCENTAGE = "PERCENTAGE",// Percentage notation (e.g., 12.3%)
16
+ HEXADECIMAL = "HEXADECIMAL",// Hex notation (e.g., 0xFF)
17
+ BINARY = "BINARY",// Binary notation (e.g., 0b1010)
18
+ OCTAL = "OCTAL"
19
+ }
20
+ /**
21
+ * Options for parsing numbers
22
+ */
23
+ export interface ParseOptions {
24
+ format?: NumberFormat;
25
+ base?: number;
26
+ allowFractions?: boolean;
27
+ rounding?: RoundingMode;
28
+ precision?: number;
29
+ strict?: boolean;
30
+ }
31
+ /**
32
+ * Parse any supported number format to BigInt
33
+ */
34
+ export declare const parseNumber: (input: string, options?: ParseOptions) => bigint;
35
+ /**
36
+ * Detect number format from string
37
+ */
38
+ export declare const detectNumberFormat: (str: string) => NumberFormat;
39
+ //# sourceMappingURL=parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../../src/utils/parser.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C;;GAEG;AACH,oBAAY,YAAY;IACtB,QAAQ,aAAa,CAAU,2BAA2B;IAC1D,UAAU,eAAe,CAAM,qCAAqC;IACpE,WAAW,gBAAgB,CAAI,sCAAsC;IACrE,OAAO,YAAY,CAAW,+CAA+C;IAC7E,QAAQ,aAAa,CAAS,kCAAkC;IAChE,UAAU,eAAe,CAAK,oCAAoC;IAClE,WAAW,gBAAgB,CAAG,4BAA4B;IAC1D,MAAM,WAAW,CAAY,iCAAiC;IAC9D,KAAK,UAAU;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,EAAE,YAAY,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAWD;;GAEG;AACH,eAAO,MAAM,WAAW,UAAW,MAAM,YAAW,YAAY,KAAQ,MAoCvE,CAAC;AAiJF;;GAEG;AACH,eAAO,MAAM,kBAAkB,QAAS,MAAM,KAAG,YAahD,CAAC"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Precision utilities for Hypernum library
3
+ * Provides functions for handling decimal precision and rounding operations
4
+ */
5
+ /**
6
+ * Rounding modes for decimal operations
7
+ */
8
+ export declare enum RoundingMode {
9
+ FLOOR = "FLOOR",// Round towards negative infinity
10
+ CEIL = "CEIL",// Round towards positive infinity
11
+ DOWN = "DOWN",// Round towards zero
12
+ UP = "UP",// Round away from zero
13
+ HALF_EVEN = "HALF_EVEN",// Round to nearest even number when tied (Banker's rounding)
14
+ HALF_UP = "HALF_UP",// Round up when tied
15
+ HALF_DOWN = "HALF_DOWN"
16
+ }
17
+ /**
18
+ * Scale a bigint by a power of 10
19
+ */
20
+ export declare const scaleByPowerOfTen: (value: bigint, power: number) => bigint;
21
+ /**
22
+ * Round a number according to specified mode and precision
23
+ */
24
+ export declare const round: (value: bigint, precision?: number, mode?: RoundingMode) => bigint;
25
+ /**
26
+ * Calculate precision required to represent a number without loss
27
+ */
28
+ export declare const calculateRequiredPrecision: (value: bigint) => number;
29
+ /**
30
+ * Normalize two numbers to the same precision
31
+ */
32
+ export declare const normalizePrecision: (a: bigint, b: bigint, precisionA: number, precisionB: number) => [bigint, bigint];
33
+ /**
34
+ * Scale a division operation to achieve desired precision
35
+ */
36
+ export declare const scaledDivision: (numerator: bigint, denominator: bigint, precision: number, roundingMode?: RoundingMode) => bigint;
37
+ /**
38
+ * Calculate the number of significant digits
39
+ */
40
+ export declare const significantDigits: (value: bigint) => number;
41
+ /**
42
+ * Truncate to specified number of significant digits
43
+ */
44
+ export declare const truncateToSignificantDigits: (value: bigint, digits: number, roundingMode?: RoundingMode) => bigint;
45
+ /**
46
+ * Check if two numbers are equal within a specified precision
47
+ */
48
+ export declare const equalWithinPrecision: (a: bigint, b: bigint, precision: number) => boolean;
49
+ /**
50
+ * Get the fractional part of a number at a given precision
51
+ */
52
+ export declare const getFractionalPart: (value: bigint, precision: number) => bigint;
53
+ /**
54
+ * Format a number with exact precision (no rounding)
55
+ */
56
+ export declare const toExactPrecision: (value: bigint, precision: number) => string;
57
+ //# sourceMappingURL=precision.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"precision.d.ts","sourceRoot":"","sources":["../../../src/utils/precision.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,oBAAY,YAAY;IACtB,KAAK,UAAU,CAAY,kCAAkC;IAC7D,IAAI,SAAS,CAAc,kCAAkC;IAC7D,IAAI,SAAS,CAAc,qBAAqB;IAChD,EAAE,OAAO,CAAkB,uBAAuB;IAClD,SAAS,cAAc,CAAI,6DAA6D;IACxF,OAAO,YAAY,CAAQ,qBAAqB;IAChD,SAAS,cAAc;CACxB;AAED;;GAEG;AACH,eAAO,MAAM,iBAAiB,UAAW,MAAM,SAAS,MAAM,KAAG,MAMhE,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,KAAK,UACT,MAAM,cACF,MAAM,SACX,YAAY,KACjB,MAyCF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,0BAA0B,UAAW,MAAM,KAAG,MAM1D,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,MAC1B,MAAM,KACN,MAAM,cACG,MAAM,cACN,MAAM,KACjB,CAAC,MAAM,EAAE,MAAM,CAOjB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,cAAc,cACd,MAAM,eACJ,MAAM,aACR,MAAM,iBACH,YAAY,KACzB,MAcF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,UAAW,MAAM,KAAG,MAQjD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,2BAA2B,UAC/B,MAAM,UACL,MAAM,iBACA,YAAY,KACzB,MAaF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB,MAC5B,MAAM,KACN,MAAM,aACE,MAAM,KAChB,OAIF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iBAAiB,UACrB,MAAM,aACF,MAAM,KAChB,MAKF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,UAAW,MAAM,aAAa,MAAM,KAAG,MAmBnE,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Validation utilities for Hypernum library
3
+ * Provides type checking and validation functions for large number operations
4
+ */
5
+ export declare class ValidationError extends Error {
6
+ constructor(message: string);
7
+ }
8
+ export declare class OverflowError extends Error {
9
+ constructor(message: string);
10
+ }
11
+ export declare const isBigInt: (value: unknown) => value is bigint;
12
+ export declare const isValidNumberString: (value: string) => boolean;
13
+ export declare const isValidNumber: (value: unknown) => value is number;
14
+ export declare const toBigInt: (value: unknown) => bigint;
15
+ export declare const validateRange: (value: bigint, min?: bigint, max?: bigint) => void;
16
+ export declare const checkAdditionOverflow: (a: bigint, b: bigint) => void;
17
+ export declare const checkMultiplicationOverflow: (a: bigint, b: bigint) => void;
18
+ export declare const checkPowerOverflow: (base: bigint, exponent: bigint) => void;
19
+ export declare const validateArrayLength: (length: number) => void;
20
+ export declare const validateArrayIndex: (index: number, length: number) => void;
21
+ export declare const validateTreeNode: (value: unknown) => void;
22
+ export declare const validateHeapProperty: <T>(value: T, parent: T | undefined, comparator: (a: T, b: T) => -1 | 0 | 1, isMinHeap: boolean) => void;
23
+ export declare const validateAckermannInput: (m: number, n: number) => void;
24
+ export declare const isInRange: (value: bigint, min: bigint, max: bigint) => boolean;
25
+ export declare const isPowerOfTwo: (value: bigint) => boolean;
26
+ export declare const validatePositive: (value: bigint) => void;
27
+ export declare const validateNonNegative: (value: bigint) => void;
28
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/utils/validation.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,qBAAa,eAAgB,SAAQ,KAAK;gBAC1B,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,OAAO,EAAE,MAAM;CAI5B;AAGD,eAAO,MAAM,QAAQ,UAAW,OAAO,oBAEtC,CAAC;AAEF,eAAO,MAAM,mBAAmB,UAAW,MAAM,KAAG,OAEnD,CAAC;AAEF,eAAO,MAAM,aAAa,UAAW,OAAO,oBAE3C,CAAC;AAGF,eAAO,MAAM,QAAQ,UAAW,OAAO,KAAG,MAoBzC,CAAC;AAGF,eAAO,MAAM,aAAa,UAAW,MAAM,QAAQ,MAAM,QAAQ,MAAM,KAAG,IAOzE,CAAC;AAGF,eAAO,MAAM,qBAAqB,MAAO,MAAM,KAAK,MAAM,KAAG,IAQ5D,CAAC;AAEF,eAAO,MAAM,2BAA2B,MAAO,MAAM,KAAK,MAAM,KAAG,IAUlE,CAAC;AAEF,eAAO,MAAM,kBAAkB,SAAU,MAAM,YAAY,MAAM,KAAG,IAanE,CAAC;AAGF,eAAO,MAAM,mBAAmB,WAAY,MAAM,KAAG,IAOpD,CAAC;AAEF,eAAO,MAAM,kBAAkB,UAAW,MAAM,UAAU,MAAM,KAAG,IAOlE,CAAC;AAGF,eAAO,MAAM,gBAAgB,UAAW,OAAO,KAAG,IAMjD,CAAC;AAGF,eAAO,MAAM,oBAAoB,aACxB,CAAC,UACA,CAAC,GAAG,SAAS,cACT,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,aAC3B,OAAO,KACjB,IAUF,CAAC;AAGF,eAAO,MAAM,sBAAsB,MAAO,MAAM,KAAK,MAAM,KAAG,IAU7D,CAAC;AAGF,eAAO,MAAM,SAAS,UAAW,MAAM,OAAO,MAAM,OAAO,MAAM,KAAG,OAEnE,CAAC;AAEF,eAAO,MAAM,YAAY,UAAW,MAAM,KAAG,OAE5C,CAAC;AAEF,eAAO,MAAM,gBAAgB,UAAW,MAAM,KAAG,IAIhD,CAAC;AAEF,eAAO,MAAM,mBAAmB,UAAW,MAAM,KAAG,IAInD,CAAC"}
package/package.json ADDED
@@ -0,0 +1,164 @@
1
+ {
2
+ "name": "@obinexusmk2/hypernum",
3
+ "version": "0.1.0",
4
+ "description": "A high-precision mathematics library for large number operations with BigInt support, custom data structures, and comprehensive type safety",
5
+ "main": "dist/index.cjs",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "browser": "dist/index.umd.js",
9
+ "unpkg": "dist/index.umd.js",
10
+ "cdn": "dist/index.umd.js",
11
+ "sideEffects": false,
12
+ "type": "module",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.js",
17
+ "require": "./dist/index.cjs",
18
+ "default": "./dist/index.js"
19
+ },
20
+ "./package.json": "./package.json"
21
+ },
22
+ "files": [
23
+ "dist",
24
+ "src",
25
+ "README.md",
26
+ "LICENSE",
27
+ "CHANGELOG.md",
28
+ "rollup.config.js",
29
+ "tsconfig.json"
30
+ ],
31
+ "scripts": {
32
+ "build": "rollup -c",
33
+ "dev": "rollup -c -w",
34
+ "clean": "rimraf dist coverage .nyc_output",
35
+ "prebuild": "npm run clean",
36
+ "prepack": "npm run build",
37
+ "test": "jest --coverage",
38
+ "test:watch": "jest --watch",
39
+ "test:ci": "jest --ci --coverage --runInBand",
40
+ "lint": "eslint src --ext .ts",
41
+ "lint:fix": "eslint src --ext .ts --fix",
42
+ "format": "prettier --write \"src/**/*.ts\"",
43
+ "prepare": "npm run build",
44
+ "docs": "typedoc --out docs src",
45
+ "benchmark": "ts-node benchmark/index.ts",
46
+ "release": "standard-version",
47
+ "commit": "git-cz"
48
+ },
49
+ "keywords": [
50
+ "bigint",
51
+ "large-numbers",
52
+ "arithmetic",
53
+ "mathematics",
54
+ "computation",
55
+ "data-structures",
56
+ "typescript",
57
+ "javascript",
58
+ "number-theory",
59
+ "high-precision",
60
+ "ackermann",
61
+ "tetration",
62
+ "avl-tree",
63
+ "power-tower"
64
+ ],
65
+ "author": "Obi Nexus Computing <contact@obinexusmk2.com> (https://obinexusmk2.com)",
66
+ "funding": {
67
+ "type": "individual",
68
+ "url": "https://www.buymeacoffee.com/obinexusmk2"
69
+ },
70
+ "license": "ISC",
71
+ "repository": {
72
+ "type": "git",
73
+ "url": "git+https://github.com/obinexusmk2/hypernum.git"
74
+ },
75
+ "bugs": {
76
+ "url": "https://github.com/obinexusmk2/hypernum/issues"
77
+ },
78
+ "homepage": "https://obinexusmk2.github.io/hypernum",
79
+ "dependencies": {
80
+ "find-up": "^5.0.0",
81
+ "rc": "^1.2.8",
82
+ "tslib": "^2.6.0"
83
+ },
84
+ "devDependencies": {
85
+ "@commitlint/cli": "^18.0.0",
86
+ "@commitlint/config-conventional": "^18.0.0",
87
+ "@rollup/plugin-alias": "^5.0.0",
88
+ "@rollup/plugin-commonjs": "^29.0.0",
89
+ "@rollup/plugin-json": "^6.0.0",
90
+ "@rollup/plugin-node-resolve": "^15.0.0",
91
+ "@rollup/plugin-terser": "^0.4.4",
92
+ "@types/jest": "^29.0.0",
93
+ "@types/node": "^20.0.0",
94
+ "@types/rc": "^1.2.1",
95
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
96
+ "@typescript-eslint/parser": "^6.0.0",
97
+ "commitizen": "^4.2.4",
98
+ "cz-conventional-changelog": "^3.3.0",
99
+ "eslint": "^8.0.0",
100
+ "eslint-config-prettier": "^6.15.0",
101
+ "eslint-plugin-prettier": "^2.7.0",
102
+ "husky": "^8.0.0",
103
+ "jest": "^19.0.2",
104
+ "lint-staged": "^15.0.0",
105
+ "prettier": "^3.0.0",
106
+ "rimraf": "^5.0.0",
107
+ "rollup": "^4.0.0",
108
+ "rollup-plugin-copy": "^2.0.1",
109
+ "rollup-plugin-dts": "^6.0.0",
110
+ "rollup-plugin-typescript2": "^0.36.0",
111
+ "standard-version": "^9.5.0",
112
+ "ts-jest": "^19.0.14",
113
+ "ts-node": "^10.0.0",
114
+ "typedoc": "^0.28.17",
115
+ "typescript": "^5.0.0"
116
+ },
117
+ "peerDependencies": {
118
+ "typescript": ">=4.5.0"
119
+ },
120
+ "engines": {
121
+ "node": ">=16.0.0"
122
+ },
123
+ "config": {
124
+ "commitizen": {
125
+ "path": "cz-conventional-changelog"
126
+ }
127
+ },
128
+ "lint-staged": {
129
+ "*.ts": [
130
+ "eslint --fix",
131
+ "prettier --write"
132
+ ]
133
+ },
134
+ "jest": {
135
+ "preset": "ts-jest",
136
+ "testEnvironment": "node",
137
+ "testMatch": [
138
+ "<rootDir>/src/**/*.test.ts"
139
+ ],
140
+ "collectCoverageFrom": [
141
+ "src/**/*.ts",
142
+ "!src/**/*.d.ts",
143
+ "!src/**/*.test.ts"
144
+ ],
145
+ "coverageThreshold": {
146
+ "global": {
147
+ "branches": 80,
148
+ "functions": 80,
149
+ "lines": 80,
150
+ "statements": 80
151
+ }
152
+ }
153
+ },
154
+ "prettier": {
155
+ "semi": true,
156
+ "singleQuote": true,
157
+ "trailingComma": "es5",
158
+ "printWidth": 80
159
+ },
160
+ "directories": {
161
+ "doc": "docs",
162
+ "example": "examples"
163
+ }
164
+ }
@@ -0,0 +1,162 @@
1
+ import typescript from 'rollup-plugin-typescript2';
2
+ import resolve from '@rollup/plugin-node-resolve';
3
+ import commonjs from '@rollup/plugin-commonjs';
4
+ import terser from '@rollup/plugin-terser';
5
+ import dts from 'rollup-plugin-dts';
6
+ import alias from '@rollup/plugin-alias';
7
+ import path from 'path';
8
+ import { readFileSync } from 'fs';
9
+ import { fileURLToPath } from 'url';
10
+
11
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
12
+ const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8'));
13
+
14
+ const banner = `/**
15
+ * ${pkg.name} v${pkg.version}
16
+ * Precison at Scale
17
+ *${pkg.description}
18
+ * @license ISC
19
+ */`;
20
+
21
+ // External dependencies
22
+ const external = [
23
+ ...Object.keys(pkg.dependencies || {}),
24
+ ...Object.keys(pkg.peerDependencies || {}),
25
+ 'tslib'
26
+ ];
27
+
28
+ // Alias configurations for hypernum specific paths
29
+ const srcAliases = [
30
+ { find: '@', replacement: path.resolve(__dirname, 'src') },
31
+ { find: '@core', replacement: path.resolve(__dirname, 'src/core') },
32
+ { find: '@operations', replacement: path.resolve(__dirname, 'src/operations') },
33
+ { find: '@structures', replacement: path.resolve(__dirname, 'src/structures') },
34
+ {find: '@storage', replacement: path.resolve(__dirname, 'src/storage') },
35
+ { find: '@utils', replacement: path.resolve(__dirname, 'src/utils') },
36
+ { find: '@types', replacement: path.resolve(__dirname, 'src/types') }
37
+ ];
38
+
39
+ // TypeScript configuration optimized for BigInt operations
40
+ const typeScriptConfig = {
41
+ tsconfig: './tsconfig.json',
42
+ clean: true,
43
+ useTsconfigDeclarationDir: true,
44
+ tsconfigOverride: {
45
+ compilerOptions: {
46
+ declaration: true,
47
+ declarationDir: './dist/types',
48
+ sourceMap: true,
49
+ module: 'esnext',
50
+ moduleResolution: 'node',
51
+ target: 'es2020', // Ensures BigInt compatibility
52
+ lib: ['es2020', 'dom'],
53
+ allowSyntheticDefaultImports: true
54
+ },
55
+ exclude: ['**/__tests__/**', '**/*.test.ts', 'src/**/*.spec.ts']
56
+ }
57
+ };
58
+
59
+ // Base plugins configuration
60
+ const basePlugins = [
61
+ alias({ entries: srcAliases }),
62
+ resolve({
63
+ browser: true,
64
+ preferBuiltins: true,
65
+ mainFields: ['module', 'browser', 'main'],
66
+ extensions: ['.ts', '.js']
67
+ }),
68
+ commonjs({
69
+ include: /node_modules/,
70
+ requireReturnsDefault: 'auto'
71
+ }),
72
+ typescript(typeScriptConfig)
73
+ ];
74
+
75
+ // Base output configuration
76
+ const baseOutput = {
77
+ banner,
78
+ sourcemap: true,
79
+ exports: 'named'
80
+ };
81
+
82
+ // Main builds configuration
83
+ const mainBuilds = [
84
+ // UMD build
85
+ {
86
+ input: 'src/index.ts',
87
+ output: {
88
+ ...baseOutput,
89
+ file: 'dist/index.umd.js',
90
+ format: 'umd',
91
+ name: 'Hypernum',
92
+ globals: {
93
+ tslib: 'tslib'
94
+ }
95
+ },
96
+ external,
97
+ plugins: [
98
+ ...basePlugins,
99
+ terser({
100
+ output: {
101
+ comments: (node, comment) =>
102
+ comment.type === 'comment2' && /@license/i.test(comment.value)
103
+ }
104
+ })
105
+ ]
106
+ },
107
+ // ESM build
108
+ {
109
+ input: 'src/index.ts',
110
+ output: {
111
+ ...baseOutput,
112
+ file: 'dist/index.js',
113
+ format: 'esm'
114
+ },
115
+ external,
116
+ plugins: basePlugins
117
+ },
118
+ // CommonJS build
119
+ {
120
+ input: 'src/index.ts',
121
+ output: {
122
+ ...baseOutput,
123
+ file: 'dist/index.cjs',
124
+ format: 'cjs'
125
+ },
126
+ external,
127
+ plugins: basePlugins
128
+ }
129
+ ];
130
+
131
+ // Types build configuration
132
+ const typesBuild = {
133
+ input: 'src/index.ts',
134
+ output: {
135
+ file: 'dist/index.d.ts',
136
+ format: 'es'
137
+ },
138
+ external: [
139
+ ...external,
140
+ /\.css$/,
141
+ /@types\/.*/,
142
+ /@core\/.*/,
143
+ /@operations\/.*/,
144
+ /@structures\/.*/,
145
+ /@utils\/.*/,
146
+ /@\/.*/
147
+ ],
148
+ plugins: [
149
+ alias({
150
+ entries: srcAliases.map(entry => ({
151
+ ...entry,
152
+ replacement: entry.replacement.replace('/src/', '/dist/types/')
153
+ }))
154
+ }),
155
+ dts()
156
+ ]
157
+ };
158
+
159
+ export default [
160
+ ...mainBuilds,
161
+ typesBuild
162
+ ];