@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.
- package/LICENSE +21 -0
- package/README.md +256 -0
- package/dist/index.cjs +3425 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +1449 -0
- package/dist/index.js +3284 -0
- package/dist/index.js.map +1 -0
- package/dist/index.umd.js +8 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/types/config/config-loader.d.ts +56 -0
- package/dist/types/config/config-loader.d.ts.map +1 -0
- package/dist/types/config/config-parser.d.ts +28 -0
- package/dist/types/config/config-parser.d.ts.map +1 -0
- package/dist/types/config/config-resolver.d.ts +21 -0
- package/dist/types/config/config-resolver.d.ts.map +1 -0
- package/dist/types/config/config-source.d.ts +27 -0
- package/dist/types/config/config-source.d.ts.map +1 -0
- package/dist/types/config/index.d.ts +68 -0
- package/dist/types/config/index.d.ts.map +1 -0
- package/dist/types/core/common.d.ts +169 -0
- package/dist/types/core/common.d.ts.map +1 -0
- package/dist/types/core/config.d.ts +197 -0
- package/dist/types/core/config.d.ts.map +1 -0
- package/dist/types/core/constants.d.ts +88 -0
- package/dist/types/core/constants.d.ts.map +1 -0
- package/dist/types/core/errors.d.ts +97 -0
- package/dist/types/core/errors.d.ts.map +1 -0
- package/dist/types/core/hypernum.d.ts +60 -0
- package/dist/types/core/hypernum.d.ts.map +1 -0
- package/dist/types/core/index.d.ts +6 -0
- package/dist/types/core/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +33 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/operations/arithmetic.d.ts +72 -0
- package/dist/types/operations/arithmetic.d.ts.map +1 -0
- package/dist/types/operations/bitwise.d.ts +98 -0
- package/dist/types/operations/bitwise.d.ts.map +1 -0
- package/dist/types/operations/comparison.d.ts +94 -0
- package/dist/types/operations/comparison.d.ts.map +1 -0
- package/dist/types/operations/conversion.d.ts +79 -0
- package/dist/types/operations/conversion.d.ts.map +1 -0
- package/dist/types/operations/factorial.d.ts +58 -0
- package/dist/types/operations/factorial.d.ts.map +1 -0
- package/dist/types/operations/index.d.ts +6 -0
- package/dist/types/operations/index.d.ts.map +1 -0
- package/dist/types/operations/power.d.ts +49 -0
- package/dist/types/operations/power.d.ts.map +1 -0
- package/dist/types/storage/Heap.d.ts +95 -0
- package/dist/types/storage/Heap.d.ts.map +1 -0
- package/dist/types/storage/index.d.ts +2 -0
- package/dist/types/storage/index.d.ts.map +1 -0
- package/dist/types/structures/ackermann.d.ts +74 -0
- package/dist/types/structures/ackermann.d.ts.map +1 -0
- package/dist/types/structures/big-array.d.ts +102 -0
- package/dist/types/structures/big-array.d.ts.map +1 -0
- package/dist/types/structures/index.d.ts +5 -0
- package/dist/types/structures/index.d.ts.map +1 -0
- package/dist/types/structures/number-tree.d.ts +114 -0
- package/dist/types/structures/number-tree.d.ts.map +1 -0
- package/dist/types/structures/power-tower.d.ts +74 -0
- package/dist/types/structures/power-tower.d.ts.map +1 -0
- package/dist/types/utils/formatting.d.ts +45 -0
- package/dist/types/utils/formatting.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +5 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/parser.d.ts +39 -0
- package/dist/types/utils/parser.d.ts.map +1 -0
- package/dist/types/utils/precision.d.ts +57 -0
- package/dist/types/utils/precision.d.ts.map +1 -0
- package/dist/types/utils/validation.d.ts +28 -0
- package/dist/types/utils/validation.d.ts.map +1 -0
- package/package.json +164 -0
- package/rollup.config.js +162 -0
- package/src/config/config-loader.ts +226 -0
- package/src/config/config-parser.ts +161 -0
- package/src/config/config-resolver.ts +52 -0
- package/src/config/config-source.ts +32 -0
- package/src/config/index.ts +159 -0
- package/src/core/common.ts +185 -0
- package/src/core/config.ts +393 -0
- package/src/core/constants.ts +102 -0
- package/src/core/errors.ts +203 -0
- package/src/core/hypernum.ts +241 -0
- package/src/core/index.ts +5 -0
- package/src/index.ts +183 -0
- package/src/operations/arithmetic.ts +333 -0
- package/src/operations/bitwise.ts +367 -0
- package/src/operations/comparison.ts +272 -0
- package/src/operations/conversion.ts +400 -0
- package/src/operations/factorial.ts +279 -0
- package/src/operations/index.ts +5 -0
- package/src/operations/power.ts +316 -0
- package/src/storage/Heap.ts +238 -0
- package/src/storage/index.ts +1 -0
- package/src/structures/ackermann.ts +233 -0
- package/src/structures/big-array.ts +306 -0
- package/src/structures/index.ts +4 -0
- package/src/structures/number-tree.ts +404 -0
- package/src/structures/power-tower.ts +278 -0
- package/src/types/common.d.ts +357 -0
- package/src/types/core.d.ts +161 -0
- package/src/types/index.d.ts +2 -0
- package/src/utils/formatting.ts +246 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/parser.ts +245 -0
- package/src/utils/precision.ts +217 -0
- package/src/utils/validation.ts +183 -0
- package/tsconfig.json +84 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Core constants for Hypernum library
|
|
3
|
+
* Defines fundamental values and limits used across the library
|
|
4
|
+
*/
|
|
5
|
+
export declare const MAX_SAFE_INTEGER: bigint;
|
|
6
|
+
export declare const MIN_SAFE_INTEGER: bigint;
|
|
7
|
+
export declare const MAX_PRECISION = 100;
|
|
8
|
+
export declare const MAX_COMPUTATION_STEPS = 1000;
|
|
9
|
+
export declare const MAX_BITS = 1024;
|
|
10
|
+
export declare const ZERO: bigint;
|
|
11
|
+
export declare const ONE: bigint;
|
|
12
|
+
export declare const TWO: bigint;
|
|
13
|
+
export declare const TEN: bigint;
|
|
14
|
+
export declare const NEGATIVE_ONE: bigint;
|
|
15
|
+
export declare const MAX_POWER_BASE: bigint;
|
|
16
|
+
export declare const MAX_POWER_EXPONENT: bigint;
|
|
17
|
+
export declare const MAX_TETRATION_HEIGHT: bigint;
|
|
18
|
+
export declare const MAX_FACTORIAL_INPUT: bigint;
|
|
19
|
+
export declare const DEFAULT_TREE_MAX_DEPTH = 1000;
|
|
20
|
+
export declare const DEFAULT_HEAP_INITIAL_CAPACITY = 16;
|
|
21
|
+
export declare const DEFAULT_ARRAY_GROWTH_FACTOR = 2;
|
|
22
|
+
export declare const MIN_ARRAY_CAPACITY = 16;
|
|
23
|
+
export declare const DEFAULT_DECIMAL_SEPARATOR = ".";
|
|
24
|
+
export declare const DEFAULT_GROUP_SEPARATOR = ",";
|
|
25
|
+
export declare const DEFAULT_GROUP_SIZE = 3;
|
|
26
|
+
export declare const MAX_GROUP_SIZE = 10;
|
|
27
|
+
export declare const MIN_ROMAN_VALUE = 1;
|
|
28
|
+
export declare const MAX_ROMAN_VALUE = 3999;
|
|
29
|
+
export declare const MAX_ACKERMANN_M = 4;
|
|
30
|
+
export declare const MAX_ACKERMANN_N = 1000;
|
|
31
|
+
export declare const DEFAULT_CACHE_SIZE = 1000;
|
|
32
|
+
export declare const MAX_CACHE_SIZE = 10000;
|
|
33
|
+
export declare const ERROR_MESSAGES: {
|
|
34
|
+
readonly OVERFLOW: "Operation would result in overflow";
|
|
35
|
+
readonly UNDERFLOW: "Operation would result in underflow";
|
|
36
|
+
readonly NEGATIVE_ROOT: "Cannot compute root of negative number";
|
|
37
|
+
readonly NEGATIVE_EXPONENT: "Negative exponents not supported for integers";
|
|
38
|
+
readonly DIVISION_BY_ZERO: "Division by zero";
|
|
39
|
+
readonly INVALID_PRECISION: "Precision must be non-negative and not exceed MAX_PRECISION";
|
|
40
|
+
readonly INVALID_BASE: "Base must be a positive integer";
|
|
41
|
+
readonly INVALID_ROMAN: "Invalid Roman numeral";
|
|
42
|
+
readonly COMPUTATION_LIMIT: "Computation exceeded maximum allowed steps";
|
|
43
|
+
readonly NEGATIVE_INDEX: "Array index cannot be negative";
|
|
44
|
+
readonly TREE_DEPTH_EXCEEDED: "Maximum tree depth exceeded";
|
|
45
|
+
readonly INVALID_HEAP_PROPERTY: "Heap property violation detected";
|
|
46
|
+
};
|
|
47
|
+
export declare const FEATURES: {
|
|
48
|
+
readonly OVERFLOW_CHECKING: true;
|
|
49
|
+
readonly AUTOMATIC_PRECISION: true;
|
|
50
|
+
readonly MEMOIZATION: true;
|
|
51
|
+
readonly TREE_BALANCING: true;
|
|
52
|
+
readonly DEBUG_MODE: false;
|
|
53
|
+
};
|
|
54
|
+
export declare const DEFAULT_OPTIONS: {
|
|
55
|
+
readonly precision: 0;
|
|
56
|
+
readonly roundingMode: "HALF_EVEN";
|
|
57
|
+
readonly checkOverflow: true;
|
|
58
|
+
readonly maxSteps: 1000;
|
|
59
|
+
readonly grouping: true;
|
|
60
|
+
readonly uppercase: false;
|
|
61
|
+
readonly cache: true;
|
|
62
|
+
};
|
|
63
|
+
export declare const NUMBER_UNITS: readonly [{
|
|
64
|
+
readonly value: 1n;
|
|
65
|
+
readonly symbol: "";
|
|
66
|
+
}, {
|
|
67
|
+
readonly value: 1000n;
|
|
68
|
+
readonly symbol: "K";
|
|
69
|
+
}, {
|
|
70
|
+
readonly value: 1000000n;
|
|
71
|
+
readonly symbol: "M";
|
|
72
|
+
}, {
|
|
73
|
+
readonly value: 1000000000n;
|
|
74
|
+
readonly symbol: "B";
|
|
75
|
+
}, {
|
|
76
|
+
readonly value: 1000000000000n;
|
|
77
|
+
readonly symbol: "T";
|
|
78
|
+
}, {
|
|
79
|
+
readonly value: 1000000000000000n;
|
|
80
|
+
readonly symbol: "Q";
|
|
81
|
+
}];
|
|
82
|
+
export declare const PERFORMANCE: {
|
|
83
|
+
readonly WARN_THRESHOLD_MS: 100;
|
|
84
|
+
readonly ERROR_THRESHOLD_MS: 1000;
|
|
85
|
+
readonly MAX_ARRAY_SIZE: 1000000;
|
|
86
|
+
readonly MAX_TREE_SIZE: 1000000;
|
|
87
|
+
};
|
|
88
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/core/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,eAAO,MAAM,gBAAgB,QAAkC,CAAC;AAChE,eAAO,MAA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WAAW;;;;;CAKd,CAAC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error types for Hypernum library
|
|
3
|
+
* Provides specific error classes for different types of errors that can occur
|
|
4
|
+
* during mathematical operations and data structure manipulations
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Base error class for Hypernum library
|
|
8
|
+
* All other error classes inherit from this
|
|
9
|
+
*/
|
|
10
|
+
export declare class HypernumError extends Error {
|
|
11
|
+
constructor(message: string);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Error for validation failures
|
|
15
|
+
*/
|
|
16
|
+
export declare class ValidationError extends HypernumError {
|
|
17
|
+
constructor(message: string);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Error for arithmetic overflow conditions
|
|
21
|
+
*/
|
|
22
|
+
export declare class OverflowError extends HypernumError {
|
|
23
|
+
constructor(message?: string);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Error for arithmetic underflow conditions
|
|
27
|
+
*/
|
|
28
|
+
export declare class UnderflowError extends HypernumError {
|
|
29
|
+
constructor(message?: string);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Error for division by zero
|
|
33
|
+
*/
|
|
34
|
+
export declare class DivisionByZeroError extends HypernumError {
|
|
35
|
+
constructor(message?: string);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Error for precision-related issues
|
|
39
|
+
*/
|
|
40
|
+
export declare class PrecisionError extends HypernumError {
|
|
41
|
+
constructor(message?: string);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Error for computation limits exceeded
|
|
45
|
+
*/
|
|
46
|
+
export declare class ComputationLimitError extends HypernumError {
|
|
47
|
+
constructor(message?: string);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Error for invalid operations on data structures
|
|
51
|
+
*/
|
|
52
|
+
export declare class DataStructureError extends HypernumError {
|
|
53
|
+
constructor(message: string);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Error for heap property violations
|
|
57
|
+
*/
|
|
58
|
+
export declare class HeapPropertyError extends DataStructureError {
|
|
59
|
+
constructor(message?: string);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Error for tree-related issues
|
|
63
|
+
*/
|
|
64
|
+
export declare class TreeError extends DataStructureError {
|
|
65
|
+
constructor(message?: string);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Error for array index out of bounds
|
|
69
|
+
*/
|
|
70
|
+
export declare class IndexError extends DataStructureError {
|
|
71
|
+
constructor(message?: string);
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Error for invalid number format or conversion
|
|
75
|
+
*/
|
|
76
|
+
export declare class FormatError extends HypernumError {
|
|
77
|
+
constructor(message: string);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Error for invalid Roman numeral operations
|
|
81
|
+
*/
|
|
82
|
+
export declare class RomanNumeralError extends FormatError {
|
|
83
|
+
constructor(message?: string);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Type guard to check if an error is a Hypernum error
|
|
87
|
+
*/
|
|
88
|
+
export declare function isHypernumError(error: unknown): error is HypernumError;
|
|
89
|
+
/**
|
|
90
|
+
* Helper function to wrap unknown errors into HypernumError
|
|
91
|
+
*/
|
|
92
|
+
export declare function wrapError(error: unknown): HypernumError;
|
|
93
|
+
/**
|
|
94
|
+
* Helper function to create an appropriate error from a message and optional type
|
|
95
|
+
*/
|
|
96
|
+
export declare function createError(message: string, type?: string): HypernumError;
|
|
97
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/core/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH;;;GAGG;AACH,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,OAAO,EAAE,M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 -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main Hypernum class that provides a high-level interface to all library functionality
|
|
3
|
+
*/
|
|
4
|
+
import { HypernumError, ValidationError, OverflowError } from './errors';
|
|
5
|
+
import { BigArray, NumberTree, AckermannStructure } from '../structures';
|
|
6
|
+
import * as formatting from '../utils/formatting';
|
|
7
|
+
import * as validation from '../utils/validation';
|
|
8
|
+
import * as precision from '../utils/precision';
|
|
9
|
+
import { MinHeap, MaxHeap } from '@/storage';
|
|
10
|
+
/**
|
|
11
|
+
* Configuration options for Hypernum instance
|
|
12
|
+
*/
|
|
13
|
+
export interface HypernumConfig {
|
|
14
|
+
precision?: number;
|
|
15
|
+
roundingMode?: precision.RoundingMode;
|
|
16
|
+
checkOverflow?: boolean;
|
|
17
|
+
maxSteps?: number;
|
|
18
|
+
debug?: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare class Hypernum {
|
|
21
|
+
private readonly config;
|
|
22
|
+
private readonly structures;
|
|
23
|
+
constructor(config?: HypernumConfig);
|
|
24
|
+
add(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
25
|
+
subtract(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
26
|
+
multiply(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
27
|
+
divide(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
28
|
+
mod(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
29
|
+
power(base: bigint | string | number, exponent: bigint | string | number): bigint;
|
|
30
|
+
sqrt(value: bigint | string | number): bigint;
|
|
31
|
+
nthRoot(value: bigint | string | number, n: bigint | string | number): bigint;
|
|
32
|
+
and(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
33
|
+
or(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
34
|
+
xor(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
35
|
+
not(value: bigint | string | number): bigint;
|
|
36
|
+
/**
|
|
37
|
+
* Calculates the greatest common divisor of two numbers
|
|
38
|
+
*/
|
|
39
|
+
gcd(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
40
|
+
/**
|
|
41
|
+
* Calculates the least common multiple of two numbers
|
|
42
|
+
*/
|
|
43
|
+
lcm(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
44
|
+
createArray(id: string): BigArray<bigint>;
|
|
45
|
+
getArray(id: string): BigArray<bigint>;
|
|
46
|
+
createTree(id: string): NumberTree;
|
|
47
|
+
getTree(id: string): NumberTree;
|
|
48
|
+
createHeap(id: string, isMinHeap?: boolean): MinHeap<bigint> | MaxHeap<bigint>;
|
|
49
|
+
getHeap(id: string): MinHeap<bigint> | MaxHeap<bigint>;
|
|
50
|
+
createAckermannStructure(): AckermannStructure;
|
|
51
|
+
format(value: bigint | string | number, options?: formatting.FormatOptions): string;
|
|
52
|
+
validate(value: unknown): boolean;
|
|
53
|
+
updateConfig(newConfig: Partial<HypernumConfig>): void;
|
|
54
|
+
getConfig(): Readonly<Required<HypernumConfig>>;
|
|
55
|
+
private compareValues;
|
|
56
|
+
dispose(): void;
|
|
57
|
+
}
|
|
58
|
+
export { HypernumError, ValidationError, OverflowError, precision, formatting, validation };
|
|
59
|
+
export default Hypernum;
|
|
60
|
+
//# sourceMappingURL=hypernum.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hypernum.d.ts","sourceRoot":"","sources":["../../../src/core/hypernum.ts"],"names":[],"mappings":"AAAA;;GAEG;AASH,OAAO,EACL,aAAa,EACb,eAAe,EACf,aAAa,EACd,MAAM,UAAU,CAAC;AAOlB,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,C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IAStD,wBAAwB,IAAI,kBAAkB;IAK9C,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,CAAC,aAAa,GAAG,MAAM;IAKnF,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAUjC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,IAAI;IAItD,SAAS,IAAI,QAAQ,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IAKtD,OAAO,CAAC,aAAa;IAOd,OAAO,IAAI,IAAI;CAKvB;AAGD,OAAO,EACL,aAAa,EACb,eAAe,EACf,aAAa,EACb,SAAS,EACT,UAAU,EACV,UAAU,EACX,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hypernum - A TypeScript/JavaScript library for large number operations
|
|
3
|
+
*/
|
|
4
|
+
import { HypernumConfig } from './core';
|
|
5
|
+
import { Hypernum } from './core/hypernum';
|
|
6
|
+
declare const VERSION: any;
|
|
7
|
+
export { Hypernum } from './core/hypernum';
|
|
8
|
+
export * from './core/constants';
|
|
9
|
+
export * from './core/common';
|
|
10
|
+
export * from './core/config';
|
|
11
|
+
export { HypernumError, ComputationLimitError, DataStructureError, DivisionByZeroError, FormatError, HeapPropertyError, IndexError, PrecisionError, RomanNumeralError, TreeError, UnderflowError } from './core/errors';
|
|
12
|
+
export { AckermannStructure } from './structures/ackermann';
|
|
13
|
+
export { BigArray, type BigArrayOptions } from './structures/big-array';
|
|
14
|
+
export { NumberTree } from './structures/number-tree';
|
|
15
|
+
export { PowerTower } from './structures/power-tower';
|
|
16
|
+
export { MinHeap, MaxHeap, type Comparator } from './storage/';
|
|
17
|
+
export { add, subtract, multiply, divide, remainder, abs, sign, gcd, lcm } from './operations/arithmetic';
|
|
18
|
+
export { and, or, xor, not, leftShift, rightShift, unsignedRightShift, rotateLeft, rotateRight, popCount, trailingZeros, leadingZeros, getBit, setBit, clearBit, toggleBit } from './operations/bitwise';
|
|
19
|
+
export { compare, equals, lessThan, lessThanOrEqual, greaterThan, greaterThanOrEqual, between, max, min, clamp, allEqual, isAscending, isDescending, createComparator } from './operations/comparison';
|
|
20
|
+
export { toBinary, toOctal, toHexadecimal, toBase, fromBase, toFraction, fromFraction, fromScientific, toScientific, fromRoman, toRoman } from './operations/conversion';
|
|
21
|
+
export { factorial, binomial, subfactorial, risingFactorial, fallingFactorial, multiFactorial, primorial } from './operations/factorial';
|
|
22
|
+
export { power, sqrt, nthRoot, tetration, superRoot } from './operations/power';
|
|
23
|
+
export { toBigInt, validateNonNegative, validatePositive, checkAdditionOverflow, checkMultiplicationOverflow, checkPowerOverflow } from './utils/validation';
|
|
24
|
+
export { formatBigInt, parseBigIntString, normalizeNumberString } from './utils/formatting';
|
|
25
|
+
export { RoundingMode, round, scaleByPowerOfTen, scaledDivision, normalizePrecision } from './utils/precision';
|
|
26
|
+
/**
|
|
27
|
+
* Creates a new Hypernum instance with custom configuration
|
|
28
|
+
*/
|
|
29
|
+
export declare function createHypernum(config?: Partial<HypernumConfig>): Hypernum;
|
|
30
|
+
export declare const defaultHypernum: Hypernum;
|
|
31
|
+
export { VERSION };
|
|
32
|
+
export default Hypernum;
|
|
33
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,cAAc,EAA+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ACX,YAAY,EACZ,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,QAAQ,EACR,OAAO,EACP,aAAa,EACb,MAAM,EACN,QAAQ,EACR,UAAU,EACV,YAAY,EACZ,cAAc,EACd,YAAY,EACZ,SAAS,EACT,OAAO,EACR,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,cAAc,EACd,SAAS,EACV,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,KAAK,EACL,IAAI,EACJ,OAAO,EACP,SAAS,EACT,SAAS,EACV,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EACL,QAAQ,EACR,mBAAmB,EACnB,gBAAgB,EAChB,qBAAqB,EACrB,2BAA2B,EAC3B,kBAAkB,EACnB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,qBAAqB,EACtB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,YAAY,EACZ,KAAK,EACL,iBAAiB,EACjB,cAAc,EACd,kBAAkB,EACnB,MAAM,mBAAmB,CAAC;AAE3B;;GAEG;AACH,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,QAAQ,CAuBzE;AAGD,eAAO,MAAM,eAAe,UAAmB,CAAC;AAGhD,OAAO,EAAE,OAAO,EAAE,CAAC;AAGnB,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Arithmetic operations module for Hypernum library
|
|
3
|
+
* Provides high-precision arithmetic operations with BigInt support
|
|
4
|
+
*/
|
|
5
|
+
import { RoundingMode } from '../utils/precision';
|
|
6
|
+
/**
|
|
7
|
+
* Options for arithmetic operations
|
|
8
|
+
*/
|
|
9
|
+
export interface ArithmeticOptions {
|
|
10
|
+
precision?: number;
|
|
11
|
+
roundingMode?: RoundingMode;
|
|
12
|
+
checkOverflow?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Adds two numbers with optional precision and overflow checking
|
|
16
|
+
*/
|
|
17
|
+
export declare function add(a: bigint | string | number, b: bigint | string | number, options?: ArithmeticOptions): bigint;
|
|
18
|
+
/**
|
|
19
|
+
* Subtracts two numbers with optional precision and overflow checking
|
|
20
|
+
*/
|
|
21
|
+
export declare function subtract(a: bigint | string | number, b: bigint | string | number, options?: ArithmeticOptions): bigint;
|
|
22
|
+
/**
|
|
23
|
+
* Multiplies two numbers with optional precision and overflow checking
|
|
24
|
+
*/
|
|
25
|
+
export declare function multiply(a: bigint | string | number, b: bigint | string | number, options?: ArithmeticOptions): bigint;
|
|
26
|
+
/**
|
|
27
|
+
* Divides two numbers with specified precision and rounding
|
|
28
|
+
*/
|
|
29
|
+
export declare function divide(numerator: bigint | string | number, denominator: bigint | string | number, options?: ArithmeticOptions): bigint;
|
|
30
|
+
/**
|
|
31
|
+
* Calculates remainder with optional precision
|
|
32
|
+
*/
|
|
33
|
+
export declare function remainder(a: bigint | string | number, b: bigint | string | number, options?: ArithmeticOptions): bigint;
|
|
34
|
+
/**
|
|
35
|
+
* Raises a number to a power with optional precision
|
|
36
|
+
*/
|
|
37
|
+
export declare function power(base: bigint | string | number, exponent: bigint | string | number, options?: ArithmeticOptions): bigint;
|
|
38
|
+
/**
|
|
39
|
+
* Calculates the square root with specified precision
|
|
40
|
+
*/
|
|
41
|
+
export declare function sqrt(value: bigint | string | number, options?: ArithmeticOptions): bigint;
|
|
42
|
+
/**
|
|
43
|
+
* Calculates the absolute value
|
|
44
|
+
*/
|
|
45
|
+
export declare function abs(value: bigint | string | number): bigint;
|
|
46
|
+
/**
|
|
47
|
+
* Returns the sign of a number (-1, 0, or 1)
|
|
48
|
+
*/
|
|
49
|
+
export declare function sign(value: bigint | string | number): bigint;
|
|
50
|
+
/**
|
|
51
|
+
* Calculates the greatest common divisor of two numbers
|
|
52
|
+
*/
|
|
53
|
+
export declare function gcd(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
54
|
+
/**
|
|
55
|
+
* Calculates the least common multiple of two numbers
|
|
56
|
+
*/
|
|
57
|
+
export declare function lcm(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
58
|
+
declare const _default: {
|
|
59
|
+
add: typeof add;
|
|
60
|
+
subtract: typeof subtract;
|
|
61
|
+
multiply: typeof multiply;
|
|
62
|
+
divide: typeof divide;
|
|
63
|
+
remainder: typeof remainder;
|
|
64
|
+
power: typeof power;
|
|
65
|
+
sqrt: typeof sqrt;
|
|
66
|
+
abs: typeof abs;
|
|
67
|
+
sign: typeof sign;
|
|
68
|
+
gcd: typeof gcd;
|
|
69
|
+
lcm: typeof lcm;
|
|
70
|
+
};
|
|
71
|
+
export default _default;
|
|
72
|
+
//# sourceMappingURL=arithmetic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"arithmetic.d.ts","sourceRoot":"","sources":["../../../src/operations/arithmetic.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAWD,OAAO,EACL,YAAY,EAIb,MAAM,oBAAoB,CAAC;AAE5B;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAQD;;GAEG;AACH,wBAAgB,GAAG,CACjB,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC3B,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC3B,OAAO,GAAE,iBAAsB,GAC9B,MAAM,CAiBR;AAED;;GAEG;AACH,wBAAgB,QAAQ,CACtB,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC3B,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC3B,OAAO,GAAE,iBAAsB,GAC9B,MAAM,CAiBR;A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AAG,MAAM,GAAG,MAAM,EAC3B,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAC1B,MAAM,CASR;;;;;;;;;;;;;;AA4BD,wBAaI"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bitwise operations module for Hypernum library
|
|
3
|
+
* Provides functions for bit-level manipulations of large numbers
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Options for bitwise operations
|
|
7
|
+
*/
|
|
8
|
+
export interface BitwiseOptions {
|
|
9
|
+
/** Maximum bits to consider in operations */
|
|
10
|
+
maxBits?: number;
|
|
11
|
+
/** Whether to throw on overflow */
|
|
12
|
+
strict?: boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Performs bitwise AND operation
|
|
16
|
+
*/
|
|
17
|
+
export declare function and(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
18
|
+
/**
|
|
19
|
+
* Performs bitwise OR operation
|
|
20
|
+
*/
|
|
21
|
+
export declare function or(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
22
|
+
/**
|
|
23
|
+
* Performs bitwise XOR operation
|
|
24
|
+
*/
|
|
25
|
+
export declare function xor(a: bigint | string | number, b: bigint | string | number): bigint;
|
|
26
|
+
/**
|
|
27
|
+
* Performs bitwise NOT operation
|
|
28
|
+
*/
|
|
29
|
+
export declare function not(value: bigint | string | number): bigint;
|
|
30
|
+
/**
|
|
31
|
+
* Performs left shift operation
|
|
32
|
+
*/
|
|
33
|
+
export declare function leftShift(value: bigint | string | number, shift: bigint | string | number, options?: BitwiseOptions): bigint;
|
|
34
|
+
/**
|
|
35
|
+
* Performs right shift operation
|
|
36
|
+
*/
|
|
37
|
+
export declare function rightShift(value: bigint | string | number, shift: bigint | string | number, options?: BitwiseOptions): bigint;
|
|
38
|
+
/**
|
|
39
|
+
* Performs unsigned right shift operation
|
|
40
|
+
* Note: BigInt doesn't have >>> operator, so we implement it manually
|
|
41
|
+
*/
|
|
42
|
+
export declare function unsignedRightShift(value: bigint | string | number, shift: bigint | string | number, options?: BitwiseOptions): bigint;
|
|
43
|
+
/**
|
|
44
|
+
* Rotates bits left by specified amount
|
|
45
|
+
*/
|
|
46
|
+
export declare function rotateLeft(value: bigint | string | number, rotation: bigint | string | number, options?: BitwiseOptions): bigint;
|
|
47
|
+
/**
|
|
48
|
+
* Rotates bits right by specified amount
|
|
49
|
+
*/
|
|
50
|
+
export declare function rotateRight(value: bigint | string | number, rotation: bigint | string | number, options?: BitwiseOptions): bigint;
|
|
51
|
+
/**
|
|
52
|
+
* Counts number of set bits (1s)
|
|
53
|
+
*/
|
|
54
|
+
export declare function popCount(value: bigint | string | number, options?: BitwiseOptions): bigint;
|
|
55
|
+
/**
|
|
56
|
+
* Returns number of trailing zero bits
|
|
57
|
+
*/
|
|
58
|
+
export declare function trailingZeros(value: bigint | string | number, options?: BitwiseOptions): bigint;
|
|
59
|
+
/**
|
|
60
|
+
* Returns number of leading zero bits
|
|
61
|
+
*/
|
|
62
|
+
export declare function leadingZeros(value: bigint | string | number, options?: BitwiseOptions): bigint;
|
|
63
|
+
/**
|
|
64
|
+
* Returns bit at specified position
|
|
65
|
+
*/
|
|
66
|
+
export declare function getBit(value: bigint | string | number, position: bigint | string | number, options?: BitwiseOptions): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Sets bit at specified position
|
|
69
|
+
*/
|
|
70
|
+
export declare function setBit(value: bigint | string | number, position: bigint | string | number, options?: BitwiseOptions): bigint;
|
|
71
|
+
/**
|
|
72
|
+
* Clears bit at specified position
|
|
73
|
+
*/
|
|
74
|
+
export declare function clearBit(value: bigint | string | number, position: bigint | string | number, options?: BitwiseOptions): bigint;
|
|
75
|
+
/**
|
|
76
|
+
* Toggles bit at specified position
|
|
77
|
+
*/
|
|
78
|
+
export declare function toggleBit(value: bigint | string | number, position: bigint | string | number, options?: BitwiseOptions): bigint;
|
|
79
|
+
declare const _default: {
|
|
80
|
+
and: typeof and;
|
|
81
|
+
or: typeof or;
|
|
82
|
+
xor: typeof xor;
|
|
83
|
+
not: typeof not;
|
|
84
|
+
leftShift: typeof leftShift;
|
|
85
|
+
rightShift: typeof rightShift;
|
|
86
|
+
unsignedRightShift: typeof unsignedRightShift;
|
|
87
|
+
rotateLeft: typeof rotateLeft;
|
|
88
|
+
rotateRight: typeof rotateRight;
|
|
89
|
+
popCount: typeof popCount;
|
|
90
|
+
trailingZeros: typeof trailingZeros;
|
|
91
|
+
leadingZeros: typeof leadingZeros;
|
|
92
|
+
getBit: typeof getBit;
|
|
93
|
+
setBit: typeof setBit;
|
|
94
|
+
clearBit: typeof clearBit;
|
|
95
|
+
toggleBit: typeof toggleBit;
|
|
96
|
+
};
|
|
97
|
+
export default _default;
|
|
98
|
+
//# sourceMappingURL=bitwise.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bitwise.d.ts","sourceRoot":"","sources":["../../../src/operations/bitwise.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mCAAmC;IACnC,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAmBD;;GAEG;AACH,wBAAgB,GAAG,CACjB,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC3B,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAC1B,MAAM,CAKR;AAED;;GAEG;AACH,wBAAgB,EAAE,CAChB,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC3B,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAC1B,MAAM,CAKR;AAED;;GAEG;AACH,wBAAgB,GAAG,CACjB,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC3B,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,GAC1B,MAAM,CAKR;AAED;;GAEG;AAC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wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC/B,OAAO,GAAE,cAAmB,GAC3B,MAAM,CAiBR;AAED;;GAEG;AACH,wBAAgB,MAAM,CACpB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC/B,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAClC,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAWT;AAED;;GAEG;AACH,wBAAgB,MAAM,CACpB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC/B,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAClC,OAAO,GAAE,cAAmB,GAC3B,MAAM,CAWR;AAED;;GAEG;AACH,wBAAgB,QAAQ,CACtB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC/B,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAClC,OAAO,GAAE,cAAmB,GAC3B,MAAM,CAWR;AAED;;GAEG;AACH,wBAAgB,SAAS,CACvB,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAC/B,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAClC,OAAO,GAAE,cAAmB,GAC3B,MAAM,CAWR;;;;;;;;;;;;;;;;;;;AAED,wBAiBE"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Comparison operations module for Hypernum library
|
|
3
|
+
* Provides functions for comparing large numbers with precision support
|
|
4
|
+
*/
|
|
5
|
+
import { RoundingMode } from '../utils/precision';
|
|
6
|
+
/**
|
|
7
|
+
* Options for comparison operations
|
|
8
|
+
*/
|
|
9
|
+
export interface ComparisonOptions {
|
|
10
|
+
precision?: number;
|
|
11
|
+
roundingMode?: RoundingMode;
|
|
12
|
+
tolerance?: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Result type for comparison operations
|
|
16
|
+
* -1: first value is less than second value
|
|
17
|
+
* 0: values are equal
|
|
18
|
+
* 1: first value is greater than second value
|
|
19
|
+
*/
|
|
20
|
+
export type ComparisonResult = -1 | 0 | 1;
|
|
21
|
+
/**
|
|
22
|
+
* Compares two numbers with optional precision
|
|
23
|
+
*/
|
|
24
|
+
export declare function compare(a: bigint | string | number, b: bigint | string | number, options?: ComparisonOptions): ComparisonResult;
|
|
25
|
+
/**
|
|
26
|
+
* Checks if two numbers are equal
|
|
27
|
+
*/
|
|
28
|
+
export declare function equals(a: bigint | string | number, b: bigint | string | number, options?: ComparisonOptions): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Checks if first number is less than second
|
|
31
|
+
*/
|
|
32
|
+
export declare function lessThan(a: bigint | string | number, b: bigint | string | number, options?: ComparisonOptions): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Checks if first number is less than or equal to second
|
|
35
|
+
*/
|
|
36
|
+
export declare function lessThanOrEqual(a: bigint | string | number, b: bigint | string | number, options?: ComparisonOptions): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Checks if first number is greater than second
|
|
39
|
+
*/
|
|
40
|
+
export declare function greaterThan(a: bigint | string | number, b: bigint | string | number, options?: ComparisonOptions): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Checks if first number is greater than or equal to second
|
|
43
|
+
*/
|
|
44
|
+
export declare function greaterThanOrEqual(a: bigint | string | number, b: bigint | string | number, options?: ComparisonOptions): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Checks if a number is between two others (inclusive)
|
|
47
|
+
*/
|
|
48
|
+
export declare function between(value: bigint | string | number, min: bigint | string | number, max: bigint | string | number, options?: ComparisonOptions): boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Finds the maximum value in an array of numbers
|
|
51
|
+
*/
|
|
52
|
+
export declare function max(values: Array<bigint | string | number>, options?: ComparisonOptions): bigint;
|
|
53
|
+
/**
|
|
54
|
+
* Finds the minimum value in an array of numbers
|
|
55
|
+
*/
|
|
56
|
+
export declare function min(values: Array<bigint | string | number>, options?: ComparisonOptions): bigint;
|
|
57
|
+
/**
|
|
58
|
+
* Clamps a value between minimum and maximum bounds
|
|
59
|
+
*/
|
|
60
|
+
export declare function clamp(value: bigint | string | number, min: bigint | string | number, max: bigint | string | number, options?: ComparisonOptions): bigint;
|
|
61
|
+
/**
|
|
62
|
+
* Checks if all values in array are equal within tolerance
|
|
63
|
+
*/
|
|
64
|
+
export declare function allEqual(values: Array<bigint | string | number>, options?: ComparisonOptions): boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Checks if values are in ascending order
|
|
67
|
+
*/
|
|
68
|
+
export declare function isAscending(values: Array<bigint | string | number>, options?: ComparisonOptions): boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Checks if values are in descending order
|
|
71
|
+
*/
|
|
72
|
+
export declare function isDescending(values: Array<bigint | string | number>, options?: ComparisonOptions): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Creates a comparator function for sorting
|
|
75
|
+
*/
|
|
76
|
+
export declare function createComparator(options?: ComparisonOptions): (a: bigint | string | number, b: bigint | string | number) => number;
|
|
77
|
+
declare const _default: {
|
|
78
|
+
compare: typeof compare;
|
|
79
|
+
equals: typeof equals;
|
|
80
|
+
lessThan: typeof lessThan;
|
|
81
|
+
lessThanOrEqual: typeof lessThanOrEqual;
|
|
82
|
+
greaterThan: typeof greaterThan;
|
|
83
|
+
greaterThanOrEqual: typeof greaterThanOrEqual;
|
|
84
|
+
between: typeof between;
|
|
85
|
+
max: typeof max;
|
|
86
|
+
min: typeof min;
|
|
87
|
+
clamp: typeof clamp;
|
|
88
|
+
allEqual: typeof allEqual;
|
|
89
|
+
isAscending: typeof isAscending;
|
|
90
|
+
isDescending: typeof isDescending;
|
|
91
|
+
createComparator: typeof createComparator;
|
|
92
|
+
};
|
|
93
|
+
export default _default;
|
|
94
|
+
//# sourceMappingURL=comparison.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"comparison.d.ts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