mathjs 15.0.0 → 15.1.1
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/HISTORY.md +34 -6
- package/NOTICE +1 -1
- package/README.md +7 -7
- package/bin/cli.js +1 -1
- package/lib/browser/math.js +1 -1
- package/lib/browser/math.js.LICENSE.txt +3 -3
- package/lib/browser/math.js.map +1 -1
- package/lib/cjs/core/function/import.js +7 -0
- package/lib/cjs/core/function/typed.js +1 -1
- package/lib/cjs/entry/dependenciesAny/dependenciesBernoulli.generated.js +25 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesConstantNode.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesEqual.generated.js +0 -2
- package/lib/cjs/entry/dependenciesAny/dependenciesIsBounded.generated.js +17 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesIsFinite.generated.js +21 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesIsInteger.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesSimplifyConstant.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny/dependenciesUnitClass.generated.js +0 -2
- package/lib/cjs/entry/dependenciesAny/dependenciesZeta.generated.js +2 -0
- package/lib/cjs/entry/dependenciesAny.generated.js +21 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesBernoulli.generated.js +21 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesConstantNode.generated.js +2 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesIsBounded.generated.js +17 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesIsFinite.generated.js +21 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesSimplifyConstant.generated.js +2 -0
- package/lib/cjs/entry/dependenciesNumber/dependenciesZeta.generated.js +2 -0
- package/lib/cjs/entry/dependenciesNumber.generated.js +21 -0
- package/lib/cjs/entry/impureFunctionsAny.generated.js +217 -212
- package/lib/cjs/entry/impureFunctionsNumber.generated.js +82 -77
- package/lib/cjs/entry/pureFunctionsAny.generated.js +668 -652
- package/lib/cjs/entry/pureFunctionsNumber.generated.js +155 -140
- package/lib/cjs/expression/embeddedDocs/embeddedDocs.js +6 -0
- package/lib/cjs/expression/embeddedDocs/function/combinatorics/stirlingS2.js +2 -2
- package/lib/cjs/expression/embeddedDocs/function/probability/bernoulli.js +14 -0
- package/lib/cjs/expression/embeddedDocs/function/utils/isBounded.js +14 -0
- package/lib/cjs/expression/embeddedDocs/function/utils/isFinite.js +14 -0
- package/lib/cjs/expression/embeddedDocs/function/utils/isNaN.js +1 -1
- package/lib/cjs/expression/embeddedDocs/function/utils/isNumeric.js +1 -1
- package/lib/cjs/expression/node/AccessorNode.js +36 -7
- package/lib/cjs/expression/node/ConstantNode.js +4 -4
- package/lib/cjs/expression/node/FunctionNode.js +20 -5
- package/lib/cjs/expression/parse.js +62 -14
- package/lib/cjs/factoriesAny.js +21 -0
- package/lib/cjs/factoriesNumber.js +23 -2
- package/lib/cjs/function/algebra/polynomialRoot.js +4 -0
- package/lib/cjs/function/algebra/simplifyConstant.js +3 -2
- package/lib/cjs/function/arithmetic/add.js +8 -1
- package/lib/cjs/function/arithmetic/cbrt.js +7 -6
- package/lib/cjs/function/arithmetic/ceil.js +10 -2
- package/lib/cjs/function/arithmetic/exp.js +7 -5
- package/lib/cjs/function/arithmetic/expm1.js +6 -5
- package/lib/cjs/function/arithmetic/fix.js +10 -2
- package/lib/cjs/function/arithmetic/floor.js +10 -2
- package/lib/cjs/function/arithmetic/log.js +13 -0
- package/lib/cjs/function/arithmetic/mod.js +8 -2
- package/lib/cjs/function/arithmetic/nthRoot.js +9 -3
- package/lib/cjs/function/arithmetic/nthRoots.js +12 -11
- package/lib/cjs/function/matrix/map.js +6 -0
- package/lib/cjs/function/probability/bernoulli.js +108 -0
- package/lib/cjs/function/relational/compare.js +6 -0
- package/lib/cjs/function/relational/compareNatural.js +8 -2
- package/lib/cjs/function/relational/deepEqual.js +8 -3
- package/lib/cjs/function/relational/equal.js +17 -5
- package/lib/cjs/function/relational/unequal.js +14 -2
- package/lib/cjs/function/set/setDistinct.js +2 -1
- package/lib/cjs/function/special/zeta.js +3 -2
- package/lib/cjs/function/string/format.js +9 -0
- package/lib/cjs/function/utils/isBounded.js +54 -0
- package/lib/cjs/function/utils/isFinite.js +57 -0
- package/lib/cjs/function/utils/isInteger.js +7 -15
- package/lib/cjs/function/utils/isNaN.js +1 -1
- package/lib/cjs/function/utils/isNumeric.js +1 -1
- package/lib/cjs/function/utils/numeric.js +6 -0
- package/lib/cjs/header.js +3 -3
- package/lib/cjs/json/replacer.js +1 -1
- package/lib/cjs/plain/number/probability.js +2 -2
- package/lib/cjs/plain/number/trigonometry.js +1 -1
- package/lib/cjs/type/bigint.js +5 -0
- package/lib/cjs/type/boolean.js +6 -0
- package/lib/cjs/type/complex/function/complex.js +6 -0
- package/lib/cjs/type/fraction/function/fraction.js +9 -1
- package/lib/cjs/type/matrix/SparseMatrix.js +24 -4
- package/lib/cjs/type/matrix/function/index.js +8 -0
- package/lib/cjs/type/matrix/function/matrix.js +6 -0
- package/lib/cjs/type/matrix/function/sparse.js +4 -0
- package/lib/cjs/type/string.js +4 -0
- package/lib/cjs/type/unit/Unit.js +12 -8
- package/lib/cjs/type/unit/function/unit.js +8 -0
- package/lib/cjs/utils/number.js +7 -7
- package/lib/cjs/utils/optimizeCallback.js +13 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/core/function/import.js +7 -0
- package/lib/esm/core/function/typed.js +1 -1
- package/lib/esm/entry/dependenciesAny/dependenciesBernoulli.generated.js +18 -0
- package/lib/esm/entry/dependenciesAny/dependenciesConstantNode.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesEqual.generated.js +0 -2
- package/lib/esm/entry/dependenciesAny/dependenciesIsBounded.generated.js +10 -0
- package/lib/esm/entry/dependenciesAny/dependenciesIsFinite.generated.js +14 -0
- package/lib/esm/entry/dependenciesAny/dependenciesIsInteger.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesSimplifyConstant.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny/dependenciesUnitClass.generated.js +0 -2
- package/lib/esm/entry/dependenciesAny/dependenciesZeta.generated.js +2 -0
- package/lib/esm/entry/dependenciesAny.generated.js +3 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesBernoulli.generated.js +14 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesConstantNode.generated.js +2 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesIsBounded.generated.js +10 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesIsFinite.generated.js +14 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesSimplifyConstant.generated.js +2 -0
- package/lib/esm/entry/dependenciesNumber/dependenciesZeta.generated.js +2 -0
- package/lib/esm/entry/dependenciesNumber.generated.js +3 -0
- package/lib/esm/entry/impureFunctionsAny.generated.js +219 -214
- package/lib/esm/entry/impureFunctionsNumber.generated.js +84 -79
- package/lib/esm/entry/pureFunctionsAny.generated.js +665 -649
- package/lib/esm/entry/pureFunctionsNumber.generated.js +154 -139
- package/lib/esm/expression/embeddedDocs/embeddedDocs.js +6 -0
- package/lib/esm/expression/embeddedDocs/function/combinatorics/stirlingS2.js +2 -2
- package/lib/esm/expression/embeddedDocs/function/probability/bernoulli.js +8 -0
- package/lib/esm/expression/embeddedDocs/function/utils/isBounded.js +8 -0
- package/lib/esm/expression/embeddedDocs/function/utils/isFinite.js +8 -0
- package/lib/esm/expression/embeddedDocs/function/utils/isNaN.js +1 -1
- package/lib/esm/expression/embeddedDocs/function/utils/isNumeric.js +1 -1
- package/lib/esm/expression/node/AccessorNode.js +36 -7
- package/lib/esm/expression/node/ConstantNode.js +4 -4
- package/lib/esm/expression/node/FunctionNode.js +20 -5
- package/lib/esm/expression/parse.js +62 -14
- package/lib/esm/factoriesAny.js +3 -0
- package/lib/esm/factoriesNumber.js +3 -0
- package/lib/esm/function/algebra/polynomialRoot.js +4 -0
- package/lib/esm/function/algebra/simplifyConstant.js +3 -2
- package/lib/esm/function/arithmetic/add.js +8 -1
- package/lib/esm/function/arithmetic/cbrt.js +7 -6
- package/lib/esm/function/arithmetic/ceil.js +10 -2
- package/lib/esm/function/arithmetic/exp.js +7 -5
- package/lib/esm/function/arithmetic/expm1.js +6 -5
- package/lib/esm/function/arithmetic/fix.js +10 -2
- package/lib/esm/function/arithmetic/floor.js +10 -2
- package/lib/esm/function/arithmetic/log.js +13 -0
- package/lib/esm/function/arithmetic/mod.js +8 -2
- package/lib/esm/function/arithmetic/nthRoot.js +9 -3
- package/lib/esm/function/arithmetic/nthRoots.js +12 -11
- package/lib/esm/function/matrix/map.js +6 -0
- package/lib/esm/function/probability/bernoulli.js +102 -0
- package/lib/esm/function/relational/compare.js +6 -0
- package/lib/esm/function/relational/compareNatural.js +8 -2
- package/lib/esm/function/relational/deepEqual.js +8 -3
- package/lib/esm/function/relational/equal.js +17 -5
- package/lib/esm/function/relational/unequal.js +14 -2
- package/lib/esm/function/set/setDistinct.js +2 -1
- package/lib/esm/function/special/zeta.js +3 -2
- package/lib/esm/function/string/format.js +9 -0
- package/lib/esm/function/utils/isBounded.js +48 -0
- package/lib/esm/function/utils/isFinite.js +51 -0
- package/lib/esm/function/utils/isInteger.js +7 -15
- package/lib/esm/function/utils/isNaN.js +1 -1
- package/lib/esm/function/utils/isNumeric.js +1 -1
- package/lib/esm/function/utils/numeric.js +6 -0
- package/lib/esm/header.js +1 -1
- package/lib/esm/json/replacer.js +1 -1
- package/lib/esm/plain/number/probability.js +2 -2
- package/lib/esm/plain/number/trigonometry.js +1 -1
- package/lib/esm/type/bigint.js +5 -0
- package/lib/esm/type/boolean.js +6 -0
- package/lib/esm/type/complex/function/complex.js +6 -0
- package/lib/esm/type/fraction/function/fraction.js +9 -1
- package/lib/esm/type/matrix/SparseMatrix.js +24 -4
- package/lib/esm/type/matrix/function/index.js +8 -0
- package/lib/esm/type/matrix/function/matrix.js +6 -0
- package/lib/esm/type/matrix/function/sparse.js +4 -0
- package/lib/esm/type/string.js +4 -0
- package/lib/esm/type/unit/Unit.js +12 -8
- package/lib/esm/type/unit/function/unit.js +8 -0
- package/lib/esm/utils/number.js +7 -7
- package/lib/esm/utils/optimizeCallback.js +13 -1
- package/lib/esm/version.js +1 -1
- package/package.json +15 -15
- package/types/index.d.ts +580 -237
|
@@ -39,6 +39,14 @@ export var createIndex = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
39
39
|
*
|
|
40
40
|
* bignumber, boolean, complex, matrix, number, string, unit
|
|
41
41
|
*
|
|
42
|
+
* History:
|
|
43
|
+
*
|
|
44
|
+
* v? Created
|
|
45
|
+
* v2 Dropped support for `[start, end, step]` arguments in favor
|
|
46
|
+
* of lists of arbitrary values; added support for Range
|
|
47
|
+
* objects.
|
|
48
|
+
* v11.10 Added support for arrays of booleans as indices.
|
|
49
|
+
*
|
|
42
50
|
* @param {...*} ranges Zero or more ranges or numbers.
|
|
43
51
|
* @return {Index} Returns the created index
|
|
44
52
|
*/
|
|
@@ -35,6 +35,12 @@ export var createMatrix = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
35
35
|
*
|
|
36
36
|
* bignumber, boolean, complex, index, number, string, unit, sparse
|
|
37
37
|
*
|
|
38
|
+
* History:
|
|
39
|
+
*
|
|
40
|
+
* v0.5 Created
|
|
41
|
+
* v1.5 Support dense or sparse Matrix types; allow construction
|
|
42
|
+
* from string, Array, or another Matrix.
|
|
43
|
+
*
|
|
38
44
|
* @param {Array | Matrix} [data] A multi dimensional array
|
|
39
45
|
* @param {string} [format] The Matrix storage format, either `'dense'` or `'sparse'`
|
|
40
46
|
* @param {string} [datatype] Type of the values
|
|
@@ -35,6 +35,10 @@ export var createSparse = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
35
35
|
*
|
|
36
36
|
* bignumber, boolean, complex, index, number, string, unit, matrix
|
|
37
37
|
*
|
|
38
|
+
* History:
|
|
39
|
+
*
|
|
40
|
+
* v1.5 Created
|
|
41
|
+
*
|
|
38
42
|
* @param {Array | Matrix} [data] A two dimensional array
|
|
39
43
|
*
|
|
40
44
|
* @return {Matrix} The created matrix
|
package/lib/esm/type/string.js
CHANGED
|
@@ -29,6 +29,10 @@ export var createString = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
|
29
29
|
*
|
|
30
30
|
* bignumber, boolean, complex, index, matrix, number, unit
|
|
31
31
|
*
|
|
32
|
+
* History:
|
|
33
|
+
*
|
|
34
|
+
* v0.9 Created
|
|
35
|
+
*
|
|
32
36
|
* @param {* | Array | Matrix | null} [value] A value to convert to a string
|
|
33
37
|
* @return {string | Array | Matrix} The created string
|
|
34
38
|
*/
|
|
@@ -9,7 +9,7 @@ import { endsWith } from '../../utils/string.js';
|
|
|
9
9
|
import { clone, hasOwnProperty } from '../../utils/object.js';
|
|
10
10
|
import { createBigNumberPi as createPi } from '../../utils/bignumber/constants.js';
|
|
11
11
|
var name = 'Unit';
|
|
12
|
-
var dependencies = ['?on', 'config', 'addScalar', 'subtractScalar', 'multiplyScalar', 'divideScalar', 'pow', 'abs', 'fix', 'round', 'equal', 'isNumeric', 'format', '
|
|
12
|
+
var dependencies = ['?on', 'config', 'addScalar', 'subtractScalar', 'multiplyScalar', 'divideScalar', 'pow', 'abs', 'fix', 'round', 'equal', 'isNumeric', 'format', 'number', 'Complex', 'BigNumber', 'Fraction'];
|
|
13
13
|
export var createUnitClass = /* #__PURE__ */factory(name, dependencies, _ref => {
|
|
14
14
|
var {
|
|
15
15
|
on,
|
|
@@ -25,13 +25,15 @@ export var createUnitClass = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
25
25
|
equal,
|
|
26
26
|
isNumeric,
|
|
27
27
|
format,
|
|
28
|
-
toBest,
|
|
29
28
|
number: _number,
|
|
30
29
|
Complex,
|
|
31
30
|
BigNumber: _BigNumber,
|
|
32
31
|
Fraction: _Fraction
|
|
33
32
|
} = _ref;
|
|
34
33
|
var toNumber = _number;
|
|
34
|
+
var fixPrefixDefault = false;
|
|
35
|
+
var skipAutomaticSimplificationDefault = true;
|
|
36
|
+
|
|
35
37
|
/**
|
|
36
38
|
* A unit can be constructed in the following ways:
|
|
37
39
|
*
|
|
@@ -58,13 +60,13 @@ export var createUnitClass = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
58
60
|
if (!(value === null || value === undefined || isNumeric(value) || isComplex(value))) {
|
|
59
61
|
throw new TypeError('First parameter in Unit constructor must be number, BigNumber, Fraction, Complex, or undefined');
|
|
60
62
|
}
|
|
61
|
-
this.fixPrefix =
|
|
63
|
+
this.fixPrefix = fixPrefixDefault; // if true, function format will not search for the
|
|
62
64
|
// best prefix but leave it as initially provided.
|
|
63
65
|
// fixPrefix is set true by the method Unit.to
|
|
64
66
|
|
|
65
67
|
// The justification behind this is that if the constructor is explicitly called,
|
|
66
68
|
// the caller wishes the units to be returned exactly as supplied.
|
|
67
|
-
this.skipAutomaticSimplification =
|
|
69
|
+
this.skipAutomaticSimplification = skipAutomaticSimplificationDefault;
|
|
68
70
|
if (valuelessUnit === undefined) {
|
|
69
71
|
this.units = [];
|
|
70
72
|
this.dimensions = BASE_DIMENSIONS.map(x => 0);
|
|
@@ -855,14 +857,15 @@ export var createUnitClass = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
855
857
|
* Get a JSON representation of the unit
|
|
856
858
|
* @memberof Unit
|
|
857
859
|
* @returns {Object} Returns a JSON object structured as:
|
|
858
|
-
* `{"mathjs": "Unit", "value": 2, "unit": "cm", "fixPrefix": false}`
|
|
860
|
+
* `{"mathjs": "Unit", "value": 2, "unit": "cm", "fixPrefix": false, "skipSimp": true}`
|
|
859
861
|
*/
|
|
860
862
|
Unit.prototype.toJSON = function () {
|
|
861
863
|
return {
|
|
862
864
|
mathjs: 'Unit',
|
|
863
865
|
value: this._denormalize(this.value),
|
|
864
866
|
unit: this.units.length > 0 ? this.formatUnits() : null,
|
|
865
|
-
fixPrefix: this.fixPrefix
|
|
867
|
+
fixPrefix: this.fixPrefix,
|
|
868
|
+
skipSimp: this.skipAutomaticSimplification
|
|
866
869
|
};
|
|
867
870
|
};
|
|
868
871
|
|
|
@@ -874,9 +877,10 @@ export var createUnitClass = /* #__PURE__ */factory(name, dependencies, _ref =>
|
|
|
874
877
|
* @return {Unit}
|
|
875
878
|
*/
|
|
876
879
|
Unit.fromJSON = function (json) {
|
|
877
|
-
var _json$unit;
|
|
880
|
+
var _json$unit, _json$fixPrefix, _json$skipSimp;
|
|
878
881
|
var unit = new Unit(json.value, (_json$unit = json.unit) !== null && _json$unit !== void 0 ? _json$unit : undefined);
|
|
879
|
-
unit.fixPrefix = json.fixPrefix
|
|
882
|
+
unit.fixPrefix = (_json$fixPrefix = json.fixPrefix) !== null && _json$fixPrefix !== void 0 ? _json$fixPrefix : fixPrefixDefault;
|
|
883
|
+
unit.skipAutomaticSimplification = (_json$skipSimp = json.skipSimp) !== null && _json$skipSimp !== void 0 ? _json$skipSimp : skipAutomaticSimplificationDefault;
|
|
880
884
|
return unit;
|
|
881
885
|
};
|
|
882
886
|
|
|
@@ -32,6 +32,14 @@ export var createUnitFunction = /* #__PURE__ */factory(name, dependencies, _ref
|
|
|
32
32
|
*
|
|
33
33
|
* bignumber, boolean, complex, index, matrix, number, string, createUnit
|
|
34
34
|
*
|
|
35
|
+
* History:
|
|
36
|
+
*
|
|
37
|
+
* v0.5 Created
|
|
38
|
+
* v0.16 Support conversion from BigNumber
|
|
39
|
+
* v2.5 Support BigNumber and Fraction values in units
|
|
40
|
+
* v2.6 Support Complex values in units
|
|
41
|
+
* v11.1 Allow the type of unit to be specifed by a unit (not just string)
|
|
42
|
+
*
|
|
35
43
|
* @param {* | Array | Matrix} args A number and unit.
|
|
36
44
|
* @return {Unit | Array | Matrix} The created unit
|
|
37
45
|
*/
|
package/lib/esm/utils/number.js
CHANGED
|
@@ -13,7 +13,7 @@ export function isInteger(value) {
|
|
|
13
13
|
if (typeof value === 'boolean') {
|
|
14
14
|
return true;
|
|
15
15
|
}
|
|
16
|
-
return isFinite(value) ? value === Math.round(value) : false;
|
|
16
|
+
return Number.isFinite(value) ? value === Math.round(value) : false;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -105,7 +105,7 @@ export var cbrt = Math.cbrt || function cbrt(x) {
|
|
|
105
105
|
if (negate) {
|
|
106
106
|
x = -x;
|
|
107
107
|
}
|
|
108
|
-
if (isFinite(x)) {
|
|
108
|
+
if (Number.isFinite(x)) {
|
|
109
109
|
result = Math.exp(Math.log(x) / 3);
|
|
110
110
|
// from https://en.wikipedia.org/wiki/Cube_root#Numerical_methods
|
|
111
111
|
result = (x / (result * result) + 2 * result) / 3;
|
|
@@ -381,7 +381,7 @@ export function splitNumber(value) {
|
|
|
381
381
|
* @param {number} [precision] Optional number of significant figures to return.
|
|
382
382
|
*/
|
|
383
383
|
export function toEngineering(value, precision) {
|
|
384
|
-
if (isNaN(value) || !isFinite(value)) {
|
|
384
|
+
if (isNaN(value) || !Number.isFinite(value)) {
|
|
385
385
|
return String(value);
|
|
386
386
|
}
|
|
387
387
|
var split = splitNumber(value);
|
|
@@ -430,7 +430,7 @@ export function toEngineering(value, precision) {
|
|
|
430
430
|
* decimal point. null by default.
|
|
431
431
|
*/
|
|
432
432
|
export function toFixed(value, precision) {
|
|
433
|
-
if (isNaN(value) || !isFinite(value)) {
|
|
433
|
+
if (isNaN(value) || !Number.isFinite(value)) {
|
|
434
434
|
return String(value);
|
|
435
435
|
}
|
|
436
436
|
var splitValue = splitNumber(value);
|
|
@@ -465,7 +465,7 @@ export function toFixed(value, precision) {
|
|
|
465
465
|
* is used.
|
|
466
466
|
*/
|
|
467
467
|
export function toExponential(value, precision) {
|
|
468
|
-
if (isNaN(value) || !isFinite(value)) {
|
|
468
|
+
if (isNaN(value) || !Number.isFinite(Number(value))) {
|
|
469
469
|
return String(value);
|
|
470
470
|
}
|
|
471
471
|
|
|
@@ -496,7 +496,7 @@ export function toExponential(value, precision) {
|
|
|
496
496
|
* @return {string}
|
|
497
497
|
*/
|
|
498
498
|
export function toPrecision(value, precision, options) {
|
|
499
|
-
if (isNaN(value) || !isFinite(value)) {
|
|
499
|
+
if (isNaN(value) || !Number.isFinite(value)) {
|
|
500
500
|
return String(value);
|
|
501
501
|
}
|
|
502
502
|
|
|
@@ -635,7 +635,7 @@ export function nearlyEqual(a, b) {
|
|
|
635
635
|
if (isNaN(a) || isNaN(b)) {
|
|
636
636
|
return false;
|
|
637
637
|
}
|
|
638
|
-
if (!isFinite(a) || !isFinite(b)) {
|
|
638
|
+
if (!Number.isFinite(a) || !Number.isFinite(b)) {
|
|
639
639
|
return a === b;
|
|
640
640
|
}
|
|
641
641
|
if (a === b) {
|
|
@@ -17,7 +17,19 @@ export function optimizeCallback(callback, array, name, isUnary) {
|
|
|
17
17
|
if (isUnary) {
|
|
18
18
|
numberOfArguments = 1;
|
|
19
19
|
} else {
|
|
20
|
-
var
|
|
20
|
+
var size = array.isMatrix ? array.size() : arraySize(array);
|
|
21
|
+
|
|
22
|
+
// Check the size of the last dimension to see if the array/matrix is empty
|
|
23
|
+
var isEmpty = size.length ? size[size.length - 1] === 0 : true;
|
|
24
|
+
if (isEmpty) {
|
|
25
|
+
// don't optimize callbacks for empty arrays/matrix, as they will never be called
|
|
26
|
+
// and in fact will throw an exception when we try to access the first element below
|
|
27
|
+
return {
|
|
28
|
+
isUnary,
|
|
29
|
+
fn: callback
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
var firstIndex = size.map(() => 0);
|
|
21
33
|
var firstValue = array.isMatrix ? array.get(firstIndex) : get(array, firstIndex);
|
|
22
34
|
numberOfArguments = _findNumberOfArgumentsTyped(callback, firstValue, firstIndex, array);
|
|
23
35
|
}
|
package/lib/esm/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mathjs",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.1.1",
|
|
4
4
|
"description": "Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with different data types like numbers, big numbers, complex numbers, fractions, units, and matrices.",
|
|
5
5
|
"author": "Jos de Jong <wjosdejong@gmail.com> (https://github.com/josdejong)",
|
|
6
6
|
"homepage": "https://mathjs.org",
|
|
@@ -36,23 +36,23 @@
|
|
|
36
36
|
"typed-function": "^4.2.1"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@babel/core": "7.
|
|
39
|
+
"@babel/core": "7.29.0",
|
|
40
40
|
"@babel/plugin-transform-object-assign": "7.27.1",
|
|
41
|
-
"@babel/plugin-transform-optional-catch-binding": "7.
|
|
42
|
-
"@babel/plugin-transform-runtime": "7.
|
|
43
|
-
"@babel/preset-env": "7.
|
|
44
|
-
"@babel/register": "7.28.
|
|
41
|
+
"@babel/plugin-transform-optional-catch-binding": "7.28.6",
|
|
42
|
+
"@babel/plugin-transform-runtime": "7.29.0",
|
|
43
|
+
"@babel/preset-env": "7.29.0",
|
|
44
|
+
"@babel/register": "7.28.6",
|
|
45
45
|
"@types/assert": "1.5.11",
|
|
46
46
|
"@types/mocha": "10.0.10",
|
|
47
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
48
|
-
"@typescript-eslint/parser": "8.
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "8.55.0",
|
|
48
|
+
"@typescript-eslint/parser": "8.55.0",
|
|
49
49
|
"assert": "2.1.0",
|
|
50
50
|
"babel-loader": "10.0.0",
|
|
51
51
|
"c8": "10.1.3",
|
|
52
52
|
"codecov": "3.8.3",
|
|
53
53
|
"del": "8.0.1",
|
|
54
54
|
"eigen": "0.2.2",
|
|
55
|
-
"es-check": "9.
|
|
55
|
+
"es-check": "9.5.4",
|
|
56
56
|
"eslint": "8.57.1",
|
|
57
57
|
"eslint-config-prettier": "9.1.0",
|
|
58
58
|
"eslint-config-standard": "17.1.0",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"eslint-plugin-n": "16.6.2",
|
|
62
62
|
"eslint-plugin-prettier": "5.5.4",
|
|
63
63
|
"eslint-plugin-promise": "6.6.0",
|
|
64
|
-
"expect-type": "1.
|
|
64
|
+
"expect-type": "1.3.0",
|
|
65
65
|
"expr-eval": "2.0.2",
|
|
66
66
|
"fancy-log": "2.0.0",
|
|
67
67
|
"glob": "11.0.3",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"karma-webdriver-launcher": "1.0.8",
|
|
78
78
|
"karma-webpack": "5.0.1",
|
|
79
79
|
"mkdirp": "3.0.1",
|
|
80
|
-
"mocha": "11.7.
|
|
80
|
+
"mocha": "11.7.5",
|
|
81
81
|
"mocha-junit-reporter": "2.2.1",
|
|
82
82
|
"ndarray": "1.0.19",
|
|
83
83
|
"ndarray-determinant": "1.0.0",
|
|
@@ -85,14 +85,14 @@
|
|
|
85
85
|
"ndarray-ops": "1.2.2",
|
|
86
86
|
"ndarray-pack": "1.2.1",
|
|
87
87
|
"numericjs": "1.2.6",
|
|
88
|
-
"prettier": "3.
|
|
88
|
+
"prettier": "3.8.1",
|
|
89
89
|
"process": "0.11.10",
|
|
90
|
-
"sinon": "21.0.
|
|
90
|
+
"sinon": "21.0.1",
|
|
91
91
|
"sylvester": "0.0.21",
|
|
92
|
-
"tinybench": "
|
|
92
|
+
"tinybench": "6.0.0",
|
|
93
93
|
"ts-node": "10.9.2",
|
|
94
94
|
"typescript": "5.9.3",
|
|
95
|
-
"webpack": "5.
|
|
95
|
+
"webpack": "5.105.0",
|
|
96
96
|
"zeros": "1.0.0"
|
|
97
97
|
},
|
|
98
98
|
"type": "module",
|