mathjs 7.3.0 → 7.6.0
Sign up to get free protection for your applications and to get access to all the features.
- package/HISTORY.md +29 -0
- package/dist/math.js +2716 -2222
- package/dist/math.min.js +5 -5
- package/dist/math.min.map +1 -1
- package/docs/datatypes/units.md +21 -0
- package/docs/reference/functions/ceil.md +10 -1
- package/docs/reference/functions/fix.md +10 -2
- package/docs/reference/functions/floor.md +12 -3
- package/docs/reference/functions/rotate.md +47 -0
- package/docs/reference/functions/rotationMatrix.md +51 -0
- package/docs/reference/functions/round.md +6 -2
- package/docs/reference/functions.md +2 -0
- package/es/entry/dependenciesAny/dependenciesCeil.generated.js +4 -0
- package/es/entry/dependenciesAny/dependenciesFix.generated.js +2 -0
- package/es/entry/dependenciesAny/dependenciesFloor.generated.js +4 -0
- package/es/entry/dependenciesAny/dependenciesRotate.generated.js +14 -0
- package/es/entry/dependenciesAny/dependenciesRotationMatrix.generated.js +30 -0
- package/es/entry/dependenciesAny.generated.js +2 -0
- package/es/entry/impureFunctionsAny.generated.js +55 -53
- package/es/entry/pureFunctionsAny.generated.js +230 -206
- package/es/expression/embeddedDocs/embeddedDocs.js +4 -0
- package/es/expression/embeddedDocs/function/matrix/rotate.js +8 -0
- package/es/expression/embeddedDocs/function/matrix/rotationMatrix.js +8 -0
- package/es/expression/node/FunctionNode.js +1 -1
- package/es/expression/node/Node.js +2 -2
- package/es/factoriesAny.js +2 -0
- package/es/function/arithmetic/ceil.js +88 -4
- package/es/function/arithmetic/fix.js +43 -6
- package/es/function/arithmetic/floor.js +90 -6
- package/es/function/arithmetic/round.js +6 -2
- package/es/function/matrix/rotate.js +78 -0
- package/es/function/matrix/rotationMatrix.js +176 -0
- package/es/function/matrix/sqrtm.js +4 -0
- package/es/function/probability/pickRandom.js +2 -6
- package/es/function/special/erf.js +1 -0
- package/es/plain/number/constants.js +1 -1
- package/es/plain/number/probability.js +1 -0
- package/es/type/unit/Unit.js +17 -18
- package/es/utils/object.js +3 -1
- package/es/version.js +1 -1
- package/examples/bignumbers.js +2 -0
- package/lib/entry/dependenciesAny/dependenciesCeil.generated.js +6 -0
- package/lib/entry/dependenciesAny/dependenciesFix.generated.js +3 -0
- package/lib/entry/dependenciesAny/dependenciesFloor.generated.js +6 -0
- package/lib/entry/dependenciesAny/dependenciesRotate.generated.js +26 -0
- package/lib/entry/dependenciesAny/dependenciesRotationMatrix.generated.js +50 -0
- package/lib/entry/dependenciesAny.generated.js +16 -0
- package/lib/entry/impureFunctionsAny.generated.js +58 -56
- package/lib/entry/mainAny.js +5 -0
- package/lib/entry/mainNumber.js +5 -0
- package/lib/entry/pureFunctionsAny.generated.js +270 -244
- package/lib/expression/embeddedDocs/embeddedDocs.js +6 -0
- package/lib/expression/embeddedDocs/function/matrix/rotate.js +15 -0
- package/lib/expression/embeddedDocs/function/matrix/rotationMatrix.js +15 -0
- package/lib/expression/node/FunctionNode.js +1 -1
- package/lib/expression/node/Node.js +2 -2
- package/lib/factoriesAny.js +16 -0
- package/lib/function/arithmetic/ceil.js +91 -4
- package/lib/function/arithmetic/fix.js +44 -6
- package/lib/function/arithmetic/floor.js +93 -6
- package/lib/function/arithmetic/round.js +6 -2
- package/lib/function/matrix/rotate.js +88 -0
- package/lib/function/matrix/rotationMatrix.js +186 -0
- package/lib/function/matrix/sqrtm.js +4 -0
- package/lib/function/probability/pickRandom.js +3 -7
- package/lib/function/special/erf.js +1 -0
- package/lib/header.js +2 -2
- package/lib/plain/bignumber/index.js +1 -0
- package/lib/plain/number/constants.js +2 -1
- package/lib/plain/number/index.js +9 -0
- package/lib/plain/number/probability.js +1 -0
- package/lib/type/unit/Unit.js +17 -18
- package/lib/utils/object.js +3 -1
- package/lib/version.js +1 -1
- package/package.json +11 -11
- package/src/core/function/import.js +2 -2
- package/src/entry/dependenciesAny/dependenciesCeil.generated.js +4 -0
- package/src/entry/dependenciesAny/dependenciesFix.generated.js +2 -0
- package/src/entry/dependenciesAny/dependenciesFloor.generated.js +4 -0
- package/src/entry/dependenciesAny/dependenciesRotate.generated.js +15 -0
- package/src/entry/dependenciesAny/dependenciesRotationMatrix.generated.js +31 -0
- package/src/entry/dependenciesAny.generated.js +2 -0
- package/src/entry/impureFunctionsAny.generated.js +84 -80
- package/src/entry/pureFunctionsAny.generated.js +75 -71
- package/src/expression/embeddedDocs/embeddedDocs.js +4 -0
- package/src/expression/embeddedDocs/function/matrix/rotate.js +19 -0
- package/src/expression/embeddedDocs/function/matrix/rotationMatrix.js +19 -0
- package/src/expression/node/FunctionNode.js +1 -1
- package/src/expression/node/Node.js +2 -1
- package/src/factoriesAny.js +2 -0
- package/src/function/arithmetic/ceil.js +63 -3
- package/src/function/arithmetic/fix.js +45 -6
- package/src/function/arithmetic/floor.js +65 -5
- package/src/function/arithmetic/round.js +6 -2
- package/src/function/matrix/rotate.js +79 -0
- package/src/function/matrix/rotationMatrix.js +186 -0
- package/src/function/matrix/sqrtm.js +4 -0
- package/src/function/probability/pickRandom.js +2 -6
- package/src/function/special/erf.js +2 -0
- package/src/plain/number/constants.js +1 -1
- package/src/plain/number/probability.js +2 -0
- package/src/type/unit/Unit.js +18 -21
- package/src/utils/object.js +3 -1
- package/src/version.js +1 -1
package/src/type/unit/Unit.js
CHANGED
@@ -216,20 +216,15 @@ export const createUnitClass = /* #__PURE__ */ factory(name, dependencies, ({
|
|
216
216
|
let unitName = ''
|
217
217
|
|
218
218
|
// Alphanumeric characters only; matches [a-zA-Z0-9]
|
219
|
-
|
220
|
-
while ((code >= 48 && code <= 57) ||
|
221
|
-
(code >= 65 && code <= 90) ||
|
222
|
-
(code >= 97 && code <= 122)) {
|
219
|
+
while (isDigit(c) || Unit.isValidAlpha(c)) {
|
223
220
|
unitName += c
|
224
221
|
next()
|
225
|
-
code = text.charCodeAt(index)
|
226
222
|
}
|
227
223
|
|
228
224
|
// Must begin with [a-zA-Z]
|
229
|
-
|
230
|
-
if ((
|
231
|
-
|
232
|
-
return unitName || null
|
225
|
+
const firstC = unitName.charAt(0)
|
226
|
+
if (Unit.isValidAlpha(firstC)) {
|
227
|
+
return unitName
|
233
228
|
} else {
|
234
229
|
return null
|
235
230
|
}
|
@@ -1103,7 +1098,8 @@ export const createUnitClass = /* #__PURE__ */ factory(name, dependencies, ({
|
|
1103
1098
|
// Simplfy the unit list, unless it is valueless or was created directly in the
|
1104
1099
|
// constructor or as the result of to or toSI
|
1105
1100
|
const simp = this.skipAutomaticSimplification || this.value === null
|
1106
|
-
? this.clone()
|
1101
|
+
? this.clone()
|
1102
|
+
: this.simplify()
|
1107
1103
|
|
1108
1104
|
// Apply some custom logic for handling VA and VAR. The goal is to express the value of the unit as a real value, if possible. Otherwise, use a real-valued unit instead of a complex-valued one.
|
1109
1105
|
let isImaginary = false
|
@@ -3030,21 +3026,22 @@ export const createUnitClass = /* #__PURE__ */ factory(name, dependencies, ({
|
|
3030
3026
|
}
|
3031
3027
|
}
|
3032
3028
|
|
3029
|
+
/**
|
3030
|
+
* Checks if a character is a valid latin letter (upper or lower case).
|
3031
|
+
* Note that this function can be overridden, for example to allow support of other alphabets.
|
3032
|
+
* @param {string} c Tested character
|
3033
|
+
*/
|
3034
|
+
Unit.isValidAlpha = function isValidAlpha (c) {
|
3035
|
+
return /^[a-zA-Z]$/.test(c)
|
3036
|
+
}
|
3037
|
+
|
3033
3038
|
function assertUnitNameIsValid (name) {
|
3034
3039
|
for (let i = 0; i < name.length; i++) {
|
3035
|
-
|
3036
|
-
|
3037
|
-
const isValidAlpha = function (p) {
|
3038
|
-
return /^[a-zA-Z]$/.test(p)
|
3039
|
-
}
|
3040
|
-
|
3041
|
-
const isDigit = function (c) {
|
3042
|
-
return (c >= '0' && c <= '9')
|
3043
|
-
}
|
3040
|
+
c = name.charAt(i)
|
3044
3041
|
|
3045
|
-
if (i === 0 && !isValidAlpha(c)) { throw new Error('Invalid unit name (must begin with alpha character): "' + name + '"') }
|
3042
|
+
if (i === 0 && !Unit.isValidAlpha(c)) { throw new Error('Invalid unit name (must begin with alpha character): "' + name + '"') }
|
3046
3043
|
|
3047
|
-
if (i > 0 && !(isValidAlpha(c) ||
|
3044
|
+
if (i > 0 && !(Unit.isValidAlpha(c) ||
|
3048
3045
|
isDigit(c))) { throw new Error('Invalid unit name (only alphanumeric characters are allowed): "' + name + '"') }
|
3049
3046
|
}
|
3050
3047
|
}
|
package/src/utils/object.js
CHANGED
@@ -86,7 +86,9 @@ export function deepExtend (a, b) {
|
|
86
86
|
}
|
87
87
|
|
88
88
|
for (const prop in b) {
|
89
|
-
|
89
|
+
// We check against prop not being in Object.prototype or Function.prototype
|
90
|
+
// to prevent polluting for example Object.__proto__.
|
91
|
+
if (hasOwnProperty(b, prop) && !(prop in Object.prototype) && !(prop in Function.prototype)) {
|
90
92
|
if (b[prop] && b[prop].constructor === Object) {
|
91
93
|
if (a[prop] === undefined) {
|
92
94
|
a[prop] = {}
|
package/src/version.js
CHANGED