@danielsimonjr/mathts-core 0.14.1 → 0.15.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/dist/arithmetic/scalar.d.ts +56 -0
- package/dist/arithmetic/scalar.d.ts.map +1 -0
- package/dist/array.d.ts +253 -0
- package/dist/array.d.ts.map +1 -0
- package/dist/bignumber-formatter.d.ts +135 -0
- package/dist/bignumber-formatter.d.ts.map +1 -0
- package/dist/{chunk-VPK5YTKG.js → chunk-L5MWGOLB.js} +111 -29
- package/dist/collection.d.ts +67 -0
- package/dist/collection.d.ts.map +1 -0
- package/dist/config.d.ts +17 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/constants.d.ts +30 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/customs.d.ts +44 -0
- package/dist/customs.d.ts.map +1 -0
- package/dist/error/DimensionError.d.ts +26 -0
- package/dist/error/DimensionError.d.ts.map +1 -0
- package/dist/error/IndexError.d.ts +33 -0
- package/dist/error/IndexError.d.ts.map +1 -0
- package/dist/error/MathjsError.d.ts +13 -0
- package/dist/error/MathjsError.d.ts.map +1 -0
- package/dist/factory/factory.d.ts +154 -0
- package/dist/factory/factory.d.ts.map +1 -0
- package/dist/factory/index.d.ts +6 -0
- package/dist/factory/index.d.ts.map +1 -0
- package/dist/factory.d.ts +112 -0
- package/dist/factory.d.ts.map +1 -0
- package/dist/index.d.ts +24 -2585
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +74 -18
- package/dist/internal.d.ts +33 -1344
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +5 -3
- package/dist/is.d.ts +102 -0
- package/dist/is.d.ts.map +1 -0
- package/dist/map.d.ts +113 -0
- package/dist/map.d.ts.map +1 -0
- package/dist/number.d.ts +314 -0
- package/dist/number.d.ts.map +1 -0
- package/dist/numeric/stable.d.ts +130 -0
- package/dist/numeric/stable.d.ts.map +1 -0
- package/dist/object.d.ts +119 -0
- package/dist/object.d.ts.map +1 -0
- package/dist/shared.d.ts +41 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/string.d.ts +70 -0
- package/dist/string.d.ts.map +1 -0
- package/dist/switch.d.ts +9 -0
- package/dist/switch.d.ts.map +1 -0
- package/dist/typed/index.d.ts +7 -0
- package/dist/typed/index.d.ts.map +1 -0
- package/dist/typed/mathts-typed.d.ts +246 -0
- package/dist/typed/mathts-typed.d.ts.map +1 -0
- package/dist/typed/type-bridge.d.ts +2 -0
- package/dist/typed/type-bridge.d.ts.map +1 -0
- package/dist/types/bignumber.d.ts +367 -0
- package/dist/types/bignumber.d.ts.map +1 -0
- package/dist/types/complex.d.ts +284 -0
- package/dist/types/complex.d.ts.map +1 -0
- package/dist/types/dual-rules.d.ts +129 -0
- package/dist/types/dual-rules.d.ts.map +1 -0
- package/dist/types/dual.d.ts +36 -0
- package/dist/types/dual.d.ts.map +1 -0
- package/dist/types/fraction.d.ts +215 -0
- package/dist/types/fraction.d.ts.map +1 -0
- package/dist/types/interfaces.d.ts +143 -0
- package/dist/types/interfaces.d.ts.map +1 -0
- package/dist/types/matrix/Range.d.ts +767 -0
- package/dist/types/matrix/Range.d.ts.map +1 -0
- package/dist/types/unit/Unit.d.ts +3 -0
- package/dist/types/unit/Unit.d.ts.map +1 -0
- package/dist/types/unit/dependencies.d.ts +4 -0
- package/dist/types/unit/dependencies.d.ts.map +1 -0
- package/dist/types/unit/errors.d.ts +18 -0
- package/dist/types/unit/errors.d.ts.map +1 -0
- package/dist/types/unit/index.d.ts +7 -0
- package/dist/types/unit/index.d.ts.map +1 -0
- package/dist/types/unit/unit-types.d.ts +231 -0
- package/dist/types/unit/unit-types.d.ts.map +1 -0
- package/dist/types/unit-definitions.d.ts +79 -0
- package/dist/types/unit-definitions.d.ts.map +1 -0
- package/dist/types/unit-prefixes.d.ts +29 -0
- package/dist/types/unit-prefixes.d.ts.map +1 -0
- package/dist/types/unit.d.ts +28 -0
- package/dist/types/unit.d.ts.map +1 -0
- package/dist/types/wasm-loader.d.ts +35 -0
- package/dist/types/wasm-loader.d.ts.map +1 -0
- package/dist/wasm-loader.d.ts +97 -0
- package/dist/wasm-loader.d.ts.map +1 -0
- package/package.json +9 -9
- package/dist/index-B4LIOfHN.d.ts +0 -449
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
function isComplex(value) {
|
|
3
3
|
return value instanceof Complex;
|
|
4
4
|
}
|
|
5
|
+
function hypotFast(re, im) {
|
|
6
|
+
if (im === 0) return Math.abs(re);
|
|
7
|
+
if (re === 0) return Math.abs(im);
|
|
8
|
+
const a = re < 0 ? -re : re;
|
|
9
|
+
const b = im < 0 ? -im : im;
|
|
10
|
+
if (a < 1e150 && b < 1e150 && (a > 1e-150 || b > 1e-150)) {
|
|
11
|
+
return Math.sqrt(re * re + im * im);
|
|
12
|
+
}
|
|
13
|
+
return Math.hypot(re, im);
|
|
14
|
+
}
|
|
5
15
|
var Complex = class _Complex {
|
|
6
16
|
type = "Complex";
|
|
7
17
|
re;
|
|
@@ -150,7 +160,7 @@ var Complex = class _Complex {
|
|
|
150
160
|
* Magnitude (absolute value) |z| = √(re² + im²)
|
|
151
161
|
*/
|
|
152
162
|
abs() {
|
|
153
|
-
return
|
|
163
|
+
return hypotFast(this.re, this.im);
|
|
154
164
|
}
|
|
155
165
|
/**
|
|
156
166
|
* Phase angle (argument) in radians, range (-π, π]
|
|
@@ -266,13 +276,28 @@ var Complex = class _Complex {
|
|
|
266
276
|
// Transcendental Functions
|
|
267
277
|
// ============================================================
|
|
268
278
|
/**
|
|
269
|
-
* Square root using principal branch
|
|
270
|
-
*
|
|
279
|
+
* Square root using the principal branch (Re ≥ 0; Im has the sign of `this.im`).
|
|
280
|
+
*
|
|
281
|
+
* Algebraic form, not polar: one hypot + one sqrt instead of hypot + atan2 +
|
|
282
|
+
* cos + sin. Same branch cut as C99 / the previous polar implementation,
|
|
283
|
+
* including `sqrt(-x - 0i) = −√x · i`.
|
|
271
284
|
*/
|
|
272
285
|
sqrt() {
|
|
273
|
-
const
|
|
274
|
-
const
|
|
275
|
-
|
|
286
|
+
const x = this.re;
|
|
287
|
+
const y = this.im;
|
|
288
|
+
if (y === 0) {
|
|
289
|
+
if (x >= 0) return new _Complex(Math.sqrt(x), y);
|
|
290
|
+
const im2 = Math.sqrt(-x);
|
|
291
|
+
return new _Complex(0, Object.is(y, -0) ? -im2 : im2);
|
|
292
|
+
}
|
|
293
|
+
const r = hypotFast(x, y);
|
|
294
|
+
if (x >= 0) {
|
|
295
|
+
const t2 = Math.sqrt(0.5 * (r + x));
|
|
296
|
+
return new _Complex(t2, y / (2 * t2));
|
|
297
|
+
}
|
|
298
|
+
const t = Math.sqrt(0.5 * (r - x));
|
|
299
|
+
const im = y < 0 ? -t : t;
|
|
300
|
+
return new _Complex(y / (2 * im), im);
|
|
276
301
|
}
|
|
277
302
|
/**
|
|
278
303
|
* n-th root (returns principal root)
|
|
@@ -312,13 +337,15 @@ var Complex = class _Complex {
|
|
|
312
337
|
* Logarithm base 10
|
|
313
338
|
*/
|
|
314
339
|
log10() {
|
|
315
|
-
|
|
340
|
+
const ln10 = Math.LN10;
|
|
341
|
+
return new _Complex(Math.log(hypotFast(this.re, this.im)) / ln10, this.arg() / ln10);
|
|
316
342
|
}
|
|
317
343
|
/**
|
|
318
344
|
* Logarithm base 2
|
|
319
345
|
*/
|
|
320
346
|
log2() {
|
|
321
|
-
|
|
347
|
+
const ln2 = Math.LN2;
|
|
348
|
+
return new _Complex(Math.log(hypotFast(this.re, this.im)) / ln2, this.arg() / ln2);
|
|
322
349
|
}
|
|
323
350
|
/**
|
|
324
351
|
* Power: z^w = e^(w·ln(z))
|
|
@@ -359,16 +386,24 @@ var Complex = class _Complex {
|
|
|
359
386
|
);
|
|
360
387
|
}
|
|
361
388
|
/**
|
|
362
|
-
* Tangent: tan(
|
|
389
|
+
* Tangent: tan(x+iy) = (sin 2x + i sinh 2y) / (cos 2x + cosh 2y)
|
|
390
|
+
*
|
|
391
|
+
* Closed form — no intermediate `sin`/`cos` Complex allocations.
|
|
363
392
|
*/
|
|
364
393
|
tan() {
|
|
365
|
-
|
|
394
|
+
const x2 = this.re * 2;
|
|
395
|
+
const y2 = this.im * 2;
|
|
396
|
+
const d = Math.cos(x2) + Math.cosh(y2);
|
|
397
|
+
return new _Complex(Math.sin(x2) / d, Math.sinh(y2) / d);
|
|
366
398
|
}
|
|
367
399
|
/**
|
|
368
|
-
* Cotangent: cot(
|
|
400
|
+
* Cotangent: cot(x+iy) = (sin 2x − i sinh 2y) / (cosh 2y − cos 2x)
|
|
369
401
|
*/
|
|
370
402
|
cot() {
|
|
371
|
-
|
|
403
|
+
const x2 = this.re * 2;
|
|
404
|
+
const y2 = this.im * 2;
|
|
405
|
+
const d = Math.cosh(y2) - Math.cos(x2);
|
|
406
|
+
return new _Complex(Math.sin(x2) / d, -Math.sinh(y2) / d);
|
|
372
407
|
}
|
|
373
408
|
/**
|
|
374
409
|
* Secant: sec(z) = 1 / cos(z)
|
|
@@ -404,16 +439,22 @@ var Complex = class _Complex {
|
|
|
404
439
|
);
|
|
405
440
|
}
|
|
406
441
|
/**
|
|
407
|
-
* Hyperbolic tangent: tanh(
|
|
442
|
+
* Hyperbolic tangent: tanh(x+iy) = (sinh 2x + i sin 2y) / (cosh 2x + cos 2y)
|
|
408
443
|
*/
|
|
409
444
|
tanh() {
|
|
410
|
-
|
|
445
|
+
const x2 = this.re * 2;
|
|
446
|
+
const y2 = this.im * 2;
|
|
447
|
+
const d = Math.cosh(x2) + Math.cos(y2);
|
|
448
|
+
return new _Complex(Math.sinh(x2) / d, Math.sin(y2) / d);
|
|
411
449
|
}
|
|
412
450
|
/**
|
|
413
|
-
* Hyperbolic cotangent: coth(
|
|
451
|
+
* Hyperbolic cotangent: coth(x+iy) = (sinh 2x − i sin 2y) / (cosh 2x − cos 2y)
|
|
414
452
|
*/
|
|
415
453
|
coth() {
|
|
416
|
-
|
|
454
|
+
const x2 = this.re * 2;
|
|
455
|
+
const y2 = this.im * 2;
|
|
456
|
+
const d = Math.cosh(x2) - Math.cos(y2);
|
|
457
|
+
return new _Complex(Math.sinh(x2) / d, -Math.sin(y2) / d);
|
|
417
458
|
}
|
|
418
459
|
/**
|
|
419
460
|
* Hyperbolic secant: sech(z) = 1 / cosh(z)
|
|
@@ -1491,11 +1532,49 @@ function gcd(a, b) {
|
|
|
1491
1532
|
}
|
|
1492
1533
|
return a;
|
|
1493
1534
|
}
|
|
1535
|
+
function reducePair(num, den) {
|
|
1536
|
+
if (den === 0n) {
|
|
1537
|
+
throw new Error("Fraction denominator cannot be zero");
|
|
1538
|
+
}
|
|
1539
|
+
if (den < 0n) {
|
|
1540
|
+
num = -num;
|
|
1541
|
+
den = -den;
|
|
1542
|
+
}
|
|
1543
|
+
if (num === 0n) return [0n, 1n];
|
|
1544
|
+
const g = gcd(num, den);
|
|
1545
|
+
return [num / g, den / g];
|
|
1546
|
+
}
|
|
1494
1547
|
var Fraction = class _Fraction {
|
|
1495
1548
|
type = "Fraction";
|
|
1496
1549
|
numerator;
|
|
1497
1550
|
denominator;
|
|
1498
1551
|
constructor(numerator, denominator = 1n) {
|
|
1552
|
+
if (typeof numerator === "bigint" && typeof denominator === "bigint") {
|
|
1553
|
+
const [num2, den2] = reducePair(numerator, denominator);
|
|
1554
|
+
this.numerator = num2;
|
|
1555
|
+
this.denominator = den2;
|
|
1556
|
+
return;
|
|
1557
|
+
}
|
|
1558
|
+
if (typeof numerator === "number" && Number.isInteger(numerator)) {
|
|
1559
|
+
if (typeof denominator === "bigint") {
|
|
1560
|
+
const [num2, den2] = reducePair(BigInt(numerator), denominator);
|
|
1561
|
+
this.numerator = num2;
|
|
1562
|
+
this.denominator = den2;
|
|
1563
|
+
return;
|
|
1564
|
+
}
|
|
1565
|
+
if (typeof denominator === "number" && Number.isInteger(denominator)) {
|
|
1566
|
+
const [num2, den2] = reducePair(BigInt(numerator), BigInt(denominator));
|
|
1567
|
+
this.numerator = num2;
|
|
1568
|
+
this.denominator = den2;
|
|
1569
|
+
return;
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
if (typeof numerator === "bigint" && typeof denominator === "number" && Number.isInteger(denominator)) {
|
|
1573
|
+
const [num2, den2] = reducePair(numerator, BigInt(denominator));
|
|
1574
|
+
this.numerator = num2;
|
|
1575
|
+
this.denominator = den2;
|
|
1576
|
+
return;
|
|
1577
|
+
}
|
|
1499
1578
|
const toRatio = (x) => {
|
|
1500
1579
|
if (isFraction2(x)) {
|
|
1501
1580
|
return [x.numerator, x.denominator];
|
|
@@ -1692,6 +1771,9 @@ var Fraction = class _Fraction {
|
|
|
1692
1771
|
*/
|
|
1693
1772
|
add(other) {
|
|
1694
1773
|
if (other instanceof _Fraction) {
|
|
1774
|
+
if (this.denominator === other.denominator) {
|
|
1775
|
+
return new _Fraction(this.numerator + other.numerator, this.denominator);
|
|
1776
|
+
}
|
|
1695
1777
|
const num = this.numerator * other.denominator + other.numerator * this.denominator;
|
|
1696
1778
|
const den = this.denominator * other.denominator;
|
|
1697
1779
|
return new _Fraction(num, den);
|
|
@@ -1703,6 +1785,9 @@ var Fraction = class _Fraction {
|
|
|
1703
1785
|
*/
|
|
1704
1786
|
subtract(other) {
|
|
1705
1787
|
if (other instanceof _Fraction) {
|
|
1788
|
+
if (this.denominator === other.denominator) {
|
|
1789
|
+
return new _Fraction(this.numerator - other.numerator, this.denominator);
|
|
1790
|
+
}
|
|
1706
1791
|
const num = this.numerator * other.denominator - other.numerator * this.denominator;
|
|
1707
1792
|
const den = this.denominator * other.denominator;
|
|
1708
1793
|
return new _Fraction(num, den);
|
|
@@ -2041,6 +2126,9 @@ var BigNumber = class _BigNumber {
|
|
|
2041
2126
|
if (n === 0) {
|
|
2042
2127
|
return new _BigNumber(0, 0n, 0);
|
|
2043
2128
|
}
|
|
2129
|
+
if (Number.isSafeInteger(n)) {
|
|
2130
|
+
return _BigNumber.fromBigInt(BigInt(n));
|
|
2131
|
+
}
|
|
2044
2132
|
return _BigNumber.parse(n.toString());
|
|
2045
2133
|
}
|
|
2046
2134
|
/**
|
|
@@ -2105,19 +2193,13 @@ var BigNumber = class _BigNumber {
|
|
|
2105
2193
|
return new _BigNumber(0, 0n, 0);
|
|
2106
2194
|
}
|
|
2107
2195
|
const sign2 = n < 0n ? -1 : 1;
|
|
2108
|
-
let
|
|
2109
|
-
let
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
} else {
|
|
2114
|
-
break;
|
|
2115
|
-
}
|
|
2116
|
-
}
|
|
2117
|
-
if (trailingZeros > 0) {
|
|
2118
|
-
str = str.slice(0, -trailingZeros);
|
|
2196
|
+
let coef = n < 0n ? -n : n;
|
|
2197
|
+
let exp = 0;
|
|
2198
|
+
while (coef % 10n === 0n) {
|
|
2199
|
+
coef /= 10n;
|
|
2200
|
+
exp++;
|
|
2119
2201
|
}
|
|
2120
|
-
return new _BigNumber(sign2,
|
|
2202
|
+
return new _BigNumber(sign2, coef, exp);
|
|
2121
2203
|
}
|
|
2122
2204
|
/**
|
|
2123
2205
|
* Create a BigNumber from a JSON object
|
|
@@ -6199,7 +6281,7 @@ var createUnitClass = /* @__PURE__ */ factory(
|
|
|
6199
6281
|
} else {
|
|
6200
6282
|
prefixes = PREFIXES.NONE;
|
|
6201
6283
|
}
|
|
6202
|
-
let newUnit
|
|
6284
|
+
let newUnit;
|
|
6203
6285
|
if (!defUnit) {
|
|
6204
6286
|
baseName = baseName || name2 + "_STUFF";
|
|
6205
6287
|
if (BASE_DIMENSIONS.indexOf(baseName) >= 0) {
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
interface Matrix<T = unknown> {
|
|
2
|
+
forEach(callback: (value: T) => void, skipZeros: boolean, recurse: boolean): void;
|
|
3
|
+
map<U>(callback: (value: T) => U, skipZeros: boolean, recurse: boolean): Matrix<U>;
|
|
4
|
+
size(): number[];
|
|
5
|
+
valueOf(): T[];
|
|
6
|
+
create(data: T[], datatype?: string): Matrix<T>;
|
|
7
|
+
datatype(): string | undefined;
|
|
8
|
+
}
|
|
9
|
+
interface SparseMatrix<T = unknown> {
|
|
10
|
+
_values: T[];
|
|
11
|
+
_index: number[];
|
|
12
|
+
_ptr: number[];
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Test whether an array contains collections
|
|
16
|
+
* @param array - Array to test
|
|
17
|
+
* @returns Returns true when the array contains one or multiple
|
|
18
|
+
* collections (Arrays or Matrices). Returns false otherwise.
|
|
19
|
+
*/
|
|
20
|
+
export declare function containsCollections(array: unknown[]): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Recursively loop over all elements in a given multi dimensional array
|
|
23
|
+
* and invoke the callback on each of the elements.
|
|
24
|
+
* @param array - Array or Matrix to iterate over
|
|
25
|
+
* @param callback - The callback method is invoked with one parameter: the current element in the array
|
|
26
|
+
*/
|
|
27
|
+
export declare function deepForEach<T>(array: T[] | Matrix<T>, callback: (value: T) => void): void;
|
|
28
|
+
/**
|
|
29
|
+
* Execute the callback function element wise for each element in array and any
|
|
30
|
+
* nested array
|
|
31
|
+
* Returns an array with the results
|
|
32
|
+
* @param array - Array or Matrix to map over
|
|
33
|
+
* @param callback - The callback is called with two parameters:
|
|
34
|
+
* value1 and value2, which contain the current
|
|
35
|
+
* element of both arrays.
|
|
36
|
+
* @param skipZeros - Invoke callback function for non-zero values only.
|
|
37
|
+
*
|
|
38
|
+
* @return Mapped result
|
|
39
|
+
*/
|
|
40
|
+
export declare function deepMap<T, U>(array: T[] | Matrix<T>, callback: (value: T) => U, skipZeros?: boolean): U[] | Matrix<U>;
|
|
41
|
+
/**
|
|
42
|
+
* Reduce a given matrix or array to a new matrix or
|
|
43
|
+
* array with one less dimension, applying the given
|
|
44
|
+
* callback in the selected dimension.
|
|
45
|
+
* @param mat - Array or Matrix to reduce
|
|
46
|
+
* @param dim - Dimension to reduce
|
|
47
|
+
* @param callback - Callback function
|
|
48
|
+
* @return Reduced result
|
|
49
|
+
*/
|
|
50
|
+
export declare function reduce<T, U>(mat: T[] | Matrix<T>, dim: number, callback: (acc: U | T, val: T) => U): U[] | Matrix<U>;
|
|
51
|
+
/**
|
|
52
|
+
* Scatter function for sparse matrix operations
|
|
53
|
+
* @param a - Sparse matrix
|
|
54
|
+
* @param j - Column index
|
|
55
|
+
* @param w - Work array for marking visited rows
|
|
56
|
+
* @param x - Work array for storing values
|
|
57
|
+
* @param u - Work array for marking updated rows
|
|
58
|
+
* @param mark - Current mark value
|
|
59
|
+
* @param cindex - Column index array to update
|
|
60
|
+
* @param f - Binary function to apply
|
|
61
|
+
* @param inverse - Whether to inverse the function arguments
|
|
62
|
+
* @param update - Whether to update existing values
|
|
63
|
+
* @param value - Value to use in binary function
|
|
64
|
+
*/
|
|
65
|
+
export declare function scatter<T>(a: SparseMatrix<T>, j: number, w: number[], x: T[] | null, u: number[], mark: number, cindex: number[], f?: (a: T, b: T) => T, inverse?: boolean, update?: boolean, value?: T): void;
|
|
66
|
+
export {};
|
|
67
|
+
//# sourceMappingURL=collection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../src/collection.ts"],"names":[],"mappings":"AAqBA,UAAU,MAAM,CAAC,CAAC,GAAG,OAAO;IAC1B,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAClF,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACnF,IAAI,IAAI,MAAM,EAAE,CAAC;IACjB,OAAO,IAAI,CAAC,EAAE,CAAC;IACf,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IAChD,QAA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,MAAM,EAAE,EACX,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EAAE,EAChB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,EACrB,OAAO,CAAC,EAAE,OAAO,EACjB,MAAM,CAAC,EAAE,OAAO,EAChB,KAAK,CAAC,EAAE,CAAC,GACR,IAAI,CA8DN"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration interface for math.js
|
|
3
|
+
*/
|
|
4
|
+
export interface ConfigOptions {
|
|
5
|
+
relTol: number;
|
|
6
|
+
absTol: number;
|
|
7
|
+
matrix: 'Matrix' | 'Array';
|
|
8
|
+
number: 'number' | 'BigNumber' | 'bigint' | 'Fraction';
|
|
9
|
+
numberFallback: 'number' | 'BigNumber';
|
|
10
|
+
precision: number;
|
|
11
|
+
predictable: boolean;
|
|
12
|
+
randomSeed: string | null;
|
|
13
|
+
legacySubset: boolean;
|
|
14
|
+
}
|
|
15
|
+
export type MathJsConfig = ConfigOptions;
|
|
16
|
+
export declare const DEFAULT_CONFIG: ConfigOptions;
|
|
17
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,aAAa;IAG5B,MAAM,EAAE,MAAM,CAAC;IAIf,MAAM,EAAE,MAAM,CAAC;IAGf,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC;IAG3B,MAAM,EAAE,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,CAAC;IAIvD,cAAc,EAAE,QAAQ,GAAG,WAAW,CAAC;IAGvC,SAAS,EAAE,MAAM,CAAC;IAMlB,WAAW,EAAE,OAAO,CAAC;IAIrB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAK1B,YAAY,EAAE,OAAO,CAAC;CACvB;AAGD,MAAM,MAAM,YAAY,GAAG,aAAa,CAAC;AAEzC,eAAO,MAAM,cAAc,EAAE,aAoC5B,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Named mathematical constants (plain `number`).
|
|
3
|
+
*
|
|
4
|
+
* These mirror the constants documented in `docs/reference/constants.md` and the
|
|
5
|
+
* familiar `Math.*` values, exported as first-class named bindings so callers can
|
|
6
|
+
* `import { PI, E, TAU } from '@danielsimonjr/mathts-core'`. The imaginary unit
|
|
7
|
+
* `I` and the type-specific constants (`COMPLEX_*`, `BIGNUMBER_*`, `FRACTION_*`)
|
|
8
|
+
* live with their respective types.
|
|
9
|
+
*/
|
|
10
|
+
/** Ratio of a circle's circumference to its diameter. */
|
|
11
|
+
export declare const PI: number;
|
|
12
|
+
/** Euler's number, the base of the natural logarithm. */
|
|
13
|
+
export declare const E: number;
|
|
14
|
+
/** Full-circle constant, `2·PI`. */
|
|
15
|
+
export declare const TAU: number;
|
|
16
|
+
/** Golden ratio, `(1 + √5) / 2`. */
|
|
17
|
+
export declare const PHI: number;
|
|
18
|
+
/** Square root of 2. */
|
|
19
|
+
export declare const SQRT2: number;
|
|
20
|
+
/** Square root of one-half. */
|
|
21
|
+
export declare const SQRT1_2: number;
|
|
22
|
+
/** Natural logarithm of 2. */
|
|
23
|
+
export declare const LN2: number;
|
|
24
|
+
/** Natural logarithm of 10. */
|
|
25
|
+
export declare const LN10: number;
|
|
26
|
+
/** Base-2 logarithm of E. */
|
|
27
|
+
export declare const LOG2E: number;
|
|
28
|
+
/** Base-10 logarithm of E. */
|
|
29
|
+
export declare const LOG10E: number;
|
|
30
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,yDAAyD;AACzD,eAAO,MAAM,EAAE,QAAU,CAAC;AAC1B,yDAAyD;AACzD,eAAO,MAAM,CAAC,QAAS,CAAC;AACxB,oCAAoC;AACpC,eAAO,MAAM,GAAG,QAAc,CAAC;AAC/B,oCAAoC;AACpC,eAAO,MAAM,GAAG,QAAyB,CAAC;AAC1C,wBAAwB;AACxB,eAAO,MAAM,KAAK,QAAa,CAAC;AAChC,+BAA+B;AAC/B,eAAO,MAAM,OAAO,QAAe,CAAC;AACpC,8BAA8B;AAC9B,eAAO,MAAM,GAAG,QAAW,CAAC;AAC5B,+BAA+B;AAC/B,eAAO,MAAM,IAAI,QAAY,CAAC;AAC9B,6BAA6B;AAC7B,eAAO,MAAM,KAAK,QAAa,CAAC;AAChC,8BAA8B;AAC9B,eAAO,MAAM,MAAM,QAAc,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get a property of a plain object
|
|
3
|
+
* Throws an error in case the object is not a plain object or the
|
|
4
|
+
* property is not defined on the object itself
|
|
5
|
+
* @param {Object} object
|
|
6
|
+
* @param {string} prop
|
|
7
|
+
* @return {*} Returns the property value when safe
|
|
8
|
+
*/
|
|
9
|
+
export declare function getSafeProperty(object: unknown, prop: string): unknown;
|
|
10
|
+
/**
|
|
11
|
+
* Set a property on a plain object.
|
|
12
|
+
* Throws an error in case the object is not a plain object or the
|
|
13
|
+
* property would override an inherited property like .constructor or .toString
|
|
14
|
+
* @param {Object} object
|
|
15
|
+
* @param {string} prop
|
|
16
|
+
* @param {*} value
|
|
17
|
+
* @return {*} Returns the value
|
|
18
|
+
*/
|
|
19
|
+
export declare function setSafeProperty(object: unknown, prop: string, value: unknown): unknown;
|
|
20
|
+
/**
|
|
21
|
+
* Test whether a property is safe to use on an object or Array.
|
|
22
|
+
* For example .toString and .constructor are not safe
|
|
23
|
+
* @param {Object | Array} object
|
|
24
|
+
* @param {string} prop
|
|
25
|
+
* @return {boolean} Returns true when safe
|
|
26
|
+
*/
|
|
27
|
+
export declare function isSafeProperty(object: unknown, prop: string): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Validate whether a method is safe.
|
|
30
|
+
* Throws an error when that's not the case.
|
|
31
|
+
* @param {Object} object
|
|
32
|
+
* @param {string} method
|
|
33
|
+
* @return {function} Returns the method when valid
|
|
34
|
+
*/
|
|
35
|
+
export declare function getSafeMethod(object: unknown, method: string): unknown;
|
|
36
|
+
/**
|
|
37
|
+
* Check whether a method is safe.
|
|
38
|
+
* Throws an error when that's not the case (for example for `constructor`).
|
|
39
|
+
* @param {Object} object
|
|
40
|
+
* @param {string} method
|
|
41
|
+
* @return {boolean} Returns true when safe, false otherwise
|
|
42
|
+
*/
|
|
43
|
+
export declare function isSafeMethod(object: unknown, method: string): boolean;
|
|
44
|
+
//# sourceMappingURL=customs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customs.d.ts","sourceRoot":"","sources":["../src/customs.ts"],"names":[],"mappings":"AAcA;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAYtE;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAQtF;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CA0BrE;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAMtE;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAwCrE"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a range error with the message:
|
|
3
|
+
* 'Dimension mismatch (<actual size> != <expected size>)'
|
|
4
|
+
* Or with a custom message when called with a single string argument.
|
|
5
|
+
*
|
|
6
|
+
* The single canonical `DimensionError` for the whole monorepo (Bucket B, commit 1),
|
|
7
|
+
* exposed via the `@danielsimonjr/mathts-core/internal` subpath. `expression/src/error/
|
|
8
|
+
* DimensionError.ts` and `functions/src/error/DimensionError.ts` are now thin
|
|
9
|
+
* re-export shims of this class — a `DimensionError` thrown in one package is
|
|
10
|
+
* `instanceof DimensionError` in any other, since there is only ever one class
|
|
11
|
+
* identity. `core/src/array.ts` (and the ~20 other call sites across matrix algos,
|
|
12
|
+
* subset, resize, concat, reshape, ...) all throw this same class.
|
|
13
|
+
*/
|
|
14
|
+
export declare class DimensionError extends RangeError {
|
|
15
|
+
actual?: number | number[];
|
|
16
|
+
expected?: number | number[];
|
|
17
|
+
relation?: string;
|
|
18
|
+
isDimensionError: true;
|
|
19
|
+
/**
|
|
20
|
+
* @param actual - The actual size or custom error message
|
|
21
|
+
* @param expected - The expected size (optional if actual is a custom message)
|
|
22
|
+
* @param relation - Optional relation between actual and expected size: '!=', '<', etc.
|
|
23
|
+
*/
|
|
24
|
+
constructor(actual: number | number[] | string, expected?: number | number[], relation?: string);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=DimensionError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DimensionError.d.ts","sourceRoot":"","sources":["../../src/error/DimensionError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,qBAAa,cAAe,SAAQ,UAAU;IAC5C,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,gBAAgB,OAAiB;IAEjC;;;;OAIG;IACH,YAAY,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EAAE,QAAQ,CAAC,EAAE,MAAM,EAwC9F;CACF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error type for index out of range errors.
|
|
3
|
+
*
|
|
4
|
+
* The single canonical `IndexError` for the whole monorepo (Bucket B, commit 1),
|
|
5
|
+
* exposed via the `@danielsimonjr/mathts-core/internal` subpath. `expression/src/error/
|
|
6
|
+
* IndexError.ts` and `functions/src/error/IndexError.ts` are now thin re-export shims
|
|
7
|
+
* of this class — an `IndexError` thrown in one package is `instanceof IndexError`
|
|
8
|
+
* in any other, since there is only ever one class identity. `core/src/array.ts` /
|
|
9
|
+
* `core/src/collection.ts` (and the many other call sites across concat, subset,
|
|
10
|
+
* cumsum, mapSlices, ...) all throw this same class.
|
|
11
|
+
*
|
|
12
|
+
* @extends RangeError
|
|
13
|
+
*/
|
|
14
|
+
export declare class IndexError extends RangeError {
|
|
15
|
+
index: number;
|
|
16
|
+
min: number | undefined;
|
|
17
|
+
max: number | undefined;
|
|
18
|
+
isIndexError: true;
|
|
19
|
+
/**
|
|
20
|
+
* Create an IndexError
|
|
21
|
+
*
|
|
22
|
+
* Can be called in two ways:
|
|
23
|
+
* - IndexError(index, max) - assumes min=0
|
|
24
|
+
* - IndexError(index, min, max)
|
|
25
|
+
*
|
|
26
|
+
* @param index The actual index
|
|
27
|
+
* @param min Minimum index (included), or max if only 2 args provided
|
|
28
|
+
* @param max Maximum index (excluded)
|
|
29
|
+
*/
|
|
30
|
+
constructor(index: number, min?: number, max?: number);
|
|
31
|
+
}
|
|
32
|
+
export declare function createIndexError(index: number, min?: number, max?: number): IndexError;
|
|
33
|
+
//# sourceMappingURL=IndexError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IndexError.d.ts","sourceRoot":"","sources":["../../src/error/IndexError.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,qBAAa,UAAW,SAAQ,UAAU;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,YAAY,OAAiB;IAE7B;;;;;;;;;;OAUG;IACH,YAAY,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAqCpD;CACF;AAID,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,UAAU,CAEtF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom error type for Mathjs errors
|
|
3
|
+
* @extends Error
|
|
4
|
+
*/
|
|
5
|
+
export declare class MathjsError extends Error {
|
|
6
|
+
isMathjsError: true;
|
|
7
|
+
/**
|
|
8
|
+
* Create a MathjsError
|
|
9
|
+
* @param message Error message
|
|
10
|
+
*/
|
|
11
|
+
constructor(message: string);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=MathjsError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MathjsError.d.ts","sourceRoot":"","sources":["../../src/error/MathjsError.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,aAAa,OAAiB;IAE9B;;;OAGG;IACH,YAAY,OAAO,EAAE,MAAM,EAgB1B;CACF"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MathTS Function Factory
|
|
3
|
+
*
|
|
4
|
+
* Provides a factory pattern for creating MathTS functions with:
|
|
5
|
+
* - Typed function dispatch via typed-function
|
|
6
|
+
* - Dependency injection for inter-function references
|
|
7
|
+
* - Backend selection integration
|
|
8
|
+
* - Lazy loading support
|
|
9
|
+
*
|
|
10
|
+
* @packageDocumentation
|
|
11
|
+
*/
|
|
12
|
+
import type { TypedFunction, TypedInstance, SignatureFunction, ReferTo, ReferToSelf } from '../typed/mathts-typed.js';
|
|
13
|
+
/**
|
|
14
|
+
* Configuration for MathTS instance
|
|
15
|
+
*/
|
|
16
|
+
export interface MathTSConfig {
|
|
17
|
+
/** Numeric precision (for BigNumber) */
|
|
18
|
+
precision: number;
|
|
19
|
+
/** Default matrix type */
|
|
20
|
+
matrix: 'Matrix' | 'Array';
|
|
21
|
+
/** Number type for parsing */
|
|
22
|
+
number: 'number' | 'BigNumber' | 'Fraction';
|
|
23
|
+
/** Enable predictable randomness */
|
|
24
|
+
randomSeed: string | null;
|
|
25
|
+
/** Epsilon for floating point comparison */
|
|
26
|
+
epsilon: number;
|
|
27
|
+
/** Preferred backend for matrix operations */
|
|
28
|
+
preferredBackend: 'auto' | 'js' | 'wasm' | 'gpu';
|
|
29
|
+
/** Minimum elements to use WASM backend */
|
|
30
|
+
wasmThreshold: number;
|
|
31
|
+
/** Minimum elements to use GPU backend */
|
|
32
|
+
gpuThreshold: number;
|
|
33
|
+
/** Enable parallel processing */
|
|
34
|
+
parallelEnabled: boolean;
|
|
35
|
+
/** Minimum elements to parallelize */
|
|
36
|
+
parallelThreshold: number;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Default MathTS configuration
|
|
40
|
+
*/
|
|
41
|
+
export declare const DEFAULT_CONFIG: MathTSConfig;
|
|
42
|
+
/**
|
|
43
|
+
* Factory function definition
|
|
44
|
+
*/
|
|
45
|
+
export interface FactoryFunction<T = TypedFunction> {
|
|
46
|
+
/** Name of the function */
|
|
47
|
+
name: string;
|
|
48
|
+
/** Dependencies required by this function */
|
|
49
|
+
dependencies: string[];
|
|
50
|
+
/** Factory that creates the function given dependencies */
|
|
51
|
+
factory: (deps: FactoryDependencies) => T;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Dependencies passed to factory functions
|
|
55
|
+
*/
|
|
56
|
+
export interface FactoryDependencies {
|
|
57
|
+
/** MathTS configuration */
|
|
58
|
+
config: MathTSConfig;
|
|
59
|
+
/** typed-function instance */
|
|
60
|
+
typed: TypedInstance;
|
|
61
|
+
/** Registered functions (for cross-references) */
|
|
62
|
+
[key: string]: unknown;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Import definition for a factory function
|
|
66
|
+
*/
|
|
67
|
+
export type FactoryImport = FactoryFunction | (() => Promise<FactoryFunction>);
|
|
68
|
+
/**
|
|
69
|
+
* MathTS function registry
|
|
70
|
+
*/
|
|
71
|
+
export declare class FunctionRegistry {
|
|
72
|
+
private factories;
|
|
73
|
+
private instances;
|
|
74
|
+
private dependencies;
|
|
75
|
+
private creating;
|
|
76
|
+
constructor(config?: Partial<MathTSConfig>, typed?: TypedInstance);
|
|
77
|
+
/**
|
|
78
|
+
* Register a factory function
|
|
79
|
+
*/
|
|
80
|
+
register(factory: FactoryFunction): void;
|
|
81
|
+
/**
|
|
82
|
+
* Register multiple factory functions
|
|
83
|
+
*/
|
|
84
|
+
registerAll(factories: FactoryFunction[]): void;
|
|
85
|
+
/**
|
|
86
|
+
* Get or create a function by name
|
|
87
|
+
*/
|
|
88
|
+
get(name: string): TypedFunction;
|
|
89
|
+
/**
|
|
90
|
+
* Check if a function is registered
|
|
91
|
+
*/
|
|
92
|
+
has(name: string): boolean;
|
|
93
|
+
/**
|
|
94
|
+
* Get all registered function names
|
|
95
|
+
*/
|
|
96
|
+
names(): string[];
|
|
97
|
+
/**
|
|
98
|
+
* Update configuration
|
|
99
|
+
*/
|
|
100
|
+
updateConfig(config: Partial<MathTSConfig>): void;
|
|
101
|
+
/**
|
|
102
|
+
* Get current configuration
|
|
103
|
+
*/
|
|
104
|
+
getConfig(): MathTSConfig;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Create a factory function definition
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* export const addFactory = createFactory('add', ['typed'], ({ typed }) =>
|
|
112
|
+
* typed('add', {
|
|
113
|
+
* 'number, number': (a, b) => a + b,
|
|
114
|
+
* 'Complex, Complex': (a, b) => ({ re: a.re + b.re, im: a.im + b.im }),
|
|
115
|
+
* })
|
|
116
|
+
* );
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
export declare function createFactory<T = TypedFunction>(name: string, dependencies: string[], factory: (deps: FactoryDependencies) => T): FactoryFunction<T>;
|
|
120
|
+
/**
|
|
121
|
+
* Create a typed function using the factory pattern
|
|
122
|
+
*
|
|
123
|
+
* This is a convenience wrapper that creates a factory and immediately
|
|
124
|
+
* invokes it with the default dependencies.
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* export const add = createTypedFunction('add', {
|
|
129
|
+
* 'number, number': (a, b) => a + b,
|
|
130
|
+
* 'string, string': (a, b) => a + b,
|
|
131
|
+
* });
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
export declare function createTypedFunction(name: string, signatures: Record<string, SignatureFunction | ReferTo | ReferToSelf>): TypedFunction;
|
|
135
|
+
export declare const registry: FunctionRegistry;
|
|
136
|
+
export declare const math: {
|
|
137
|
+
/**
|
|
138
|
+
* Get a registered function
|
|
139
|
+
*/
|
|
140
|
+
get: (name: string) => TypedFunction;
|
|
141
|
+
/**
|
|
142
|
+
* Register a factory function
|
|
143
|
+
*/
|
|
144
|
+
register: (factory: FactoryFunction) => void;
|
|
145
|
+
/**
|
|
146
|
+
* Get configuration
|
|
147
|
+
*/
|
|
148
|
+
config: () => MathTSConfig;
|
|
149
|
+
/**
|
|
150
|
+
* Update configuration
|
|
151
|
+
*/
|
|
152
|
+
configure: (config: Partial<MathTSConfig>) => void;
|
|
153
|
+
};
|
|
154
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/factory/factory.ts"],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