mathjs 10.6.1 → 10.6.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -43,19 +43,19 @@ var createCeilNumber = /* #__PURE__ */(0, _factory.factory)(name, ['typed', 'con
43
43
  if ((0, _number.nearlyEqual)(x, round(x, n), config.epsilon)) {
44
44
  return round(x, n);
45
45
  } else {
46
- var _$split = "".concat(x, "e").split('e'),
47
- _$split2 = (0, _slicedToArray2.default)(_$split, 2),
48
- number = _$split2[0],
49
- exponent = _$split2[1];
46
+ var _split = "".concat(x, "e").split('e'),
47
+ _split2 = (0, _slicedToArray2.default)(_split, 2),
48
+ number = _split2[0],
49
+ exponent = _split2[1];
50
50
 
51
51
  var result = Math.ceil(Number("".concat(number, "e").concat(Number(exponent) + n)));
52
52
 
53
- var _$split3 = "".concat(result, "e").split('e');
53
+ var _split3 = "".concat(result, "e").split('e');
54
54
 
55
- var _$split4 = (0, _slicedToArray2.default)(_$split3, 2);
55
+ var _split4 = (0, _slicedToArray2.default)(_split3, 2);
56
56
 
57
- number = _$split4[0];
58
- exponent = _$split4[1];
57
+ number = _split4[0];
58
+ exponent = _split4[1];
59
59
  return Number("".concat(number, "e").concat(Number(exponent) - n));
60
60
  }
61
61
  }
@@ -43,19 +43,19 @@ var createFloorNumber = /* #__PURE__ */(0, _factory.factory)(name, ['typed', 'co
43
43
  if ((0, _number.nearlyEqual)(x, round(x, n), config.epsilon)) {
44
44
  return round(x, n);
45
45
  } else {
46
- var _$split = "".concat(x, "e").split('e'),
47
- _$split2 = (0, _slicedToArray2.default)(_$split, 2),
48
- number = _$split2[0],
49
- exponent = _$split2[1];
46
+ var _split = "".concat(x, "e").split('e'),
47
+ _split2 = (0, _slicedToArray2.default)(_split, 2),
48
+ number = _split2[0],
49
+ exponent = _split2[1];
50
50
 
51
51
  var result = Math.floor(Number("".concat(number, "e").concat(Number(exponent) + n)));
52
52
 
53
- var _$split3 = "".concat(result, "e").split('e');
53
+ var _split3 = "".concat(result, "e").split('e');
54
54
 
55
- var _$split4 = (0, _slicedToArray2.default)(_$split3, 2);
55
+ var _split4 = (0, _slicedToArray2.default)(_split3, 2);
56
56
 
57
- number = _$split4[0];
58
- exponent = _$split4[1];
57
+ number = _split4[0];
58
+ exponent = _split4[1];
59
59
  return Number("".concat(number, "e").concat(Number(exponent) - n));
60
60
  }
61
61
  }
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 10.6.1
10
- * @date 2022-05-31
9
+ * @version 10.6.4
10
+ * @date 2022-06-28
11
11
  *
12
12
  * @license
13
13
  * Copyright (C) 2013-2022 Jos de Jong <wjosdejong@gmail.com>
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.version = void 0;
7
- var version = '10.6.1'; // Note: This file is automatically generated when building math.js.
7
+ var version = '10.6.4'; // Note: This file is automatically generated when building math.js.
8
8
  // Changes made in this file will be overwritten.
9
9
 
10
10
  exports.version = version;
@@ -1,2 +1,2 @@
1
- export var version = '10.6.1'; // Note: This file is automatically generated when building math.js.
1
+ export var version = '10.6.4'; // Note: This file is automatically generated when building math.js.
2
2
  // Changes made in this file will be overwritten.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mathjs",
3
- "version": "10.6.1",
3
+ "version": "10.6.4",
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",
@@ -25,7 +25,7 @@
25
25
  "unit"
26
26
  ],
27
27
  "dependencies": {
28
- "@babel/runtime": "^7.18.3",
28
+ "@babel/runtime": "^7.18.6",
29
29
  "complex.js": "^2.1.1",
30
30
  "decimal.js": "^10.3.1",
31
31
  "escape-latex": "^1.2.0",
@@ -36,29 +36,29 @@
36
36
  "typed-function": "^2.1.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@babel/core": "7.18.2",
40
- "@babel/plugin-transform-object-assign": "7.16.7",
41
- "@babel/plugin-transform-runtime": "7.18.2",
42
- "@babel/preset-env": "7.18.2",
43
- "@babel/register": "7.17.7",
39
+ "@babel/core": "7.18.6",
40
+ "@babel/plugin-transform-object-assign": "7.18.6",
41
+ "@babel/plugin-transform-runtime": "7.18.6",
42
+ "@babel/preset-env": "7.18.6",
43
+ "@babel/register": "7.18.6",
44
44
  "@types/assert": "1.5.6",
45
45
  "@types/mocha": "9.1.1",
46
- "@typescript-eslint/eslint-plugin": "5.27.0",
47
- "@typescript-eslint/parser": "5.27.0",
46
+ "@typescript-eslint/eslint-plugin": "5.30.0",
47
+ "@typescript-eslint/parser": "5.30.0",
48
48
  "assert": "2.0.0",
49
49
  "babel-loader": "8.2.5",
50
50
  "benchmark": "2.1.4",
51
51
  "codecov": "3.8.3",
52
- "core-js": "3.22.7",
52
+ "core-js": "3.23.3",
53
53
  "del": "6.1.1",
54
54
  "dtslint": "4.2.1",
55
- "eslint": "8.16.0",
55
+ "eslint": "8.18.0",
56
56
  "eslint-config-prettier": "8.5.0",
57
57
  "eslint-config-standard": "17.0.0",
58
58
  "eslint-plugin-import": "2.26.0",
59
59
  "eslint-plugin-mocha": "10.0.5",
60
- "eslint-plugin-n": "15.2.0",
61
- "eslint-plugin-prettier": "4.0.0",
60
+ "eslint-plugin-n": "15.2.3",
61
+ "eslint-plugin-prettier": "4.1.0",
62
62
  "eslint-plugin-promise": "6.0.0",
63
63
  "expect-type": "0.13.0",
64
64
  "expr-eval": "2.0.2",
@@ -69,7 +69,7 @@
69
69
  "handlebars": "4.7.7",
70
70
  "istanbul": "0.4.5",
71
71
  "jsep": "1.3.6",
72
- "karma": "6.3.20",
72
+ "karma": "6.4.0",
73
73
  "karma-browserstack-launcher": "1.6.0",
74
74
  "karma-firefox-launcher": "2.1.2",
75
75
  "karma-mocha": "2.0.1",
@@ -86,11 +86,11 @@
86
86
  "numericjs": "1.2.6",
87
87
  "nyc": "15.1.0",
88
88
  "pad-right": "0.2.2",
89
- "prettier": "2.6.2",
89
+ "prettier": "2.7.1",
90
90
  "process": "0.11.10",
91
91
  "sylvester": "0.0.21",
92
- "ts-node": "10.8.0",
93
- "typescript": "4.7.2",
92
+ "ts-node": "10.8.1",
93
+ "typescript": "4.7.4",
94
94
  "webpack": "4.46.0",
95
95
  "zeros": "1.0.0"
96
96
  },
package/types/index.d.ts CHANGED
@@ -161,6 +161,10 @@ declare namespace math {
161
161
  isHexDigit(c: string): boolean
162
162
  }
163
163
 
164
+ interface NodeCtor {
165
+ new (): MathNodeCommon
166
+ }
167
+
164
168
  interface AccessorNode extends MathNodeCommon {
165
169
  type: 'AccessorNode'
166
170
  isAccessorNode: true
@@ -337,13 +341,16 @@ declare namespace math {
337
341
  implicit?: boolean
338
342
  ): OperatorNode<TOp, TFn, TArgs>
339
343
  }
340
- interface ParenthesisNode extends MathNodeCommon {
344
+ interface ParenthesisNode<TContent extends MathNode = MathNode>
345
+ extends MathNodeCommon {
341
346
  type: 'ParenthesisNode'
342
347
  isParenthesisNode: true
343
- content: MathNode
348
+ content: TContent
344
349
  }
345
350
  interface ParenthesisNodeCtor {
346
- new (content: MathNode): ParenthesisNode
351
+ new <TContent extends MathNode>(
352
+ content: TContent
353
+ ): ParenthesisNode<TContent>
347
354
  }
348
355
 
349
356
  interface RangeNode extends MathNodeCommon {
@@ -431,6 +438,7 @@ declare namespace math {
431
438
  tau: number
432
439
 
433
440
  // Class-like constructors
441
+ Node: NodeCtor
434
442
  AccessorNode: AccessorNodeCtor
435
443
  ArrayNode: ArrayNodeCtor
436
444
  AssignmentNode: AssignmentNodeCtor
@@ -3285,10 +3293,12 @@ declare namespace math {
3285
3293
  factories: FactoryFunctionMap,
3286
3294
  config?: ConfigOptions
3287
3295
  ) => MathJsStatic
3288
- factory: <T>(
3296
+ factory: <T, TDeps extends readonly MathJsFunctionName[]>(
3289
3297
  name: string,
3290
- dependencies: MathJsFunctionName[],
3291
- create: (injected: Partial<MathJsStatic>) => T,
3298
+ dependencies: TDeps,
3299
+ create: (
3300
+ injected: Pick<MathJsStatic, Extract<MathJsFunctionName, TDeps[number]>>
3301
+ ) => T,
3292
3302
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
3293
3303
  meta?: any
3294
3304
  ) => FactoryFunction<T>
@@ -3806,22 +3816,7 @@ declare namespace math {
3806
3816
  interface MathNodeCommon {
3807
3817
  isNode: true
3808
3818
  comment: string
3809
- type:
3810
- | 'AccessorNode'
3811
- | 'ArrayNode'
3812
- | 'AssignmentNode'
3813
- | 'BlockNode'
3814
- | 'ConditionalNode'
3815
- | 'ConstantNode'
3816
- | 'FunctionAssignmentNode'
3817
- | 'FunctionNode'
3818
- | 'IndexNode'
3819
- | 'ObjectNode'
3820
- | 'OperatorNode'
3821
- | 'ParenthesisNode'
3822
- | 'RangeNode'
3823
- | 'RelationalNode'
3824
- | 'SymbolNode'
3819
+ type: string
3825
3820
 
3826
3821
  isUpdateNode?: boolean
3827
3822
 
@@ -3945,9 +3940,9 @@ declare namespace math {
3945
3940
  * transformed.toString(); // returns '(3 ^ 2) + (5 * 3)'
3946
3941
  * ```
3947
3942
  */
3948
- transform(
3949
- callback: (node: MathNode, path: string, parent: MathNode) => MathNode
3950
- ): MathNode
3943
+ transform<TResult>(
3944
+ callback: (node: this, path: string, parent: MathNode) => TResult
3945
+ ): TResult
3951
3946
 
3952
3947
  /**
3953
3948
  * `traverse(callback)`
package/types/index.ts CHANGED
@@ -28,6 +28,7 @@ import {
28
28
  OperatorNodeFn,
29
29
  OperatorNodeOp,
30
30
  SymbolNode,
31
+ ParenthesisNode,
31
32
  } from 'mathjs'
32
33
  import * as assert from 'assert'
33
34
  import { expectTypeOf } from 'expect-type'
@@ -825,6 +826,17 @@ Complex numbers examples
825
826
  }
826
827
  }
827
828
 
829
+ /*
830
+ Parenthesis examples
831
+ */
832
+ {
833
+ const math = create(all, {})
834
+
835
+ expectTypeOf(
836
+ new math.ParenthesisNode(new math.ConstantNode(3))
837
+ ).toMatchTypeOf<ParenthesisNode<ConstantNode>>()
838
+ }
839
+
828
840
  /*
829
841
  Expressions examples
830
842
  */
@@ -924,6 +936,46 @@ Fractions examples
924
936
  const _a = math.fraction('2/3')
925
937
  }
926
938
 
939
+ /*
940
+ Transform examples
941
+ */
942
+ {
943
+ const math = create(all, {})
944
+ {
945
+ const myTransform1 = (node: MathNode): OperatorNode<'+', 'add'> =>
946
+ new OperatorNode('+', 'add', [node, new ConstantNode(1)])
947
+ const myTransform2 = (
948
+ node: OperatorNode<'+', 'add'>
949
+ ): OperatorNode<'-', 'subtract'> =>
950
+ new OperatorNode('-', 'subtract', [node, new ConstantNode(5)])
951
+
952
+ expectTypeOf(
953
+ math.parse('sqrt(3^2 + 4^2)').transform(myTransform1)
954
+ ).toMatchTypeOf<OperatorNode<'+', 'add', MathNode[]>>()
955
+
956
+ assert.deepStrictEqual(
957
+ math.parse('sqrt(3^2 + 4^2)').transform(myTransform1).toString(),
958
+ 'sqrt(3 ^ 2 + 4 ^ 2) + 1'
959
+ )
960
+
961
+ expectTypeOf(
962
+ math
963
+ .parse('sqrt(3^2 + 4^2)')
964
+ .transform(myTransform1)
965
+ .transform(myTransform2)
966
+ ).toMatchTypeOf<OperatorNode<'-', 'subtract', MathNode[]>>()
967
+
968
+ assert.deepStrictEqual(
969
+ math
970
+ .parse('sqrt(3^2 + 4^2)')
971
+ .transform(myTransform1)
972
+ .transform(myTransform2)
973
+ .toString(),
974
+ 'sqrt(3 ^ 2 + 4 ^ 2) + 1 - 5'
975
+ )
976
+ }
977
+ }
978
+
927
979
  /*
928
980
  Matrices examples
929
981
  */