mathjs 7.3.0 → 7.6.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.
Files changed (104) hide show
  1. package/HISTORY.md +29 -0
  2. package/dist/math.js +2716 -2222
  3. package/dist/math.min.js +5 -5
  4. package/dist/math.min.map +1 -1
  5. package/docs/datatypes/units.md +21 -0
  6. package/docs/reference/functions/ceil.md +10 -1
  7. package/docs/reference/functions/fix.md +10 -2
  8. package/docs/reference/functions/floor.md +12 -3
  9. package/docs/reference/functions/rotate.md +47 -0
  10. package/docs/reference/functions/rotationMatrix.md +51 -0
  11. package/docs/reference/functions/round.md +6 -2
  12. package/docs/reference/functions.md +2 -0
  13. package/es/entry/dependenciesAny/dependenciesCeil.generated.js +4 -0
  14. package/es/entry/dependenciesAny/dependenciesFix.generated.js +2 -0
  15. package/es/entry/dependenciesAny/dependenciesFloor.generated.js +4 -0
  16. package/es/entry/dependenciesAny/dependenciesRotate.generated.js +14 -0
  17. package/es/entry/dependenciesAny/dependenciesRotationMatrix.generated.js +30 -0
  18. package/es/entry/dependenciesAny.generated.js +2 -0
  19. package/es/entry/impureFunctionsAny.generated.js +55 -53
  20. package/es/entry/pureFunctionsAny.generated.js +230 -206
  21. package/es/expression/embeddedDocs/embeddedDocs.js +4 -0
  22. package/es/expression/embeddedDocs/function/matrix/rotate.js +8 -0
  23. package/es/expression/embeddedDocs/function/matrix/rotationMatrix.js +8 -0
  24. package/es/expression/node/FunctionNode.js +1 -1
  25. package/es/expression/node/Node.js +2 -2
  26. package/es/factoriesAny.js +2 -0
  27. package/es/function/arithmetic/ceil.js +88 -4
  28. package/es/function/arithmetic/fix.js +43 -6
  29. package/es/function/arithmetic/floor.js +90 -6
  30. package/es/function/arithmetic/round.js +6 -2
  31. package/es/function/matrix/rotate.js +78 -0
  32. package/es/function/matrix/rotationMatrix.js +176 -0
  33. package/es/function/matrix/sqrtm.js +4 -0
  34. package/es/function/probability/pickRandom.js +2 -6
  35. package/es/function/special/erf.js +1 -0
  36. package/es/plain/number/constants.js +1 -1
  37. package/es/plain/number/probability.js +1 -0
  38. package/es/type/unit/Unit.js +17 -18
  39. package/es/utils/object.js +3 -1
  40. package/es/version.js +1 -1
  41. package/examples/bignumbers.js +2 -0
  42. package/lib/entry/dependenciesAny/dependenciesCeil.generated.js +6 -0
  43. package/lib/entry/dependenciesAny/dependenciesFix.generated.js +3 -0
  44. package/lib/entry/dependenciesAny/dependenciesFloor.generated.js +6 -0
  45. package/lib/entry/dependenciesAny/dependenciesRotate.generated.js +26 -0
  46. package/lib/entry/dependenciesAny/dependenciesRotationMatrix.generated.js +50 -0
  47. package/lib/entry/dependenciesAny.generated.js +16 -0
  48. package/lib/entry/impureFunctionsAny.generated.js +58 -56
  49. package/lib/entry/mainAny.js +5 -0
  50. package/lib/entry/mainNumber.js +5 -0
  51. package/lib/entry/pureFunctionsAny.generated.js +270 -244
  52. package/lib/expression/embeddedDocs/embeddedDocs.js +6 -0
  53. package/lib/expression/embeddedDocs/function/matrix/rotate.js +15 -0
  54. package/lib/expression/embeddedDocs/function/matrix/rotationMatrix.js +15 -0
  55. package/lib/expression/node/FunctionNode.js +1 -1
  56. package/lib/expression/node/Node.js +2 -2
  57. package/lib/factoriesAny.js +16 -0
  58. package/lib/function/arithmetic/ceil.js +91 -4
  59. package/lib/function/arithmetic/fix.js +44 -6
  60. package/lib/function/arithmetic/floor.js +93 -6
  61. package/lib/function/arithmetic/round.js +6 -2
  62. package/lib/function/matrix/rotate.js +88 -0
  63. package/lib/function/matrix/rotationMatrix.js +186 -0
  64. package/lib/function/matrix/sqrtm.js +4 -0
  65. package/lib/function/probability/pickRandom.js +3 -7
  66. package/lib/function/special/erf.js +1 -0
  67. package/lib/header.js +2 -2
  68. package/lib/plain/bignumber/index.js +1 -0
  69. package/lib/plain/number/constants.js +2 -1
  70. package/lib/plain/number/index.js +9 -0
  71. package/lib/plain/number/probability.js +1 -0
  72. package/lib/type/unit/Unit.js +17 -18
  73. package/lib/utils/object.js +3 -1
  74. package/lib/version.js +1 -1
  75. package/package.json +11 -11
  76. package/src/core/function/import.js +2 -2
  77. package/src/entry/dependenciesAny/dependenciesCeil.generated.js +4 -0
  78. package/src/entry/dependenciesAny/dependenciesFix.generated.js +2 -0
  79. package/src/entry/dependenciesAny/dependenciesFloor.generated.js +4 -0
  80. package/src/entry/dependenciesAny/dependenciesRotate.generated.js +15 -0
  81. package/src/entry/dependenciesAny/dependenciesRotationMatrix.generated.js +31 -0
  82. package/src/entry/dependenciesAny.generated.js +2 -0
  83. package/src/entry/impureFunctionsAny.generated.js +84 -80
  84. package/src/entry/pureFunctionsAny.generated.js +75 -71
  85. package/src/expression/embeddedDocs/embeddedDocs.js +4 -0
  86. package/src/expression/embeddedDocs/function/matrix/rotate.js +19 -0
  87. package/src/expression/embeddedDocs/function/matrix/rotationMatrix.js +19 -0
  88. package/src/expression/node/FunctionNode.js +1 -1
  89. package/src/expression/node/Node.js +2 -1
  90. package/src/factoriesAny.js +2 -0
  91. package/src/function/arithmetic/ceil.js +63 -3
  92. package/src/function/arithmetic/fix.js +45 -6
  93. package/src/function/arithmetic/floor.js +65 -5
  94. package/src/function/arithmetic/round.js +6 -2
  95. package/src/function/matrix/rotate.js +79 -0
  96. package/src/function/matrix/rotationMatrix.js +186 -0
  97. package/src/function/matrix/sqrtm.js +4 -0
  98. package/src/function/probability/pickRandom.js +2 -6
  99. package/src/function/special/erf.js +2 -0
  100. package/src/plain/number/constants.js +1 -1
  101. package/src/plain/number/probability.js +2 -0
  102. package/src/type/unit/Unit.js +18 -21
  103. package/src/utils/object.js +3 -1
  104. package/src/version.js +1 -1
@@ -1,3 +1,5 @@
1
+ /* eslint-disable no-loss-of-precision */
2
+
1
3
  import { isInteger } from '../../utils/number'
2
4
  import { product } from '../../utils/product'
3
5
 
@@ -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
- let code = text.charCodeAt(index)
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
- code = unitName.charCodeAt(0)
230
- if ((code >= 65 && code <= 90) ||
231
- (code >= 97 && code <= 122)) {
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() : this.simplify()
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
- const c = name.charAt(i)
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
  }
@@ -86,7 +86,9 @@ export function deepExtend (a, b) {
86
86
  }
87
87
 
88
88
  for (const prop in b) {
89
- if (hasOwnProperty(b, prop)) {
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
@@ -1,3 +1,3 @@
1
- export const version = '7.3.0'
1
+ export const version = '7.6.0'
2
2
  // Note: This file is automatically generated when building math.js.
3
3
  // Changes made in this file will be overwritten.