mathjs 11.1.0 → 11.2.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.
- package/CONTRIBUTING.md +1 -4
- package/HISTORY.md +11 -0
- package/lib/browser/math.js +1 -1
- package/lib/browser/math.js.LICENSE.txt +2 -2
- package/lib/browser/math.js.map +1 -1
- package/lib/cjs/core/create.js +1 -0
- package/lib/cjs/core/function/typed.js +3 -0
- package/lib/cjs/entry/typeChecks.js +6 -0
- package/lib/cjs/header.js +2 -2
- package/lib/cjs/utils/is.js +5 -0
- package/lib/cjs/version.js +1 -1
- package/lib/esm/core/create.js +2 -1
- package/lib/esm/core/function/typed.js +4 -1
- package/lib/esm/entry/typeChecks.js +1 -1
- package/lib/esm/utils/is.js +3 -0
- package/lib/esm/version.js +1 -1
- package/package.json +11 -12
- package/types/index.d.ts +20 -16
- package/types/index.ts +21 -0
package/lib/cjs/core/create.js
CHANGED
@@ -122,6 +122,7 @@ function create(factories, config) {
|
|
122
122
|
isOperatorNode: _is.isOperatorNode,
|
123
123
|
isParenthesisNode: _is.isParenthesisNode,
|
124
124
|
isRangeNode: _is.isRangeNode,
|
125
|
+
isRelationalNode: _is.isRelationalNode,
|
125
126
|
isSymbolNode: _is.isSymbolNode,
|
126
127
|
isChain: _is.isChain
|
127
128
|
}); // load config function and apply provided config
|
@@ -197,6 +197,9 @@ var createTyped = /* #__PURE__ */(0, _factory.factory)('typed', dependencies, fu
|
|
197
197
|
}, {
|
198
198
|
name: 'RangeNode',
|
199
199
|
test: _is.isRangeNode
|
200
|
+
}, {
|
201
|
+
name: 'RelationalNode',
|
202
|
+
test: _is.isRelationalNode
|
200
203
|
}, {
|
201
204
|
name: 'SymbolNode',
|
202
205
|
test: _is.isSymbolNode
|
@@ -195,6 +195,12 @@ Object.defineProperty(exports, "isRegExp", {
|
|
195
195
|
return _is.isRegExp;
|
196
196
|
}
|
197
197
|
});
|
198
|
+
Object.defineProperty(exports, "isRelationalNode", {
|
199
|
+
enumerable: true,
|
200
|
+
get: function get() {
|
201
|
+
return _is.isRelationalNode;
|
202
|
+
}
|
203
|
+
});
|
198
204
|
Object.defineProperty(exports, "isResultSet", {
|
199
205
|
enumerable: true,
|
200
206
|
get: function get() {
|
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 11.
|
10
|
-
* @date 2022-
|
9
|
+
* @version 11.2.0
|
10
|
+
* @date 2022-09-12
|
11
11
|
*
|
12
12
|
* @license
|
13
13
|
* Copyright (C) 2013-2022 Jos de Jong <wjosdejong@gmail.com>
|
package/lib/cjs/utils/is.js
CHANGED
@@ -37,6 +37,7 @@ exports.isParenthesisNode = isParenthesisNode;
|
|
37
37
|
exports.isRange = isRange;
|
38
38
|
exports.isRangeNode = isRangeNode;
|
39
39
|
exports.isRegExp = isRegExp;
|
40
|
+
exports.isRelationalNode = isRelationalNode;
|
40
41
|
exports.isResultSet = isResultSet;
|
41
42
|
exports.isSparseMatrix = isSparseMatrix;
|
42
43
|
exports.isString = isString;
|
@@ -237,6 +238,10 @@ function isRangeNode(x) {
|
|
237
238
|
return x && x.isRangeNode === true && x.constructor.prototype.isNode === true || false;
|
238
239
|
}
|
239
240
|
|
241
|
+
function isRelationalNode(x) {
|
242
|
+
return x && x.isRelationalNode === true && x.constructor.prototype.isNode === true || false;
|
243
|
+
}
|
244
|
+
|
240
245
|
function isSymbolNode(x) {
|
241
246
|
return x && x.isSymbolNode === true && x.constructor.prototype.isNode === true || false;
|
242
247
|
}
|
package/lib/cjs/version.js
CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.version = void 0;
|
7
|
-
var version = '11.
|
7
|
+
var version = '11.2.0'; // 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;
|
package/lib/esm/core/create.js
CHANGED
@@ -5,7 +5,7 @@ import * as emitter from './../utils/emitter.js';
|
|
5
5
|
import { importFactory } from './function/import.js';
|
6
6
|
import { configFactory } from './function/config.js';
|
7
7
|
import { factory, isFactory } from '../utils/factory.js';
|
8
|
-
import { isAccessorNode, isArray, isArrayNode, isAssignmentNode, isBigNumber, isBlockNode, isBoolean, isChain, isCollection, isComplex, isConditionalNode, isConstantNode, isDate, isDenseMatrix, isFraction, isFunction, isFunctionAssignmentNode, isFunctionNode, isHelp, isIndex, isIndexNode, isMatrix, isNode, isNull, isNumber, isObject, isObjectNode, isOperatorNode, isParenthesisNode, isRange, isRangeNode, isRegExp, isResultSet, isSparseMatrix, isString, isSymbolNode, isUndefined, isUnit } from '../utils/is.js';
|
8
|
+
import { isAccessorNode, isArray, isArrayNode, isAssignmentNode, isBigNumber, isBlockNode, isBoolean, isChain, isCollection, isComplex, isConditionalNode, isConstantNode, isDate, isDenseMatrix, isFraction, isFunction, isFunctionAssignmentNode, isFunctionNode, isHelp, isIndex, isIndexNode, isMatrix, isNode, isNull, isNumber, isObject, isObjectNode, isOperatorNode, isParenthesisNode, isRange, isRangeNode, isRelationalNode, isRegExp, isResultSet, isSparseMatrix, isString, isSymbolNode, isUndefined, isUnit } from '../utils/is.js';
|
9
9
|
import { ArgumentsError } from '../error/ArgumentsError.js';
|
10
10
|
import { DimensionError } from '../error/DimensionError.js';
|
11
11
|
import { IndexError } from '../error/IndexError.js';
|
@@ -97,6 +97,7 @@ export function create(factories, config) {
|
|
97
97
|
isOperatorNode,
|
98
98
|
isParenthesisNode,
|
99
99
|
isRangeNode,
|
100
|
+
isRelationalNode,
|
100
101
|
isSymbolNode,
|
101
102
|
isChain
|
102
103
|
}); // load config function and apply provided config
|
@@ -35,7 +35,7 @@
|
|
35
35
|
* @param {Object<string, function>} signatures Object with one or multiple function signatures
|
36
36
|
* @returns {function} The created typed-function.
|
37
37
|
*/
|
38
|
-
import { isAccessorNode, isArray, isArrayNode, isAssignmentNode, isBigNumber, isBlockNode, isBoolean, isChain, isCollection, isComplex, isConditionalNode, isConstantNode, isDate, isDenseMatrix, isFraction, isFunction, isFunctionAssignmentNode, isFunctionNode, isHelp, isIndex, isIndexNode, isMatrix, isNode, isNull, isNumber, isObject, isObjectNode, isOperatorNode, isParenthesisNode, isRange, isRangeNode, isRegExp, isResultSet, isSparseMatrix, isString, isSymbolNode, isUndefined, isUnit } from '../../utils/is.js';
|
38
|
+
import { isAccessorNode, isArray, isArrayNode, isAssignmentNode, isBigNumber, isBlockNode, isBoolean, isChain, isCollection, isComplex, isConditionalNode, isConstantNode, isDate, isDenseMatrix, isFraction, isFunction, isFunctionAssignmentNode, isFunctionNode, isHelp, isIndex, isIndexNode, isMatrix, isNode, isNull, isNumber, isObject, isObjectNode, isOperatorNode, isParenthesisNode, isRange, isRangeNode, isRelationalNode, isRegExp, isResultSet, isSparseMatrix, isString, isSymbolNode, isUndefined, isUnit } from '../../utils/is.js';
|
39
39
|
import typedFunction from 'typed-function';
|
40
40
|
import { digits } from '../../utils/number.js';
|
41
41
|
import { factory } from '../../utils/factory.js';
|
@@ -183,6 +183,9 @@ export var createTyped = /* #__PURE__ */factory('typed', dependencies, function
|
|
183
183
|
}, {
|
184
184
|
name: 'RangeNode',
|
185
185
|
test: isRangeNode
|
186
|
+
}, {
|
187
|
+
name: 'RelationalNode',
|
188
|
+
test: isRelationalNode
|
186
189
|
}, {
|
187
190
|
name: 'SymbolNode',
|
188
191
|
test: isSymbolNode
|
@@ -1,2 +1,2 @@
|
|
1
1
|
// util functions
|
2
|
-
export { isAccessorNode, isArray, isArrayNode, isAssignmentNode, isBigNumber, isBlockNode, isBoolean, isChain, isCollection, isComplex, isConditionalNode, isConstantNode, isDate, isDenseMatrix, isFraction, isFunction, isFunctionAssignmentNode, isFunctionNode, isHelp, isIndex, isIndexNode, isMatrix, isNode, isNull, isNumber, isString, isUndefined, isObject, isObjectNode, isOperatorNode, isParenthesisNode, isRange, isRangeNode, isRegExp, isResultSet, isSparseMatrix, isSymbolNode, isUnit } from '../utils/is.js';
|
2
|
+
export { isAccessorNode, isArray, isArrayNode, isAssignmentNode, isBigNumber, isBlockNode, isBoolean, isChain, isCollection, isComplex, isConditionalNode, isConstantNode, isDate, isDenseMatrix, isFraction, isFunction, isFunctionAssignmentNode, isFunctionNode, isHelp, isIndex, isIndexNode, isMatrix, isNode, isNull, isNumber, isString, isUndefined, isObject, isObjectNode, isOperatorNode, isParenthesisNode, isRange, isRangeNode, isRelationalNode, isRegExp, isResultSet, isSparseMatrix, isSymbolNode, isUnit } from '../utils/is.js';
|
package/lib/esm/utils/is.js
CHANGED
@@ -149,6 +149,9 @@ export function isParenthesisNode(x) {
|
|
149
149
|
export function isRangeNode(x) {
|
150
150
|
return x && x.isRangeNode === true && x.constructor.prototype.isNode === true || false;
|
151
151
|
}
|
152
|
+
export function isRelationalNode(x) {
|
153
|
+
return x && x.isRelationalNode === true && x.constructor.prototype.isNode === true || false;
|
154
|
+
}
|
152
155
|
export function isSymbolNode(x) {
|
153
156
|
return x && x.isSymbolNode === true && x.constructor.prototype.isNode === true || false;
|
154
157
|
}
|
package/lib/esm/version.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export var version = '11.
|
1
|
+
export var version = '11.2.0'; // 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": "11.
|
3
|
+
"version": "11.2.0",
|
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.
|
28
|
+
"@babel/runtime": "^7.19.0",
|
29
29
|
"complex.js": "^2.1.1",
|
30
30
|
"decimal.js": "^10.4.0",
|
31
31
|
"escape-latex": "^1.2.0",
|
@@ -36,31 +36,31 @@
|
|
36
36
|
"typed-function": "^4.1.0"
|
37
37
|
},
|
38
38
|
"devDependencies": {
|
39
|
-
"@babel/core": "7.
|
39
|
+
"@babel/core": "7.19.0",
|
40
40
|
"@babel/plugin-transform-object-assign": "7.18.6",
|
41
41
|
"@babel/plugin-transform-runtime": "7.18.10",
|
42
|
-
"@babel/preset-env": "7.
|
42
|
+
"@babel/preset-env": "7.19.0",
|
43
43
|
"@babel/register": "7.18.9",
|
44
44
|
"@types/assert": "1.5.6",
|
45
45
|
"@types/mocha": "9.1.1",
|
46
|
-
"@typescript-eslint/eslint-plugin": "5.
|
47
|
-
"@typescript-eslint/parser": "5.
|
46
|
+
"@typescript-eslint/eslint-plugin": "5.36.2",
|
47
|
+
"@typescript-eslint/parser": "5.36.2",
|
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.
|
52
|
+
"core-js": "3.25.1",
|
53
53
|
"del": "6.1.1",
|
54
54
|
"dtslint": "4.2.1",
|
55
|
-
"eslint": "8.
|
55
|
+
"eslint": "8.23.1",
|
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.1.0",
|
60
60
|
"eslint-plugin-n": "15.2.5",
|
61
61
|
"eslint-plugin-prettier": "4.2.1",
|
62
|
-
"eslint-plugin-promise": "6.0.
|
63
|
-
"expect-type": "0.
|
62
|
+
"eslint-plugin-promise": "6.0.1",
|
63
|
+
"expect-type": "0.14.2",
|
64
64
|
"expr-eval": "2.0.2",
|
65
65
|
"fancy-log": "2.0.0",
|
66
66
|
"glob": "8.0.3",
|
@@ -90,7 +90,7 @@
|
|
90
90
|
"process": "0.11.10",
|
91
91
|
"sylvester": "0.0.21",
|
92
92
|
"ts-node": "10.9.1",
|
93
|
-
"typescript": "4.
|
93
|
+
"typescript": "4.8.3",
|
94
94
|
"webpack": "5.74.0",
|
95
95
|
"zeros": "1.0.0"
|
96
96
|
},
|
@@ -164,7 +164,6 @@
|
|
164
164
|
"test:types": "cd types && tsc -p ./tsconfig.json && node --loader ts-node/esm ./index.ts",
|
165
165
|
"coverage": "nyc --reporter=lcov --reporter=text-summary mocha test/unit-tests && echo \"\nDetailed coverage report is available at ./coverage/lcov-report/index.html\"",
|
166
166
|
"prepublishOnly": "npm run test:all && npm run lint",
|
167
|
-
"prepare": "npm run build",
|
168
167
|
"update-authors": "node ./tools/update-authors.js"
|
169
168
|
},
|
170
169
|
"bin": {
|
package/types/index.d.ts
CHANGED
@@ -283,6 +283,7 @@ declare namespace math {
|
|
283
283
|
type OperatorNodeMap = {
|
284
284
|
xor: 'xor'
|
285
285
|
and: 'and'
|
286
|
+
or: 'or'
|
286
287
|
bitOr: '|'
|
287
288
|
bitXor: '^|'
|
288
289
|
bitAnd: '&'
|
@@ -291,6 +292,7 @@ declare namespace math {
|
|
291
292
|
smaller: '<'
|
292
293
|
larger: '>'
|
293
294
|
smallerEq: '<='
|
295
|
+
largerEq: '>='
|
294
296
|
leftShift: '<<'
|
295
297
|
rightArithShift: '>>'
|
296
298
|
rightLogShift: '>>>'
|
@@ -2201,11 +2203,9 @@ declare namespace math {
|
|
2201
2203
|
* undefined. Returns an array with the configured number of elements
|
2202
2204
|
* when number is > 1.
|
2203
2205
|
*/
|
2204
|
-
pickRandom(
|
2205
|
-
|
2206
|
-
|
2207
|
-
weights?: number[]
|
2208
|
-
): number | number[]
|
2206
|
+
pickRandom<T>(array: T[]): T
|
2207
|
+
pickRandom<T>(array: T[], number: number): T[]
|
2208
|
+
pickRandom<T>(array: T[], number: number, weights: number[]): T[]
|
2209
2209
|
|
2210
2210
|
/**
|
2211
2211
|
* Return a random number larger or equal to min and smaller than max
|
@@ -2576,9 +2576,9 @@ declare namespace math {
|
|
2576
2576
|
median(...args: MathType[]): any
|
2577
2577
|
|
2578
2578
|
/**
|
2579
|
-
* Compute the
|
2580
|
-
* a multi dimensional array, the
|
2581
|
-
* calculated. When dim is provided, the
|
2579
|
+
* Compute the minimum value of a matrix or a list of values. In case of
|
2580
|
+
* a multi dimensional array, the minimun of the flattened array will be
|
2581
|
+
* calculated. When dim is provided, the minimun over the selected
|
2582
2582
|
* dimension will be calculated. Parameter dim is zero-based.
|
2583
2583
|
* @param args A single matrix or or multiple scalar values
|
2584
2584
|
* @returns The minimum value
|
@@ -3158,6 +3158,8 @@ declare namespace math {
|
|
3158
3158
|
|
3159
3159
|
isRangeNode(x: unknown): x is RangeNode
|
3160
3160
|
|
3161
|
+
isRelationalNode(x: unknown): x is RelationalNode
|
3162
|
+
|
3161
3163
|
isSymbolNode(x: unknown): x is SymbolNode
|
3162
3164
|
|
3163
3165
|
isChain(x: unknown): x is MathJsChain<unknown>
|
@@ -5521,11 +5523,13 @@ declare namespace math {
|
|
5521
5523
|
* @param number An int or float
|
5522
5524
|
* @param weights An array of ints or floats
|
5523
5525
|
*/
|
5524
|
-
pickRandom(
|
5525
|
-
|
5526
|
-
|
5527
|
-
|
5528
|
-
|
5526
|
+
pickRandom<T>(this: MathJsChain<T[]>): MathJsChain<T>
|
5527
|
+
pickRandom<T>(this: MathJsChain<T[]>, number: number): MathJsChain<T[]>
|
5528
|
+
pickRandom<T>(
|
5529
|
+
this: MathJsChain<T[]>,
|
5530
|
+
number: number,
|
5531
|
+
weights: number[]
|
5532
|
+
): MathJsChain<T[]>
|
5529
5533
|
|
5530
5534
|
/**
|
5531
5535
|
* Return a random number larger or equal to min and smaller than max
|
@@ -5873,9 +5877,9 @@ declare namespace math {
|
|
5873
5877
|
median(this: MathJsChain<MathCollection>, dim?: number): MathJsChain<any>
|
5874
5878
|
|
5875
5879
|
/**
|
5876
|
-
* Compute the
|
5877
|
-
* a multi dimensional array, the
|
5878
|
-
* calculated. When dim is provided, the
|
5880
|
+
* Compute the minimum value of a matrix or a list of values. In case of
|
5881
|
+
* a multi dimensional array, the minimum of the flattened array will be
|
5882
|
+
* calculated. When dim is provided, the minimum over the selected
|
5879
5883
|
* dimension will be calculated. Parameter dim is zero-based.
|
5880
5884
|
* @param dim The minimum over the selected dimension
|
5881
5885
|
*/
|
package/types/index.ts
CHANGED
@@ -2076,6 +2076,7 @@ Factory Test
|
|
2076
2076
|
math.isOperatorNode,
|
2077
2077
|
math.isParenthesisNode,
|
2078
2078
|
math.isRangeNode,
|
2079
|
+
math.isRelationalNode,
|
2079
2080
|
math.isSymbolNode,
|
2080
2081
|
math.isChain,
|
2081
2082
|
]
|
@@ -2189,6 +2190,9 @@ Factory Test
|
|
2189
2190
|
if (math.isRangeNode(x)) {
|
2190
2191
|
expectTypeOf(x).toMatchTypeOf<RangeNode>()
|
2191
2192
|
}
|
2193
|
+
if (math.isRelationalNode(x)) {
|
2194
|
+
expectTypeOf(x).toMatchTypeOf<math.RelationalNode>()
|
2195
|
+
}
|
2192
2196
|
if (math.isSymbolNode(x)) {
|
2193
2197
|
expectTypeOf(x).toMatchTypeOf<SymbolNode>()
|
2194
2198
|
}
|
@@ -2242,3 +2246,20 @@ Resolve examples
|
|
2242
2246
|
).toMatchTypeOf<MathNode[]>()
|
2243
2247
|
expectTypeOf(math.resolve(math.matrix(['x', 'y']))).toMatchTypeOf<Matrix>()
|
2244
2248
|
}
|
2249
|
+
|
2250
|
+
/*
|
2251
|
+
Random examples
|
2252
|
+
*/
|
2253
|
+
{
|
2254
|
+
const math = create(all, {})
|
2255
|
+
expectTypeOf(math.pickRandom([1, 2, 3])).toMatchTypeOf<number>()
|
2256
|
+
expectTypeOf(math.pickRandom(['a', { b: 10 }, 42])).toMatchTypeOf<
|
2257
|
+
string | number | { b: number }
|
2258
|
+
>()
|
2259
|
+
expectTypeOf(math.pickRandom([1, 2, 3])).toMatchTypeOf<number>()
|
2260
|
+
expectTypeOf(math.pickRandom([1, 2, 3], 2)).toMatchTypeOf<number[]>()
|
2261
|
+
|
2262
|
+
expectTypeOf(math.chain([1, 2, 3]).pickRandom(2)).toMatchTypeOf<
|
2263
|
+
MathJsChain<number[]>
|
2264
|
+
>()
|
2265
|
+
}
|