mathjs 14.5.1 → 14.5.3

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.
@@ -317,6 +317,10 @@ const embeddedDocs = exports.embeddedDocs = {
317
317
  description: 'Characteristic impedance of vacuum',
318
318
  examples: ['vacuumImpedance']
319
319
  },
320
+ coulomb: {
321
+ description: 'Coulomb\'s constant. Deprecated in favor of coulombConstant',
322
+ examples: ['coulombConstant']
323
+ },
320
324
  coulombConstant: {
321
325
  description: 'Coulomb\'s constant',
322
326
  examples: ['coulombConstant']
@@ -511,7 +511,7 @@ const createParse = exports.createParse = /* #__PURE__ */(0, _factory.factory)(n
511
511
  */
512
512
  parse.isWhitespace = function isWhitespace(c, nestingLevel) {
513
513
  // TODO: also take '\r' carriage return as newline? Or does that give problems on mac?
514
- return c === ' ' || c === '\t' || c === '\n' && nestingLevel > 0;
514
+ return c === ' ' || c === '\t' || c === '\u00A0' || c === '\n' && nestingLevel > 0;
515
515
  };
516
516
 
517
517
  /**
package/lib/cjs/header.js CHANGED
@@ -6,8 +6,8 @@
6
6
  * It features real and complex numbers, units, matrices, a large set of
7
7
  * mathematical functions, and a flexible expression parser.
8
8
  *
9
- * @version 14.5.1
10
- * @date 2025-05-28
9
+ * @version 14.5.3
10
+ * @date 2025-07-02
11
11
  *
12
12
  * @license
13
13
  * Copyright (C) 2013-2025 Jos de Jong <wjosdejong@gmail.com>
@@ -4,6 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.version = void 0;
7
- const version = exports.version = '14.5.1';
7
+ const version = exports.version = '14.5.3';
8
8
  // Note: This file is automatically generated when building math.js.
9
9
  // Changes made in this file will be overwritten.
@@ -311,6 +311,10 @@ export var embeddedDocs = {
311
311
  description: 'Characteristic impedance of vacuum',
312
312
  examples: ['vacuumImpedance']
313
313
  },
314
+ coulomb: {
315
+ description: 'Coulomb\'s constant. Deprecated in favor of coulombConstant',
316
+ examples: ['coulombConstant']
317
+ },
314
318
  coulombConstant: {
315
319
  description: 'Coulomb\'s constant',
316
320
  examples: ['coulombConstant']
@@ -504,7 +504,7 @@ export var createParse = /* #__PURE__ */factory(name, dependencies, _ref => {
504
504
  */
505
505
  parse.isWhitespace = function isWhitespace(c, nestingLevel) {
506
506
  // TODO: also take '\r' carriage return as newline? Or does that give problems on mac?
507
- return c === ' ' || c === '\t' || c === '\n' && nestingLevel > 0;
507
+ return c === ' ' || c === '\t' || c === '\u00A0' || c === '\n' && nestingLevel > 0;
508
508
  };
509
509
 
510
510
  /**
@@ -1,3 +1,3 @@
1
- export var version = '14.5.1';
1
+ export var version = '14.5.3';
2
2
  // Note: This file is automatically generated when building math.js.
3
3
  // Changes made in this file will be overwritten.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mathjs",
3
- "version": "14.5.1",
3
+ "version": "14.5.3",
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,37 +36,37 @@
36
36
  "typed-function": "^4.2.1"
37
37
  },
38
38
  "devDependencies": {
39
- "@babel/core": "7.27.3",
39
+ "@babel/core": "7.28.0",
40
40
  "@babel/plugin-transform-object-assign": "7.27.1",
41
41
  "@babel/plugin-transform-optional-catch-binding": "7.27.1",
42
- "@babel/plugin-transform-runtime": "7.27.3",
43
- "@babel/preset-env": "7.27.2",
42
+ "@babel/plugin-transform-runtime": "7.28.0",
43
+ "@babel/preset-env": "7.28.0",
44
44
  "@babel/register": "7.27.1",
45
45
  "@types/assert": "1.5.11",
46
46
  "@types/mocha": "10.0.10",
47
- "@typescript-eslint/eslint-plugin": "8.33.0",
48
- "@typescript-eslint/parser": "8.33.0",
47
+ "@typescript-eslint/eslint-plugin": "8.35.1",
48
+ "@typescript-eslint/parser": "8.35.1",
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
- "core-js": "3.42.0",
53
+ "core-js": "3.43.0",
54
54
  "del": "8.0.0",
55
55
  "dtslint": "4.2.1",
56
56
  "eigen": "0.2.2",
57
57
  "eslint": "8.57.1",
58
58
  "eslint-config-prettier": "9.1.0",
59
59
  "eslint-config-standard": "17.1.0",
60
- "eslint-plugin-import": "2.31.0",
60
+ "eslint-plugin-import": "2.32.0",
61
61
  "eslint-plugin-mocha": "10.5.0",
62
62
  "eslint-plugin-n": "16.6.2",
63
- "eslint-plugin-prettier": "5.4.0",
63
+ "eslint-plugin-prettier": "5.5.1",
64
64
  "eslint-plugin-promise": "6.6.0",
65
65
  "expect-type": "1.2.1",
66
66
  "expr-eval": "2.0.2",
67
67
  "fancy-log": "2.0.0",
68
- "glob": "11.0.2",
69
- "gulp": "5.0.0",
68
+ "glob": "11.0.3",
69
+ "gulp": "5.0.1",
70
70
  "gulp-babel": "8.0.0",
71
71
  "handlebars": "4.7.8",
72
72
  "jsep": "1.4.0",
@@ -78,7 +78,7 @@
78
78
  "karma-webdriver-launcher": "1.0.8",
79
79
  "karma-webpack": "5.0.1",
80
80
  "mkdirp": "3.0.1",
81
- "mocha": "11.5.0",
81
+ "mocha": "11.7.1",
82
82
  "mocha-junit-reporter": "2.2.1",
83
83
  "ndarray": "1.0.19",
84
84
  "ndarray-determinant": "1.0.0",
@@ -86,9 +86,9 @@
86
86
  "ndarray-ops": "1.2.2",
87
87
  "ndarray-pack": "1.2.1",
88
88
  "numericjs": "1.2.6",
89
- "prettier": "3.5.3",
89
+ "prettier": "3.6.2",
90
90
  "process": "0.11.10",
91
- "sinon": "20.0.0",
91
+ "sinon": "21.0.0",
92
92
  "sylvester": "0.0.21",
93
93
  "tinybench": "4.0.1",
94
94
  "ts-node": "10.9.2",
@@ -20,7 +20,7 @@ Maintaining the TypeScript types is done manually. When adding a function, one h
20
20
  3. Add a static definition inside `export const {...} : MathJsInstance`
21
21
  4. Add a dependencies definition inside `export const {...} : Record<string, FactoryFunctionMap>`
22
22
 
23
- For exampe for the function `add`, we can have the following definitions:
23
+ For example for the function `add`, we can have the following definitions:
24
24
 
25
25
  ```ts
26
26
  // instance
package/types/index.d.ts CHANGED
@@ -28,7 +28,12 @@ export type MatrixFromFunctionCallback<T extends MathScalarType> = (
28
28
  ) => T
29
29
 
30
30
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
- export type FactoryFunction<T> = (scope: any) => T
31
+ export type FactoryFunction<T> = (scope: MathScope) => T
32
+
33
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
+ export type MathScope<TValue = any> =
35
+ | Record<string, TValue>
36
+ | MapLike<string, TValue>
32
37
 
33
38
  // FactoryFunctionMap can be nested; all nested objects will be flattened
34
39
  export interface FactoryFunctionMap {
@@ -862,8 +867,8 @@ export interface MathJsInstance extends MathJsFactory {
862
867
  * @param unit The unit to be created
863
868
  * @returns The created unit
864
869
  */
865
- unit(value: MathNumericType, unit: string): Unit
866
- unit(value: MathCollection, unit: string): Unit[]
870
+ unit(value: MathNumericType, unit?: string): Unit
871
+ unit(value: MathCollection): Unit[]
867
872
 
868
873
  /*************************************************************************
869
874
  * Expression functions
@@ -891,12 +896,12 @@ export interface MathJsInstance extends MathJsFactory {
891
896
  */
892
897
  evaluate(
893
898
  expr: MathExpression | Matrix,
894
- scope?: object
899
+ scope?: MathScope
895
900
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
896
901
  ): any
897
902
  evaluate(
898
903
  expr: MathExpression[],
899
- scope?: object
904
+ scope?: MathScope
900
905
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
901
906
  ): any[]
902
907
 
@@ -1071,14 +1076,14 @@ export interface MathJsInstance extends MathJsFactory {
1071
1076
  * @param scope Scope to read/write variables
1072
1077
  */
1073
1078
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1074
- resolve(node: MathNode | string, scope?: Record<string, any>): MathNode
1079
+ resolve(node: MathNode | string, scope?: MathScope): MathNode
1075
1080
  resolve(
1076
1081
  node: (MathNode | string)[],
1077
1082
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1078
- scope?: Record<string, any>
1083
+ scope?: MathScope
1079
1084
  ): MathNode[]
1080
1085
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1081
- resolve(node: Matrix, scope?: Record<string, any>): Matrix
1086
+ resolve(node: Matrix, scope?: MathScope): Matrix
1082
1087
 
1083
1088
  /**
1084
1089
  * Calculate the Sparse Matrix LU decomposition with full pivoting.
@@ -1131,9 +1136,9 @@ export interface MathJsInstance extends MathJsFactory {
1131
1136
  * @returns Sum of x and y
1132
1137
  */
1133
1138
  add<T extends MathType>(x: T, y: T): T
1134
- add<T extends MathType>(...values: T[]): T
1139
+ add<T extends MathType>(x: T, y: T, ...values: T[]): T
1135
1140
  add(x: MathType, y: MathType): MathType
1136
- add(...values: MathType[]): MathType
1141
+ add(x: MathType, y: MathType, ...values: MathType[]): MathType
1137
1142
 
1138
1143
  /**
1139
1144
  * Calculate the cubic root of a value.
@@ -1460,9 +1465,8 @@ export interface MathJsInstance extends MathJsFactory {
1460
1465
  multiply<T extends MathArray>(x: T, y: T): MathScalarType
1461
1466
  multiply(x: Unit, y: Unit): Unit
1462
1467
  multiply(x: number, y: number): number
1463
- multiply(x: MathType, y: MathType): MathType
1464
- multiply<T extends MathType>(...values: T[]): T
1465
- multiply(...values: MathType[]): MathType
1468
+ multiply(x: MathType, y: MathType, ...values: MathType[]): MathType
1469
+ multiply<T extends MathType>(x: T, y: T, ...values: T[]): T
1466
1470
 
1467
1471
  /**
1468
1472
  * Calculate the norm of a number, vector or matrix. The second
@@ -3518,7 +3522,7 @@ export interface MathJsInstance extends MathJsFactory {
3518
3522
 
3519
3523
  isBoolean(x: unknown): x is boolean
3520
3524
 
3521
- isResultSet(x: unknown): boolean
3525
+ isResultSet(x: unknown): x is ResultSet
3522
3526
 
3523
3527
  isHelp(x: unknown): x is Help
3524
3528
 
@@ -4172,7 +4176,7 @@ export interface Unit {
4172
4176
  divide(unit: Unit): Unit | number
4173
4177
  pow(unit: Unit): Unit
4174
4178
  abs(unit: Unit): Unit
4175
- to(unit: string): Unit
4179
+ to(unit: string | Unit): Unit
4176
4180
  toNumber(unit?: string): number
4177
4181
  toNumeric(unit?: string): number | Fraction | BigNumber
4178
4182
  toSI(): Unit
@@ -4286,10 +4290,14 @@ export interface Simplify {
4286
4290
  (
4287
4291
  expr: MathNode | string,
4288
4292
  rules: SimplifyRule[],
4289
- scope?: object,
4293
+ scope?: MathScope,
4294
+ options?: SimplifyOptions
4295
+ ): MathNode
4296
+ (
4297
+ expr: MathNode | string,
4298
+ scope: MathScope,
4290
4299
  options?: SimplifyOptions
4291
4300
  ): MathNode
4292
- (expr: MathNode | string, scope: object, options?: SimplifyOptions): MathNode
4293
4301
 
4294
4302
  rules: SimplifyRule[]
4295
4303
  }
@@ -4316,7 +4324,15 @@ export interface ObjectWrappingMap<T extends string | number | symbol, U> {
4316
4324
 
4317
4325
  export interface EvalFunction {
4318
4326
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4319
- evaluate(scope?: any): any
4327
+ evaluate(scope?: MathScope): any
4328
+ }
4329
+
4330
+ // ResultSet type and helper
4331
+ export interface ResultSet {
4332
+ entries: unknown[]
4333
+ valueOf(): unknown[]
4334
+ toString(): string
4335
+ toJSON(): MathJSON
4320
4336
  }
4321
4337
 
4322
4338
  export interface MathNode {
@@ -4346,7 +4362,7 @@ export interface MathNode {
4346
4362
  * node.compile().evaluate(scope). Example:
4347
4363
  */
4348
4364
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4349
- evaluate(expr?: any): any
4365
+ evaluate(scope?: MathScope): any
4350
4366
  /**
4351
4367
  * Test whether this node equals an other node. Does a deep comparison
4352
4368
  * of the values of both nodes.
@@ -4810,7 +4826,7 @@ export interface MathJsChain<TValue> {
4810
4826
  */
4811
4827
  unit(this: MathJsChain<string>, unit?: string): MathJsChain<Unit>
4812
4828
  unit(this: MathJsChain<MathNumericType>, unit?: string): MathJsChain<Unit>
4813
- unit(this: MathJsChain<MathCollection>, unit?: string): MathJsChain<Unit[]>
4829
+ unit(this: MathJsChain<MathCollection>): MathJsChain<Unit[]>
4814
4830
 
4815
4831
  /*************************************************************************
4816
4832
  * Expression functions
@@ -4829,12 +4845,12 @@ export interface MathJsChain<TValue> {
4829
4845
  */
4830
4846
  evaluate(
4831
4847
  this: MathJsChain<MathExpression | Matrix>,
4832
- scope?: object
4848
+ scope?: MathScope
4833
4849
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4834
4850
  ): MathJsChain<any>
4835
4851
  evaluate(
4836
4852
  this: MathJsChain<MathExpression[]>,
4837
- scope?: object
4853
+ scope?: MathScope
4838
4854
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4839
4855
  ): MathJsChain<any[]>
4840
4856
 
@@ -4871,12 +4887,12 @@ export interface MathJsChain<TValue> {
4871
4887
  resolve(
4872
4888
  this: MathJsChain<MathNode>,
4873
4889
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4874
- scope?: Record<string, any>
4890
+ scope?: MathScope
4875
4891
  ): MathJsChain<MathNode>
4876
4892
  resolve(
4877
4893
  this: MathJsChain<MathNode[]>,
4878
4894
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
4879
- scope?: Record<string, any>
4895
+ scope?: MathScope
4880
4896
  ): MathJsChain<MathNode[]>
4881
4897
 
4882
4898
  /*************************************************************************
@@ -7073,6 +7089,13 @@ export interface ImportObject {
7073
7089
  [key: string]: any
7074
7090
  }
7075
7091
 
7092
+ export interface MapLike<TKey = string, TValue = unknown> {
7093
+ get(key: TKey): TValue
7094
+ set(key: TKey, value: TValue): MapLike<TKey, TValue>
7095
+ has(key: TKey): boolean
7096
+ keys(): IterableIterator<TKey> | TKey[]
7097
+ }
7098
+
7076
7099
  export const {
7077
7100
  // config // Don't export config: no config available in the static instance
7078
7101