@danielsimonjr/mathts-core 0.14.3 → 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/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 -2593
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -13
- package/dist/internal.d.ts +33 -1344
- package/dist/internal.d.ts.map +1 -0
- 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 +8 -8
- package/dist/index-B4LIOfHN.d.ts +0 -449
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { BigNumber } from '../types/bignumber.js';
|
|
2
|
+
import { Complex } from '../types/complex.js';
|
|
3
|
+
import { Fraction } from '../types/fraction.js';
|
|
4
|
+
/** Any scalar core can do arithmetic on. */
|
|
5
|
+
export type NumericScalar = number | bigint | Complex | Fraction | BigNumber;
|
|
6
|
+
/** Add two scalar values, `x + y`. */
|
|
7
|
+
export declare function addScalar(x: NumericScalar, y: NumericScalar): NumericScalar;
|
|
8
|
+
/** Subtract two scalar values, `x − y` (order preserved through promotion). */
|
|
9
|
+
export declare function subtractScalar(x: NumericScalar, y: NumericScalar): NumericScalar;
|
|
10
|
+
/** Multiply two scalar values, `x · y`. */
|
|
11
|
+
export declare function multiplyScalar(x: NumericScalar, y: NumericScalar): NumericScalar;
|
|
12
|
+
/** Divide two scalar values, `x ÷ y` (order preserved through promotion). */
|
|
13
|
+
export declare function divideScalar(x: NumericScalar, y: NumericScalar): NumericScalar;
|
|
14
|
+
/**
|
|
15
|
+
* Raise `base` to the power `exp`, treating `exp` as a real exponent.
|
|
16
|
+
*
|
|
17
|
+
* The exact `.pow()` of an exact type (Fraction/BigNumber) only supports INTEGER
|
|
18
|
+
* exponents. A non-integer exponent of an exact base is generally irrational, so
|
|
19
|
+
* it cannot stay exact — those cases fall back to double-precision `Math.pow`,
|
|
20
|
+
* returning a plain `number`. (Without this guard, `BigNumber.pow(0.5)` silently
|
|
21
|
+
* returned 1 and `Fraction.pow(0.5)` threw `BigInt(0.5)`.)
|
|
22
|
+
*/
|
|
23
|
+
export declare function pow(base: NumericScalar, exp: NumericScalar): NumericScalar;
|
|
24
|
+
/** Absolute value. `abs(Complex)` returns the magnitude (a real number). */
|
|
25
|
+
export declare function abs(x: NumericScalar): NumericScalar;
|
|
26
|
+
/** Round toward zero (truncate). Complex components are truncated independently. */
|
|
27
|
+
export declare function fix(x: NumericScalar): NumericScalar;
|
|
28
|
+
/**
|
|
29
|
+
* Round to the nearest integer, half toward +∞ — matching `Math.round` and
|
|
30
|
+
* `Fraction.round`. `BigNumber.round` defaults to half-away-from-zero, so it is
|
|
31
|
+
* given `'halfCeil'` explicitly; otherwise negative half-integers would round
|
|
32
|
+
* type-dependently (`round(-2.5)` = −2 for number/Fraction but −3 for BigNumber).
|
|
33
|
+
* Complex components are rounded independently.
|
|
34
|
+
*/
|
|
35
|
+
export declare function round(x: NumericScalar): NumericScalar;
|
|
36
|
+
/**
|
|
37
|
+
* Equality. Floating-point operands compare with the configured tolerance
|
|
38
|
+
* (`relTol`/`absTol`); exact types (Fraction, BigNumber) compare exactly —
|
|
39
|
+
* tolerance is meaningless for an exact rational/decimal.
|
|
40
|
+
*/
|
|
41
|
+
export declare function equal(x: NumericScalar, y: NumericScalar, relTol?: number, absTol?: number): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* True for values math treats as real-numeric: `number`, `bigint`, `boolean`,
|
|
44
|
+
* `Fraction`, `BigNumber`. Mirrors mathjs semantics — `boolean` counts (it
|
|
45
|
+
* coerces to 0/1), while `Complex` is intentionally NOT numeric (callers test it
|
|
46
|
+
* separately), so `isNumeric(complex)` is `false`. The relocated Unit uses this as
|
|
47
|
+
* its value-type gate (`isNumeric(value) || isComplex(value)`), and mathjs accepts
|
|
48
|
+
* `new Unit(true)` — so booleans must pass.
|
|
49
|
+
*/
|
|
50
|
+
export declare function isNumeric(x: unknown): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Convert any scalar to a plain JS `number`. A non-real `Complex` (nonzero
|
|
53
|
+
* imaginary part) has no real-number value and throws.
|
|
54
|
+
*/
|
|
55
|
+
export declare function number(x: NumericScalar): number;
|
|
56
|
+
//# sourceMappingURL=scalar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scalar.d.ts","sourceRoot":"","sources":["../../src/arithmetic/scalar.ts"],"names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OAAO,GAAG,OAAO,CAQ7C;AAED;;;GAGG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,aAAa,GAAG,MAAM,CAS/C"}
|
package/dist/array.d.ts
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { Index, Matrix } from './is.js';
|
|
2
|
+
export type NestedArray<T> = T | NestedArray<T>[];
|
|
3
|
+
export interface IdentifiedValue<T> {
|
|
4
|
+
value: T;
|
|
5
|
+
identifier: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Calculate the size of a multi dimensional array.
|
|
9
|
+
* This function checks the size of the first entry, it does not validate
|
|
10
|
+
* whether all dimensions match. (use function `validate` for that)
|
|
11
|
+
* @param {Array} x
|
|
12
|
+
* @return {number[]} size
|
|
13
|
+
*/
|
|
14
|
+
export declare function arraySize<T>(x: NestedArray<T>): number[];
|
|
15
|
+
/**
|
|
16
|
+
* Validate whether each element in a multi dimensional array has
|
|
17
|
+
* a size corresponding to the provided size array.
|
|
18
|
+
* @param {Array} array Array to be validated
|
|
19
|
+
* @param {number[]} size Array with the size of each dimension
|
|
20
|
+
* @throws DimensionError
|
|
21
|
+
*/
|
|
22
|
+
export declare function validate<T>(array: NestedArray<T>, size: number[]): void;
|
|
23
|
+
/**
|
|
24
|
+
* Validate whether the source of the index matches the size of the Array
|
|
25
|
+
* @param {Array | Matrix} value Array to be validated
|
|
26
|
+
* @param {Index} index Index with the source information to validate
|
|
27
|
+
* @throws DimensionError
|
|
28
|
+
*/
|
|
29
|
+
export declare function validateIndexSourceSize(value: unknown[] | Matrix, index: Index): void;
|
|
30
|
+
/**
|
|
31
|
+
* Test whether index is an integer number with index >= 0 and index < length
|
|
32
|
+
* when length is provided
|
|
33
|
+
* @param {number} index Zero-based index
|
|
34
|
+
* @param {number} [length] Length of the array
|
|
35
|
+
*/
|
|
36
|
+
export declare function validateIndex(index: number | undefined, length?: number): void;
|
|
37
|
+
/**
|
|
38
|
+
* Test if an index has empty values
|
|
39
|
+
* @param {Index} index Zero-based index
|
|
40
|
+
*/
|
|
41
|
+
export declare function isEmptyIndex(index: Index): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Resize a multi dimensional array. The resized array is returned.
|
|
44
|
+
* @param {Array | number} array Array to be resized
|
|
45
|
+
* @param {number[]} size Array with the size of each dimension
|
|
46
|
+
* @param {*} [defaultValue=0] Value to be filled in new entries,
|
|
47
|
+
* zero by default. Specify for example `null`,
|
|
48
|
+
* to clearly see entries that are not explicitly
|
|
49
|
+
* set.
|
|
50
|
+
* @return {Array} array The resized array
|
|
51
|
+
*/
|
|
52
|
+
export declare function resize<T = unknown>(array: T | T[] | NestedArray<T>, size: number[], defaultValue?: T): NestedArray<T>;
|
|
53
|
+
/**
|
|
54
|
+
* Re-shape a multi dimensional array to fit the specified dimensions
|
|
55
|
+
* @param {Array} array Array to be reshaped
|
|
56
|
+
* @param {number[]} sizes List of sizes for each dimension
|
|
57
|
+
* @returns {Array} Array whose data has been formatted to fit the
|
|
58
|
+
* specified dimensions
|
|
59
|
+
*
|
|
60
|
+
* @throws {DimensionError} If the product of the new dimension sizes does
|
|
61
|
+
* not equal that of the old ones
|
|
62
|
+
*/
|
|
63
|
+
export declare function reshape<T = unknown>(array: NestedArray<T>, sizes: number[]): NestedArray<T>;
|
|
64
|
+
/**
|
|
65
|
+
* Replaces the wildcard -1 in the sizes array.
|
|
66
|
+
* @param {number[]} sizes List of sizes for each dimension. At most one wildcard.
|
|
67
|
+
* @param {number} currentLength Number of elements in the array.
|
|
68
|
+
* @throws {Error} If more than one wildcard or unable to replace it.
|
|
69
|
+
* @returns {number[]} The sizes array with wildcard replaced.
|
|
70
|
+
*/
|
|
71
|
+
export declare function processSizesWildcard(sizes: number[], currentLength: number): number[];
|
|
72
|
+
/**
|
|
73
|
+
* Squeeze a multi dimensional array
|
|
74
|
+
* @param {Array} array
|
|
75
|
+
* @param {Array} [size]
|
|
76
|
+
* @returns {Array} returns the array itself
|
|
77
|
+
*/
|
|
78
|
+
export declare function squeeze<T>(array: NestedArray<T>, size?: number[]): T | NestedArray<T>;
|
|
79
|
+
/**
|
|
80
|
+
* Unsqueeze a multi dimensional array: add dimensions when missing
|
|
81
|
+
*
|
|
82
|
+
* Parameter `size` will be mutated to match the new, unsqueezed matrix size.
|
|
83
|
+
*
|
|
84
|
+
* @param {Array} array
|
|
85
|
+
* @param {number} dims Desired number of dimensions of the array
|
|
86
|
+
* @param {number} [outer] Number of outer dimensions to be added
|
|
87
|
+
* @param {Array} [size] Current size of array.
|
|
88
|
+
* @returns {Array} returns the array itself
|
|
89
|
+
* @private
|
|
90
|
+
*/
|
|
91
|
+
export declare function unsqueeze<T>(array: NestedArray<T>, dims: number, outer?: number, size?: number[]): NestedArray<T>;
|
|
92
|
+
/**
|
|
93
|
+
* Flatten a multi dimensional array, put all elements in a one dimensional
|
|
94
|
+
* array
|
|
95
|
+
* @param {Array} array A multi dimensional array
|
|
96
|
+
* @param {boolean} isRectangular Optional. If the array is rectangular (not jagged)
|
|
97
|
+
* @return {Array} The flattened array (1 dimensional)
|
|
98
|
+
*/
|
|
99
|
+
export declare function flatten<T>(array: NestedArray<T>, isRectangular?: boolean): T[];
|
|
100
|
+
/**
|
|
101
|
+
* A safe map
|
|
102
|
+
* @param {Array} array
|
|
103
|
+
* @param {function} callback
|
|
104
|
+
*/
|
|
105
|
+
export declare function map<T, U>(array: T[], callback: (value: T, index: number, array: T[]) => U): U[];
|
|
106
|
+
/**
|
|
107
|
+
* A safe forEach
|
|
108
|
+
* @param {Array} array
|
|
109
|
+
* @param {function} callback
|
|
110
|
+
*/
|
|
111
|
+
export declare function forEach<T>(array: T[], callback: (value: T, index: number, array: T[]) => void): void;
|
|
112
|
+
/**
|
|
113
|
+
* A safe filter
|
|
114
|
+
* @param {Array} array
|
|
115
|
+
* @param {function} callback
|
|
116
|
+
*/
|
|
117
|
+
export declare function filter<T>(array: T[], callback: (value: T, index: number, array: T[]) => boolean): T[];
|
|
118
|
+
/**
|
|
119
|
+
* Filter values in an array given a regular expression
|
|
120
|
+
* @param {Array} array
|
|
121
|
+
* @param {RegExp} regexp
|
|
122
|
+
* @return {Array} Returns the filtered array
|
|
123
|
+
* @private
|
|
124
|
+
*/
|
|
125
|
+
export declare function filterRegExp(array: string[], regexp: RegExp): string[];
|
|
126
|
+
/**
|
|
127
|
+
* A safe join
|
|
128
|
+
* @param {Array} array
|
|
129
|
+
* @param {string} separator
|
|
130
|
+
*/
|
|
131
|
+
export declare function join<T>(array: T[], separator: string): string;
|
|
132
|
+
/**
|
|
133
|
+
* Assign a numeric identifier to every element of a sorted array
|
|
134
|
+
* @param {Array} a An array
|
|
135
|
+
* @return {Array} An array of objects containing the original value and its identifier
|
|
136
|
+
*/
|
|
137
|
+
export declare function identify<T>(a: T[]): IdentifiedValue<T>[];
|
|
138
|
+
/**
|
|
139
|
+
* Remove the numeric identifier from the elements
|
|
140
|
+
* @param {array} a An array
|
|
141
|
+
* @return {array} An array of values without identifiers
|
|
142
|
+
*/
|
|
143
|
+
export declare function generalize<T>(a: IdentifiedValue<T>[]): T[];
|
|
144
|
+
/**
|
|
145
|
+
* Check the datatype of a given object
|
|
146
|
+
* This is a low level implementation that should only be used by
|
|
147
|
+
* parent Matrix classes such as SparseMatrix or DenseMatrix
|
|
148
|
+
* This method does not validate Array Matrix shape
|
|
149
|
+
* @param {Array} array
|
|
150
|
+
* @param {function} typeOf Callback function to use to determine the type of a value
|
|
151
|
+
* @return {string}
|
|
152
|
+
*/
|
|
153
|
+
export declare function getArrayDataType(array: unknown[], typeOf: (value: unknown) => string): string | undefined;
|
|
154
|
+
/**
|
|
155
|
+
* Return the last item from an array
|
|
156
|
+
* @param {Array} array
|
|
157
|
+
* @returns {*}
|
|
158
|
+
*/
|
|
159
|
+
export declare function last<T>(array: T[]): T;
|
|
160
|
+
/**
|
|
161
|
+
* Get all but the last element of array.
|
|
162
|
+
*
|
|
163
|
+
* KNOWN DIVERGENCE (Bucket B slice 2): only `expression/src/utils/array.ts` had
|
|
164
|
+
* this; `functions/src/utils/array.ts` never defined it, and it was dead code
|
|
165
|
+
* even in expression (unused outside its own definition). Re-exported from
|
|
166
|
+
* expression's shim only — see the module header.
|
|
167
|
+
* @param {Array} array
|
|
168
|
+
* @returns {Array}
|
|
169
|
+
*/
|
|
170
|
+
export declare function initial<T>(array: T[]): T[];
|
|
171
|
+
/**
|
|
172
|
+
* Concatenates many arrays in the specified direction
|
|
173
|
+
* @param {...Array} arrays All the arrays to concatenate
|
|
174
|
+
* @param {number} concatDim The dimension on which to concatenate (zero-based)
|
|
175
|
+
* @returns {Array}
|
|
176
|
+
*/
|
|
177
|
+
export declare function concat<T>(...args: [...NestedArray<T>[], number]): NestedArray<T>[];
|
|
178
|
+
/**
|
|
179
|
+
* Receives two or more sizes and gets the broadcasted size for both.
|
|
180
|
+
* @param {...number[]} sizes Sizes to broadcast together
|
|
181
|
+
* @returns {number[]} The broadcasted size
|
|
182
|
+
*/
|
|
183
|
+
export declare function broadcastSizes(...sizes: number[][]): number[];
|
|
184
|
+
/**
|
|
185
|
+
* Checks if it's possible to broadcast a size to another size
|
|
186
|
+
* @param {number[]} size The size of the array to check
|
|
187
|
+
* @param {number[]} toSize The size of the array to validate if it can be broadcasted to
|
|
188
|
+
*/
|
|
189
|
+
export declare function checkBroadcastingRules(size: number[], toSize: number[]): void;
|
|
190
|
+
/**
|
|
191
|
+
* Broadcasts a single array to a certain size
|
|
192
|
+
* @param {Array} array Array to be broadcasted
|
|
193
|
+
* @param {number[]} toSize Size to broadcast the array
|
|
194
|
+
* @returns {Array} The broadcasted array
|
|
195
|
+
*/
|
|
196
|
+
export declare function broadcastTo<T>(array: NestedArray<T>, toSize: number[]): NestedArray<T>;
|
|
197
|
+
/**
|
|
198
|
+
* Broadcasts arrays and returns the broadcasted arrays in an array
|
|
199
|
+
* @param {...Array | any} arrays
|
|
200
|
+
* @returns {Array[]} The broadcasted arrays
|
|
201
|
+
*/
|
|
202
|
+
export declare function broadcastArrays<T>(...arrays: NestedArray<T>[]): NestedArray<T>[];
|
|
203
|
+
/**
|
|
204
|
+
* Stretches a matrix up to a certain size in a certain dimension
|
|
205
|
+
* @param {Array} arrayToStretch
|
|
206
|
+
* @param {number[]} sizeToStretch
|
|
207
|
+
* @param {number} dimToStretch
|
|
208
|
+
* @returns {Array} The stretched array
|
|
209
|
+
*/
|
|
210
|
+
export declare function stretch<T>(arrayToStretch: NestedArray<T>, sizeToStretch: number, dimToStretch: number): NestedArray<T>;
|
|
211
|
+
/**
|
|
212
|
+
* Retrieves a single element from an array given an index.
|
|
213
|
+
*
|
|
214
|
+
* @param {Array} array - The array from which to retrieve the value.
|
|
215
|
+
* @param {Array<number>} index - An array of indices specifying the position of the desired element in each dimension.
|
|
216
|
+
* @returns {*} - The value at the specified position in the array.
|
|
217
|
+
*
|
|
218
|
+
* @example
|
|
219
|
+
* const arr = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]];
|
|
220
|
+
* const index = [1, 0, 1];
|
|
221
|
+
* console.log(get(arr, index)); // 6
|
|
222
|
+
*/
|
|
223
|
+
export declare function get<T>(array: NestedArray<T>, index: number[]): T;
|
|
224
|
+
/**
|
|
225
|
+
* Recursively maps over each element of nested array using a provided callback function.
|
|
226
|
+
*
|
|
227
|
+
* @param {Array} array - The array to be mapped.
|
|
228
|
+
* @param {Function} callback - The function to execute on each element, taking three arguments:
|
|
229
|
+
* - `value` (any): The current element being processed in the array.
|
|
230
|
+
* - `index` (Array<number>): The index of the current element being processed in the array.
|
|
231
|
+
* - `array` (Array): The array `deepMap` was called upon.
|
|
232
|
+
* @param {boolean} [skipIndex=false] - If true, the callback function is called with only the value.
|
|
233
|
+
* @returns {Array} A new array with each element being the result of the callback function.
|
|
234
|
+
*/
|
|
235
|
+
export declare function deepMap<T, U>(array: NestedArray<T>, callback: ((value: T, index: number[], array: NestedArray<T>) => U) | ((value: T) => U), skipIndex?: boolean): NestedArray<U>;
|
|
236
|
+
/**
|
|
237
|
+
* Recursively iterates over each element in a multi-dimensional array and applies a callback function.
|
|
238
|
+
*
|
|
239
|
+
* @param {Array} array - The multi-dimensional array to iterate over.
|
|
240
|
+
* @param {Function} callback - The function to execute for each element. It receives three arguments:
|
|
241
|
+
* - {any} value: The current element being processed in the array.
|
|
242
|
+
* - {Array<number>} index: The index of the current element in each dimension.
|
|
243
|
+
* - {Array} array: The original array being processed.
|
|
244
|
+
* @param {boolean} [skipIndex=false] - If true, the callback function is called with only the value.
|
|
245
|
+
*/
|
|
246
|
+
export declare function deepForEach<T>(array: NestedArray<T>, callback: ((value: T, index: number[], array: NestedArray<T>) => void) | ((value: T) => void), skipIndex?: boolean): void;
|
|
247
|
+
/**
|
|
248
|
+
* Deep clones a multidimensional array
|
|
249
|
+
* @param {Array} array
|
|
250
|
+
* @returns {Array} cloned array
|
|
251
|
+
*/
|
|
252
|
+
export declare function clone<T>(array: T[]): T[];
|
|
253
|
+
//# sourceMappingURL=array.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../src/array.ts"],"names":[],"mappings":"AAsBA,OAAO,EAA4C,KAAK,EAAE,MAAM,EAAkB,MAAM,SAAS,CAAC;AAOlG,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;AAGlD,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,KAAK,EAAE,CAAC,CAAC;IACT,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,CAUxD;AAuCD;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAWvE;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,KAAK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;GAWG;AACH,wBAAgB,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,CAYhE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAC1B,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,EACrB,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,EACvF,SAAS,GAAE,OAAe,GACzB,WAAW,CAAC,CAAC,CAAC,CA0ChB;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,EACrB,QAAQ,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC,EAC7F,SAAS,GAAE,OAAe,GACzB,IAAI,CAsCN;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAExC"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural contract for the BigNumber values handled by this formatter.
|
|
3
|
+
* Captures exactly the methods/properties used here. The configured BigNumber
|
|
4
|
+
* implementation (e.g. decimal.js) provides these; the project's `BigNumber`
|
|
5
|
+
* type alias points at a minimal local Decimal that does not declare them all,
|
|
6
|
+
* so we model the runtime contract explicitly.
|
|
7
|
+
*/
|
|
8
|
+
export interface BigNumberValue {
|
|
9
|
+
e: number;
|
|
10
|
+
constructor: new (value: number | string) => BigNumberValue;
|
|
11
|
+
isFinite(): boolean;
|
|
12
|
+
isNaN(): boolean;
|
|
13
|
+
isZero(): boolean;
|
|
14
|
+
isInteger(): boolean;
|
|
15
|
+
gt(other: number | BigNumberValue): boolean;
|
|
16
|
+
greaterThan(other: number | BigNumberValue): boolean;
|
|
17
|
+
lessThan(other: number | BigNumberValue): boolean;
|
|
18
|
+
add(other: number | BigNumberValue): BigNumberValue;
|
|
19
|
+
sub(other: number | BigNumberValue): BigNumberValue;
|
|
20
|
+
mul(other: number | BigNumberValue): BigNumberValue;
|
|
21
|
+
pow(exp: number | BigNumberValue): BigNumberValue;
|
|
22
|
+
toNumber(): number;
|
|
23
|
+
toFixed(places?: number): string;
|
|
24
|
+
toExponential(places?: number): string;
|
|
25
|
+
toPrecision(sd?: number): string;
|
|
26
|
+
toSignificantDigits(sd?: number): BigNumberValue;
|
|
27
|
+
toBinary(): string;
|
|
28
|
+
toOctal(): string;
|
|
29
|
+
toHexadecimal(): string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Convert a BigNumber to a formatted string representation.
|
|
33
|
+
*
|
|
34
|
+
* Syntax:
|
|
35
|
+
*
|
|
36
|
+
* format(value)
|
|
37
|
+
* format(value, options)
|
|
38
|
+
* format(value, precision)
|
|
39
|
+
* format(value, fn)
|
|
40
|
+
*
|
|
41
|
+
* Where:
|
|
42
|
+
*
|
|
43
|
+
* {number} value The value to be formatted
|
|
44
|
+
* {Object} options An object with formatting options. Available options:
|
|
45
|
+
* {string} notation
|
|
46
|
+
* Number notation. Choose from:
|
|
47
|
+
* 'fixed' Always use regular number notation.
|
|
48
|
+
* For example '123.40' and '14000000'
|
|
49
|
+
* 'exponential' Always use exponential notation.
|
|
50
|
+
* For example '1.234e+2' and '1.4e+7'
|
|
51
|
+
* 'auto' (default) Regular number notation for numbers
|
|
52
|
+
* having an absolute value between
|
|
53
|
+
* `lower` and `upper` bounds, and uses
|
|
54
|
+
* exponential notation elsewhere.
|
|
55
|
+
* Lower bound is included, upper bound
|
|
56
|
+
* is excluded.
|
|
57
|
+
* For example '123.4' and '1.4e7'.
|
|
58
|
+
* 'bin', 'oct, or
|
|
59
|
+
* 'hex' Format the number using binary, octal,
|
|
60
|
+
* or hexadecimal notation.
|
|
61
|
+
* For example '0b1101' and '0x10fe'.
|
|
62
|
+
* {number} wordSize The word size in bits to use for formatting
|
|
63
|
+
* in binary, octal, or hexadecimal notation.
|
|
64
|
+
* To be used only with 'bin', 'oct', or 'hex'
|
|
65
|
+
* values for 'notation' option. When this option
|
|
66
|
+
* is defined the value is formatted as a signed
|
|
67
|
+
* twos complement integer of the given word size
|
|
68
|
+
* and the size suffix is appended to the output.
|
|
69
|
+
* For example
|
|
70
|
+
* format(-1, {notation: 'hex', wordSize: 8}) === '0xffi8'.
|
|
71
|
+
* Default value is undefined.
|
|
72
|
+
* {number} precision A number between 0 and 16 to round
|
|
73
|
+
* the digits of the number.
|
|
74
|
+
* In case of notations 'exponential',
|
|
75
|
+
* 'engineering', and 'auto',
|
|
76
|
+
* `precision` defines the total
|
|
77
|
+
* number of significant digits returned.
|
|
78
|
+
* In case of notation 'fixed',
|
|
79
|
+
* `precision` defines the number of
|
|
80
|
+
* significant digits after the decimal
|
|
81
|
+
* point.
|
|
82
|
+
* `precision` is undefined by default.
|
|
83
|
+
* {number} lowerExp Exponent determining the lower boundary
|
|
84
|
+
* for formatting a value with an exponent
|
|
85
|
+
* when `notation='auto`.
|
|
86
|
+
* Default value is `-3`.
|
|
87
|
+
* {number} upperExp Exponent determining the upper boundary
|
|
88
|
+
* for formatting a value with an exponent
|
|
89
|
+
* when `notation='auto`.
|
|
90
|
+
* Default value is `5`.
|
|
91
|
+
* {Function} fn A custom formatting function. Can be used to override the
|
|
92
|
+
* built-in notations. Function `fn` is called with `value` as
|
|
93
|
+
* parameter and must return a string. Is useful for example to
|
|
94
|
+
* format all values inside a matrix in a particular way.
|
|
95
|
+
*
|
|
96
|
+
* Examples:
|
|
97
|
+
*
|
|
98
|
+
* format(6.4) // '6.4'
|
|
99
|
+
* format(1240000) // '1.24e6'
|
|
100
|
+
* format(1/3) // '0.3333333333333333'
|
|
101
|
+
* format(1/3, 3) // '0.333'
|
|
102
|
+
* format(21385, 2) // '21000'
|
|
103
|
+
* format(12e8, {notation: 'fixed'}) // returns '1200000000'
|
|
104
|
+
* format(2.3, {notation: 'fixed', precision: 4}) // returns '2.3000'
|
|
105
|
+
* format(52.8, {notation: 'exponential'}) // returns '5.28e+1'
|
|
106
|
+
* format(12400, {notation: 'engineering'}) // returns '12.400e+3'
|
|
107
|
+
*
|
|
108
|
+
* @param {BigNumber} value
|
|
109
|
+
* @param {Object | Function | number | BigNumber} [options]
|
|
110
|
+
* @return {string} str The formatted value
|
|
111
|
+
*/
|
|
112
|
+
export declare function format(value: unknown, options?: unknown): string;
|
|
113
|
+
/**
|
|
114
|
+
* Format a BigNumber in engineering notation. Like '1.23e+6', '2.3e+0', '3.500e-3'
|
|
115
|
+
* @param {BigNumber} value
|
|
116
|
+
* @param {number} [precision] Optional number of significant figures to return.
|
|
117
|
+
*/
|
|
118
|
+
export declare function toEngineering(value: BigNumberValue, precision?: number): string;
|
|
119
|
+
/**
|
|
120
|
+
* Format a number in exponential notation. Like '1.23e+5', '2.3e+0', '3.500e-3'
|
|
121
|
+
* @param {BigNumber} value
|
|
122
|
+
* @param {number} [precision] Number of digits in formatted output.
|
|
123
|
+
* If not provided, the maximum available digits
|
|
124
|
+
* is used.
|
|
125
|
+
* @returns {string} str
|
|
126
|
+
*/
|
|
127
|
+
export declare function toExponential(value: BigNumberValue, precision?: number): string;
|
|
128
|
+
/**
|
|
129
|
+
* Format a number with fixed notation.
|
|
130
|
+
* @param {BigNumber} value
|
|
131
|
+
* @param {number} [precision=undefined] Optional number of decimals after the
|
|
132
|
+
* decimal point. Undefined by default.
|
|
133
|
+
*/
|
|
134
|
+
export declare function toFixed(value: BigNumberValue, precision?: number): string;
|
|
135
|
+
//# sourceMappingURL=bignumber-formatter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bignumber-formatter.d.ts","sourceRoot":"","sources":["../src/bignumber-formatter.ts"],"names":[],"mappings":"AAqBA;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,CAAC,EAAE,MAAM,CAAC;IACV,WAAW,EAAE,KAAK,KAAK,EAAE,MAAM,GAAG,MAAM,KAAK,cAAc,CAAC;IAC5D,QAAQ,IAAI,OAAO,CAAC;IACpB,KAAK,IAAI,OAAO,CAAC;IACjB,MAAM,IAAI,OAAO,CAAC;IAClB,SAAS,IAAI,OAAO,CAAC;IACrB,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,GAAG,OAAO,CAAC;IAC5C,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,GAAG,OAAO,CAAC;IACrD,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,GAAG,OAAO,CAAC;IAClD,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,GAAG,cAAc,CAAC;IACpD,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,GAAG,cAAc,CAAC;IACpD,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,GAAG,cAAc,CAAC;IACpD,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,GAAG,cAAc,CAAC;IAClD,QAAQ,IAAI,MAAM,CAAC;IACnB,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACvC,WAAW,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,mBAAmB,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,cAAc,CAAC;IACjD,QAAQ,IAAI,MAAM,CAAC;IACnB,OAAO,IAAI,MAAM,CAAC;IAClB,aAAa,IAAI,MAAM,CAAC;CACzB;AA2CD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgFG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAkGhE;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAe/E;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAM/E;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,cAAc,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAEzE"}
|
|
@@ -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,QAAQ,IAAI,MAAM,GAAG,SAAS,CAAC;CAChC;AAED,UAAU,YAAY,CAAC,CAAC,GAAG,OAAO;IAChC,OAAO,EAAE,CAAC,EAAE,CAAC;IACb,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,OAAO,CAO7D;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC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Options {
|
|
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"}
|