mathfuse 1.0.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/CHANGELOG.md +37 -0
- package/LICENSE +21 -0
- package/README.md +239 -0
- package/dist/cjs/algebra/index.d.ts +99 -0
- package/dist/cjs/algebra/index.d.ts.map +1 -0
- package/dist/cjs/algebra/index.js +358 -0
- package/dist/cjs/algebra/index.js.map +1 -0
- package/dist/cjs/index.d.ts +15 -0
- package/dist/cjs/index.d.ts.map +1 -0
- package/dist/cjs/index.js +82 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/number-theory/index.d.ts +81 -0
- package/dist/cjs/number-theory/index.d.ts.map +1 -0
- package/dist/cjs/number-theory/index.js +331 -0
- package/dist/cjs/number-theory/index.js.map +1 -0
- package/dist/cjs/numerical/index.d.ts +95 -0
- package/dist/cjs/numerical/index.d.ts.map +1 -0
- package/dist/cjs/numerical/index.js +300 -0
- package/dist/cjs/numerical/index.js.map +1 -0
- package/dist/cjs/stats/index.d.ts +32 -0
- package/dist/cjs/stats/index.d.ts.map +1 -0
- package/dist/cjs/stats/index.js +232 -0
- package/dist/cjs/stats/index.js.map +1 -0
- package/dist/esm/algebra/index.d.ts +99 -0
- package/dist/esm/algebra/index.d.ts.map +1 -0
- package/dist/esm/algebra/index.js +333 -0
- package/dist/esm/algebra/index.js.map +1 -0
- package/dist/esm/index.d.ts +15 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/number-theory/index.d.ts +81 -0
- package/dist/esm/number-theory/index.d.ts.map +1 -0
- package/dist/esm/number-theory/index.js +311 -0
- package/dist/esm/number-theory/index.js.map +1 -0
- package/dist/esm/numerical/index.d.ts +95 -0
- package/dist/esm/numerical/index.d.ts.map +1 -0
- package/dist/esm/numerical/index.js +280 -0
- package/dist/esm/numerical/index.js.map +1 -0
- package/dist/esm/stats/index.d.ts +32 -0
- package/dist/esm/stats/index.d.ts.map +1 -0
- package/dist/esm/stats/index.js +208 -0
- package/dist/esm/stats/index.js.map +1 -0
- package/dist/types/algebra/index.d.ts +99 -0
- package/dist/types/algebra/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +15 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/number-theory/index.d.ts +81 -0
- package/dist/types/number-theory/index.d.ts.map +1 -0
- package/dist/types/numerical/index.d.ts +95 -0
- package/dist/types/numerical/index.d.ts.map +1 -0
- package/dist/types/stats/index.d.ts +32 -0
- package/dist/types/stats/index.d.ts.map +1 -0
- package/package.json +85 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* mathfuse — A modern, zero-dependency TypeScript math utility library.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
export * as stats from './stats/index.js';
|
|
7
|
+
export * as algebra from './algebra/index.js';
|
|
8
|
+
export * as nt from './number-theory/index.js';
|
|
9
|
+
export * as numerical from './numerical/index.js';
|
|
10
|
+
export { mean, median, mode, stdDev, variance, percentile, pearsonCorrelation, linearRegression, zScore, minMaxNormalize, } from './stats/index.js';
|
|
11
|
+
export { vadd, vsub, vdot, vnorm, vnormalize, vdistance, mmul, mdet, minverse, msolve, mtranspose, midentity, } from './algebra/index.js';
|
|
12
|
+
export { isPrime, primesUpTo, gcd, lcm, factorial, binomial, fibonacci, nthFibonacci, primeFactors, } from './number-theory/index.js';
|
|
13
|
+
export { bisection, newtonRaphson, brent, derivative, integrate, lerp, clamp, roundTo, approxEqual, } from './numerical/index.js';
|
|
14
|
+
export declare const VERSION = "1.0.0";
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAC1C,OAAO,KAAK,OAAO,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAGlD,OAAO,EACL,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAChD,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,EAAE,eAAe,GAC9D,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,SAAS,EAC9C,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,GACpD,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,QAAQ,EAClD,SAAS,EAAE,YAAY,EAAE,YAAY,GACtC,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,SAAS,EAAE,aAAa,EAAE,KAAK,EAC/B,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,GACzD,MAAM,sBAAsB,CAAC;AAE9B,eAAO,MAAM,OAAO,UAAU,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module number-theory
|
|
3
|
+
* Primes, GCD/LCM, combinatorics, modular arithmetic, and sequences.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Miller-Rabin primality test (deterministic for n < 3,317,044,064,679,887,385,961,981).
|
|
7
|
+
*/
|
|
8
|
+
export declare function isPrime(n: number): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Sieve of Eratosthenes — returns all primes up to (and including) limit.
|
|
11
|
+
* @example primesUpTo(20) // [2, 3, 5, 7, 11, 13, 17, 19]
|
|
12
|
+
*/
|
|
13
|
+
export declare function primesUpTo(limit: number): number[];
|
|
14
|
+
/**
|
|
15
|
+
* Next prime strictly greater than n.
|
|
16
|
+
* @example nextPrime(10) // 11
|
|
17
|
+
*/
|
|
18
|
+
export declare function nextPrime(n: number): number;
|
|
19
|
+
/**
|
|
20
|
+
* Prime factorization — returns sorted array of prime factors (with repeats).
|
|
21
|
+
* @example primeFactors(60) // [2, 2, 3, 5]
|
|
22
|
+
*/
|
|
23
|
+
export declare function primeFactors(n: number): number[];
|
|
24
|
+
/**
|
|
25
|
+
* Greatest common divisor via Euclidean algorithm.
|
|
26
|
+
* @example gcd(48, 18) // 6
|
|
27
|
+
*/
|
|
28
|
+
export declare function gcd(a: number, b: number): number;
|
|
29
|
+
/**
|
|
30
|
+
* GCD of an array of integers.
|
|
31
|
+
*/
|
|
32
|
+
export declare function gcdMany(nums: number[]): number;
|
|
33
|
+
/**
|
|
34
|
+
* Least common multiple.
|
|
35
|
+
* @example lcm(4, 6) // 12
|
|
36
|
+
*/
|
|
37
|
+
export declare function lcm(a: number, b: number): number;
|
|
38
|
+
/**
|
|
39
|
+
* LCM of an array of integers.
|
|
40
|
+
*/
|
|
41
|
+
export declare function lcmMany(nums: number[]): number;
|
|
42
|
+
export declare function factorial(n: number): number;
|
|
43
|
+
/**
|
|
44
|
+
* Binomial coefficient C(n, k) — "n choose k".
|
|
45
|
+
* @example binomial(10, 3) // 120
|
|
46
|
+
*/
|
|
47
|
+
export declare function binomial(n: number, k: number): number;
|
|
48
|
+
/**
|
|
49
|
+
* Number of permutations P(n, r) = n! / (n−r)!
|
|
50
|
+
*/
|
|
51
|
+
export declare function permutations(n: number, r: number): number;
|
|
52
|
+
/**
|
|
53
|
+
* Modular exponentiation: (base^exp) mod m
|
|
54
|
+
* @example modPow(2, 10, 1000) // 24
|
|
55
|
+
*/
|
|
56
|
+
export declare function modPow(base: number, exp: number, m: number): number;
|
|
57
|
+
/**
|
|
58
|
+
* Euler's totient φ(n) — count of integers in [1, n] coprime to n.
|
|
59
|
+
*/
|
|
60
|
+
export declare function eulerTotient(n: number): number;
|
|
61
|
+
/**
|
|
62
|
+
* Fibonacci sequence up to length n.
|
|
63
|
+
* @example fibonacci(8) // [0, 1, 1, 2, 3, 5, 8, 13]
|
|
64
|
+
*/
|
|
65
|
+
export declare function fibonacci(n: number): number[];
|
|
66
|
+
/**
|
|
67
|
+
* nth Fibonacci number (0-indexed, fast doubling algorithm).
|
|
68
|
+
* @example nthFibonacci(10) // 55
|
|
69
|
+
*/
|
|
70
|
+
export declare function nthFibonacci(n: number): number;
|
|
71
|
+
/**
|
|
72
|
+
* Collatz sequence starting at n (stops at 1).
|
|
73
|
+
* @example collatz(6) // [6, 3, 10, 5, 16, 8, 4, 2, 1]
|
|
74
|
+
*/
|
|
75
|
+
export declare function collatz(n: number): number[];
|
|
76
|
+
/**
|
|
77
|
+
* Digital root of a positive integer (repeated digit sum until single digit).
|
|
78
|
+
* @example digitalRoot(9875) // 2
|
|
79
|
+
*/
|
|
80
|
+
export declare function digitalRoot(n: number): number;
|
|
81
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/number-theory/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA8BH;;GAEG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAmC1C;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAalD;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAO3C;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAYhD;AAID;;;GAGG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAOhD;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAG9C;AAED;;;GAGG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAGhD;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAG9C;AASD,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAQ3C;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAWrD;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAOzD;AAID;;;GAGG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAYnE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAY9C;AAID;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAM7C;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAW9C;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAQ3C;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAI7C"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module numerical
|
|
3
|
+
* Root finding, numerical integration, differentiation, and interpolation.
|
|
4
|
+
*/
|
|
5
|
+
export type Fn = (x: number) => number;
|
|
6
|
+
export interface RootResult {
|
|
7
|
+
root: number;
|
|
8
|
+
iterations: number;
|
|
9
|
+
converged: boolean;
|
|
10
|
+
error: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Bisection method — guaranteed convergence on a bracketed root.
|
|
14
|
+
* @param f - continuous function
|
|
15
|
+
* @param a - left bracket
|
|
16
|
+
* @param b - right bracket (f(a) and f(b) must have opposite signs)
|
|
17
|
+
*/
|
|
18
|
+
export declare function bisection(f: Fn, a: number, b: number, tol?: number, maxIter?: number): RootResult;
|
|
19
|
+
/**
|
|
20
|
+
* Newton-Raphson method — fast quadratic convergence near smooth roots.
|
|
21
|
+
* @param f - function
|
|
22
|
+
* @param df - derivative (if omitted, estimated numerically)
|
|
23
|
+
*/
|
|
24
|
+
export declare function newtonRaphson(f: Fn, x0: number, df?: Fn, tol?: number, maxIter?: number): RootResult;
|
|
25
|
+
/**
|
|
26
|
+
* Brent's method — combines bisection, secant, and inverse quadratic interpolation.
|
|
27
|
+
* Robust and fast — the recommended general-purpose root finder.
|
|
28
|
+
*/
|
|
29
|
+
export declare function brent(f: Fn, a: number, b: number, tol?: number, maxIter?: number): RootResult;
|
|
30
|
+
/**
|
|
31
|
+
* First derivative using central differences (O(h²) accuracy).
|
|
32
|
+
*/
|
|
33
|
+
export declare function derivative(f: Fn, x: number, h?: number): number;
|
|
34
|
+
/**
|
|
35
|
+
* Second derivative using central differences.
|
|
36
|
+
*/
|
|
37
|
+
export declare function secondDerivative(f: Fn, x: number, h?: number): number;
|
|
38
|
+
/**
|
|
39
|
+
* Gradient of a multivariate function at point x.
|
|
40
|
+
* @param f - function accepting a vector and returning a scalar
|
|
41
|
+
* @param x - point at which to compute the gradient
|
|
42
|
+
*/
|
|
43
|
+
export declare function gradient(f: (x: number[]) => number, x: number[], h?: number): number[];
|
|
44
|
+
/**
|
|
45
|
+
* Adaptive Simpson's rule — highly accurate for smooth functions.
|
|
46
|
+
*/
|
|
47
|
+
export declare function integrate(f: Fn, a: number, b: number, tol?: number, maxDepth?: number): number;
|
|
48
|
+
/**
|
|
49
|
+
* Gauss-Legendre quadrature (5-point) — excellent for polynomials and smooth functions.
|
|
50
|
+
* @param f - function to integrate
|
|
51
|
+
* @param a - lower bound
|
|
52
|
+
* @param b - upper bound
|
|
53
|
+
*/
|
|
54
|
+
export declare function gaussLegendre(f: Fn, a: number, b: number): number;
|
|
55
|
+
/**
|
|
56
|
+
* Linear interpolation between two points.
|
|
57
|
+
*/
|
|
58
|
+
export declare function lerp(a: number, b: number, t: number): number;
|
|
59
|
+
/**
|
|
60
|
+
* Inverse lerp — find t such that lerp(a, b, t) === value.
|
|
61
|
+
*/
|
|
62
|
+
export declare function inverseLerp(a: number, b: number, value: number): number;
|
|
63
|
+
/**
|
|
64
|
+
* Linear interpolation from a data table (sorted x values required).
|
|
65
|
+
* @param xs - sorted x values
|
|
66
|
+
* @param ys - corresponding y values
|
|
67
|
+
* @param x - query x value
|
|
68
|
+
*/
|
|
69
|
+
export declare function tableInterpolate(xs: number[], ys: number[], x: number): number;
|
|
70
|
+
/**
|
|
71
|
+
* Lagrange polynomial interpolation at a query point.
|
|
72
|
+
*/
|
|
73
|
+
export declare function lagrange(xs: number[], ys: number[], x: number): number;
|
|
74
|
+
/**
|
|
75
|
+
* Clamp a value to [min, max].
|
|
76
|
+
*/
|
|
77
|
+
export declare function clamp(value: number, min: number, max: number): number;
|
|
78
|
+
/**
|
|
79
|
+
* Round to n decimal places.
|
|
80
|
+
*/
|
|
81
|
+
export declare function roundTo(value: number, decimals: number): number;
|
|
82
|
+
/**
|
|
83
|
+
* Check if two floats are approximately equal.
|
|
84
|
+
*/
|
|
85
|
+
export declare function approxEqual(a: number, b: number, relTol?: number, absTol?: number): boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Map a value from one range to another.
|
|
88
|
+
* @example remap(5, 0, 10, 0, 100) // 50
|
|
89
|
+
*/
|
|
90
|
+
export declare function remap(value: number, inMin: number, inMax: number, outMin: number, outMax: number): number;
|
|
91
|
+
/**
|
|
92
|
+
* Sum of an array using compensated Kahan summation (reduces floating-point error).
|
|
93
|
+
*/
|
|
94
|
+
export declare function kahanSum(data: number[]): number;
|
|
95
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/numerical/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module stats
|
|
3
|
+
* Descriptive statistics, correlation, normalization, and regression.
|
|
4
|
+
*/
|
|
5
|
+
export declare function mean(data: number[]): number;
|
|
6
|
+
export declare function geometricMean(data: number[]): number;
|
|
7
|
+
export declare function harmonicMean(data: number[]): number;
|
|
8
|
+
export declare function median(data: number[]): number;
|
|
9
|
+
export declare function mode(data: number[]): number[];
|
|
10
|
+
export declare function weightedMean(data: number[], weights: number[]): number;
|
|
11
|
+
export declare function variance(data: number[], population?: boolean): number;
|
|
12
|
+
export declare function stdDev(data: number[], population?: boolean): number;
|
|
13
|
+
export declare function range(data: number[]): number;
|
|
14
|
+
export declare function iqr(data: number[]): number;
|
|
15
|
+
export declare function mad(data: number[]): number;
|
|
16
|
+
export declare function percentile(data: number[], p: number): number;
|
|
17
|
+
export declare function fiveNumberSummary(data: number[]): [number, number, number, number, number];
|
|
18
|
+
export declare function skewness(data: number[]): number;
|
|
19
|
+
export declare function kurtosis(data: number[]): number;
|
|
20
|
+
export declare function covariance(x: number[], y: number[]): number;
|
|
21
|
+
export declare function pearsonCorrelation(x: number[], y: number[]): number;
|
|
22
|
+
export declare function spearmanCorrelation(x: number[], y: number[]): number;
|
|
23
|
+
export declare function zScore(data: number[]): number[];
|
|
24
|
+
export declare function minMaxNormalize(data: number[]): number[];
|
|
25
|
+
export interface RegressionResult {
|
|
26
|
+
slope: number;
|
|
27
|
+
intercept: number;
|
|
28
|
+
r2: number;
|
|
29
|
+
predict: (x: number) => number;
|
|
30
|
+
}
|
|
31
|
+
export declare function linearRegression(x: number[], y: number[]): RegressionResult;
|
|
32
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stats/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAUH,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAG3C;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAOpD;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAOnD;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAO7C;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAS7C;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAOtE;AAID,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,UAAU,UAAQ,GAAG,MAAM,CAQnE;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,UAAU,UAAQ,GAAG,MAAM,CAEjE;AAED,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAG5C;AAED,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAG1C;AAED,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAI1C;AAID,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAO5D;AAED,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAU1F;AAID,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAa/C;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAW/C;AAID,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAM3D;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAInE;AAED,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,CAqBpE;AAID,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAI/C;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAOxD;AAID,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,MAAM,CAAC;CAChC;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,gBAAgB,CAkB3E"}
|
package/package.json
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mathfuse",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A modern, zero-dependency TypeScript math utility library — statistics, linear algebra, number theory & numerical methods.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"math", "mathematics", "statistics", "linear-algebra", "matrix",
|
|
7
|
+
"number-theory", "numerical", "numerical-analysis", "calculus",
|
|
8
|
+
"utility", "typescript", "zero-dependency"
|
|
9
|
+
],
|
|
10
|
+
"author": "Avinashvelu03",
|
|
11
|
+
"license": "MIT",
|
|
12
|
+
"homepage": "https://github.com/Avinashvelu03/mathfuse#readme",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "https://github.com/Avinashvelu03/mathfuse.git"
|
|
16
|
+
},
|
|
17
|
+
"bugs": {
|
|
18
|
+
"url": "https://github.com/Avinashvelu03/mathfuse/issues"
|
|
19
|
+
},
|
|
20
|
+
"main": "./dist/cjs/index.js",
|
|
21
|
+
"module": "./dist/esm/index.js",
|
|
22
|
+
"types": "./dist/types/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"import": "./dist/esm/index.js",
|
|
26
|
+
"require": "./dist/cjs/index.js",
|
|
27
|
+
"types": "./dist/types/index.d.ts"
|
|
28
|
+
},
|
|
29
|
+
"./stats": {
|
|
30
|
+
"import": "./dist/esm/stats/index.js",
|
|
31
|
+
"require": "./dist/cjs/stats/index.js",
|
|
32
|
+
"types": "./dist/types/stats/index.d.ts"
|
|
33
|
+
},
|
|
34
|
+
"./algebra": {
|
|
35
|
+
"import": "./dist/esm/algebra/index.js",
|
|
36
|
+
"require": "./dist/cjs/algebra/index.js",
|
|
37
|
+
"types": "./dist/types/algebra/index.d.ts"
|
|
38
|
+
},
|
|
39
|
+
"./number-theory": {
|
|
40
|
+
"import": "./dist/esm/number-theory/index.js",
|
|
41
|
+
"require": "./dist/cjs/number-theory/index.js",
|
|
42
|
+
"types": "./dist/types/number-theory/index.d.ts"
|
|
43
|
+
},
|
|
44
|
+
"./numerical": {
|
|
45
|
+
"import": "./dist/esm/numerical/index.js",
|
|
46
|
+
"require": "./dist/cjs/numerical/index.js",
|
|
47
|
+
"types": "./dist/types/numerical/index.d.ts"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"sideEffects": false,
|
|
51
|
+
"files": [
|
|
52
|
+
"dist",
|
|
53
|
+
"README.md",
|
|
54
|
+
"LICENSE",
|
|
55
|
+
"CHANGELOG.md"
|
|
56
|
+
],
|
|
57
|
+
"scripts": {
|
|
58
|
+
"build": "npm run build:esm && npm run build:cjs && npm run build:types",
|
|
59
|
+
"build:esm": "tsc -p tsconfig.esm.json",
|
|
60
|
+
"build:cjs": "tsc -p tsconfig.cjs.json",
|
|
61
|
+
"build:types": "tsc -p tsconfig.types.json",
|
|
62
|
+
"test": "jest --coverage",
|
|
63
|
+
"test:watch": "jest --watch",
|
|
64
|
+
"lint": "eslint src --ext .ts",
|
|
65
|
+
"format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
66
|
+
"prepublishOnly": "npm run test && npm run build",
|
|
67
|
+
"size": "bundlephobia mathfuse",
|
|
68
|
+
"docs": "typedoc --out docs src/index.ts"
|
|
69
|
+
},
|
|
70
|
+
"devDependencies": {
|
|
71
|
+
"@types/jest": "^29.5.12",
|
|
72
|
+
"@types/node": "^20.11.0",
|
|
73
|
+
"@typescript-eslint/eslint-plugin": "^7.0.0",
|
|
74
|
+
"@typescript-eslint/parser": "^7.0.0",
|
|
75
|
+
"eslint": "^8.57.0",
|
|
76
|
+
"jest": "^29.7.0",
|
|
77
|
+
"prettier": "^3.2.5",
|
|
78
|
+
"ts-jest": "^29.1.2",
|
|
79
|
+
"typedoc": "^0.25.12",
|
|
80
|
+
"typescript": "^5.4.0"
|
|
81
|
+
},
|
|
82
|
+
"engines": {
|
|
83
|
+
"node": ">=16.0.0"
|
|
84
|
+
}
|
|
85
|
+
}
|