Socket
Socket
Sign inDemoInstall

mathjs

Package Overview
Dependencies
10
Maintainers
1
Versions
272
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 11.8.0 to 11.8.1

lib/cjs/utils/applyCallback.js

4

lib/browser/math.js.LICENSE.txt

@@ -26,4 +26,4 @@ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */

*
* @version 11.8.0
* @date 2023-04-03
* @version 11.8.1
* @date 2023-06-13
*

@@ -30,0 +30,0 @@ * @license

@@ -9,2 +9,3 @@ "use strict";

var _dependenciesAddScalarGenerated = require("./dependenciesAddScalar.generated.js");
var _dependenciesDeepEqualGenerated = require("./dependenciesDeepEqual.generated.js");
var _dependenciesDivideScalarGenerated = require("./dependenciesDivideScalar.generated.js");

@@ -15,3 +16,2 @@ var _dependenciesMultiplyScalarGenerated = require("./dependenciesMultiplyScalar.generated.js");

var _dependenciesTypedGenerated = require("./dependenciesTyped.generated.js");
var _dependenciesUnaryMinusGenerated = require("./dependenciesUnaryMinus.generated.js");
var _factoriesAny = require("../../factoriesAny.js");

@@ -26,2 +26,3 @@ /**

addScalarDependencies: _dependenciesAddScalarGenerated.addScalarDependencies,
deepEqualDependencies: _dependenciesDeepEqualGenerated.deepEqualDependencies,
divideScalarDependencies: _dependenciesDivideScalarGenerated.divideScalarDependencies,

@@ -32,5 +33,4 @@ multiplyScalarDependencies: _dependenciesMultiplyScalarGenerated.multiplyScalarDependencies,

typedDependencies: _dependenciesTypedGenerated.typedDependencies,
unaryMinusDependencies: _dependenciesUnaryMinusGenerated.unaryMinusDependencies,
createDistance: _factoriesAny.createDistance
};
exports.distanceDependencies = distanceDependencies;

@@ -1069,2 +1069,3 @@ "use strict";

addScalar: addScalar,
deepEqual: deepEqual,
divideScalar: divideScalar,

@@ -1074,4 +1075,3 @@ multiplyScalar: multiplyScalar,

subtract: subtract,
typed: typed,
unaryMinus: unaryMinus
typed: typed
});

@@ -1078,0 +1078,0 @@ exports.distance = distance;

@@ -37,3 +37,3 @@ "use strict";

* // get and set variables and functions
* const x = parser.get('x') // 7
* const x = parser.get('x') // 3.5
* const f = parser.get('f') // function

@@ -40,0 +40,0 @@ * const g = f(3, 2) // 9

@@ -47,3 +47,3 @@ "use strict";

* // get and set variables and functions
* const x = parser.get('x') // 7
* const x = parser.get('x') // 3.5
* const f = parser.get('f') // function

@@ -50,0 +50,0 @@ * const g = f(3, 2) // 9

@@ -7,7 +7,7 @@ "use strict";

exports.createFilterTransform = void 0;
var _applyCallback = require("../../utils/applyCallback.js");
var _array = require("../../utils/array.js");
var _factory = require("../../utils/factory.js");
var _is = require("../../utils/is.js");
var _array = require("../../utils/array.js");
var _function = require("../../utils/function.js");
var _compileInlineExpression = require("./utils/compileInlineExpression.js");
var _factory = require("../../utils/factory.js");
var name = 'filter';

@@ -70,15 +70,6 @@ var dependencies = ['typed'];

function _filter(x, callback) {
// figure out what number of arguments the callback function expects
var args = (0, _function.maxArgumentCount)(callback);
return (0, _array.filter)(x, function (value, index, array) {
// invoke the callback function with the right number of arguments
if (args === 1) {
return callback(value);
} else if (args === 2) {
return callback(value, [index + 1]);
} else {
// 3 or -1
return callback(value, [index + 1], array);
}
return (0, _applyCallback.applyCallback)(callback, value, [index + 1], array, 'filter');
});
}

@@ -7,6 +7,6 @@ "use strict";

exports.createForEachTransform = void 0;
var _is = require("../../utils/is.js");
var _function = require("../../utils/function.js");
var _applyCallback = require("../../utils/applyCallback.js");
var _array = require("../../utils/array.js");
var _factory = require("../../utils/factory.js");
var _is = require("../../utils/is.js");
var _compileInlineExpression = require("./utils/compileInlineExpression.js");

@@ -44,4 +44,2 @@ var name = 'forEach';

'Array | Matrix, function': function ArrayMatrixFunction(array, callback) {
// figure out what number of arguments the callback function expects
var args = (0, _function.maxArgumentCount)(callback);
var recurse = function recurse(value, index) {

@@ -55,10 +53,3 @@ if (Array.isArray(value)) {

// invoke the callback function with the right number of arguments
if (args === 1) {
callback(value);
} else if (args === 2) {
callback(value, index);
} else {
// 3 or -1
callback(value, index, array);
}
return (0, _applyCallback.applyCallback)(callback, value, index, array, 'forEach');
}

@@ -65,0 +56,0 @@ };

@@ -7,6 +7,6 @@ "use strict";

exports.createMapTransform = void 0;
var _is = require("../../utils/is.js");
var _function = require("../../utils/function.js");
var _applyCallback = require("../../utils/applyCallback.js");
var _array = require("../../utils/array.js");
var _factory = require("../../utils/factory.js");
var _is = require("../../utils/is.js");
var _compileInlineExpression = require("./utils/compileInlineExpression.js");

@@ -56,3 +56,3 @@ var name = 'map';

/**
* Map for a multi dimensional array. One-based indexes
* Map for a multidimensional array. One-based indexes
* @param {Array} array

@@ -66,4 +66,2 @@ * @param {function} callback

function _map(array, callback, orig) {
// figure out what number of arguments the callback function expects
var argsCount = (0, _function.maxArgumentCount)(callback);
function recurse(value, index) {

@@ -77,10 +75,3 @@ if (Array.isArray(value)) {

// invoke the (typed) callback function with the right number of arguments
if (argsCount === 1) {
return callback(value);
} else if (argsCount === 2) {
return callback(value, index);
} else {
// 3 or -1
return callback(value, index, orig);
}
return (0, _applyCallback.applyCallback)(callback, value, index, orig, 'map');
}

@@ -87,0 +78,0 @@ }

@@ -36,4 +36,4 @@ "use strict";

*
* derivative(expr, variable)
* derivative(expr, variable, options)
* math.derivative(expr, variable)
* math.derivative(expr, variable, options)
*

@@ -40,0 +40,0 @@ * Examples:

@@ -36,3 +36,3 @@ "use strict";

*
* leafCount(expr)
* math.leafCount(expr)
*

@@ -39,0 +39,0 @@ * Examples:

@@ -34,3 +34,3 @@ "use strict";

*
* polynomialRoot(constant, linearCoeff, quadraticCoeff, cubicCoeff)
* math.polynomialRoot(constant, linearCoeff, quadraticCoeff, cubicCoeff)
*

@@ -37,0 +37,0 @@ * Examples:

@@ -46,6 +46,6 @@ "use strict";

*
* rationalize(expr)
* rationalize(expr, detailed)
* rationalize(expr, scope)
* rationalize(expr, scope, detailed)
* math.rationalize(expr)
* math.rationalize(expr, detailed)
* math.rationalize(expr, scope)
* math.rationalize(expr, scope, detailed)
*

@@ -52,0 +52,0 @@ * Examples:

@@ -24,3 +24,3 @@ "use strict";

*
* resolve(expr, scope)
* math.resolve(expr, scope)
*

@@ -27,0 +27,0 @@ * Examples:

@@ -146,9 +146,9 @@ "use strict";

*
* simplify(expr)
* simplify(expr, rules)
* simplify(expr, rules)
* simplify(expr, rules, scope)
* simplify(expr, rules, scope, options)
* simplify(expr, scope)
* simplify(expr, scope, options)
* math.simplify(expr)
* math.simplify(expr, rules)
* math.simplify(expr, rules)
* math.simplify(expr, rules, scope)
* math.simplify(expr, rules, scope, options)
* math.simplify(expr, scope)
* math.simplify(expr, scope, options)
*

@@ -155,0 +155,0 @@ * Examples:

@@ -51,4 +51,4 @@ "use strict";

*
* simplifyConstant(expr)
* simplifyConstant(expr, options)
* math.simplifyConstant(expr)
* math.simplifyConstant(expr, options)
*

@@ -55,0 +55,0 @@ * Examples:

@@ -73,4 +73,4 @@ "use strict";

*
* simplifyCore(expr)
* simplifyCore(expr, options)
* math.simplifyCore(expr)
* math.simplifyCore(expr, options)
*

@@ -77,0 +77,0 @@ * Examples:

@@ -32,16 +32,16 @@ "use strict";

*
* symbolicEqual(expr1, expr2)
* symbolicEqual(expr1, expr2, options)
* math.symbolicEqual(expr1, expr2)
* math.symbolicEqual(expr1, expr2, options)
*
* Examples:
*
* symbolicEqual('x*y', 'y*x') // Returns true
* symbolicEqual('x*y', 'y*x', {context: {multiply: {commutative: false}}}) // Returns false
* symbolicEqual('x/y', '(y*x^(-1))^(-1)') // Returns true
* symbolicEqual('abs(x)','x') // Returns false
* symbolicEqual('abs(x)','x', simplify.positiveContext) // Returns true
* math.symbolicEqual('x*y', 'y*x') // Returns true
* math.symbolicEqual('x*y', 'y*x', {context: {multiply: {commutative: false}}}) // Returns false
* math.symbolicEqual('x/y', '(y*x^(-1))^(-1)') // Returns true
* math.symbolicEqual('abs(x)','x') // Returns false
* math.symbolicEqual('abs(x)','x', simplify.positiveContext) // Returns true
*
* See also:
*
* simplify, evaluate
* simplify, evaluate
*

@@ -48,0 +48,0 @@ * @param {Node|string} expr1 The first expression to compare

@@ -10,3 +10,3 @@ "use strict";

var name = 'distance';
var dependencies = ['typed', 'addScalar', 'subtract', 'divideScalar', 'multiplyScalar', 'unaryMinus', 'sqrt', 'abs'];
var dependencies = ['typed', 'addScalar', 'subtract', 'divideScalar', 'multiplyScalar', 'deepEqual', 'sqrt', 'abs'];
var createDistance = /* #__PURE__ */(0, _factory.factory)(name, dependencies, function (_ref) {

@@ -18,3 +18,3 @@ var typed = _ref.typed,

divideScalar = _ref.divideScalar,
unaryMinus = _ref.unaryMinus,
deepEqual = _ref.deepEqual,
sqrt = _ref.sqrt,

@@ -40,6 +40,6 @@ abs = _ref.abs;

* math.distance([[x1,y1,z1], [x2,y2,z2], [x3,y3,z3]])
* math.distance([x1,y1], [x2,y2,z2])
* math.distance([x1,y1], [x2,y2], [x3,y3])
* math.distance([pointX,pointY], [a,b,c])
* math.distance([pointX,pointY], [lineOnePtX,lineOnePtY], [lineTwoPtX,lineTwoPtY])
* math.distance({pointX, pointY}, {lineOnePtX, lineOnePtY}, {lineTwoPtX, lineTwoPtY})
* math.distance([x1,y1,z1], [x0, y0, z0, a, b, c])
* math.distance([pointX,pointY,pointZ], [x0, y0, z0, a, b, c])
* math.distance({pointX, pointY, pointZ}, {x0, y0, z0, a, b, c})

@@ -60,7 +60,7 @@ *

* math.distance([10, 10], [8, 1, 3]) // Returns 11.535230316796387
* math.distance([10, 10], [2, 3], [-8, 0]) // Returns 8.759953130362847
* math.distance([0, 0], [3, 0], [0, 4]) // Returns 2.4
* math.distance(
* {pointX: 1, pointY: 4},
* {lineOnePtX: 6, lineOnePtY: 3},
* {lineTwoPtX: 2, lineTwoPtY: 8}) // Returns 2.720549372624744
* {pointX: 0, pointY: 0},
* {lineOnePtX: 3, lineOnePtY: 0},
* {lineTwoPtX: 0, lineTwoPtY: 4}) // Returns 2.4
* math.distance([2, 3, 1], [1, 1, 2, 5, 0, 1]) // Returns 2.3204774044612857

@@ -88,6 +88,8 @@ * math.distance(

}
var m = divideScalar(subtract(z[1], z[0]), subtract(y[1], y[0]));
var xCoeff = multiplyScalar(multiplyScalar(m, m), y[0]);
var yCoeff = unaryMinus(multiplyScalar(m, y[0]));
var constant = x[1];
if (deepEqual(y, z)) {
throw new TypeError('LinePoint1 should not be same with LinePoint2');
}
var xCoeff = subtract(z[1], y[1]);
var yCoeff = subtract(y[0], z[0]);
var constant = subtract(multiplyScalar(z[0], y[1]), multiplyScalar(y[0], z[1]));
return _distancePointLine2D(x[0], x[1], xCoeff, yCoeff, constant);

@@ -109,7 +111,9 @@ } else {

}
if (deepEqual(_objectToArray(y), _objectToArray(z))) {
throw new TypeError('LinePoint1 should not be same with LinePoint2');
}
if ('pointX' in x && 'pointY' in x && 'lineOnePtX' in y && 'lineOnePtY' in y && 'lineTwoPtX' in z && 'lineTwoPtY' in z) {
var m = divideScalar(subtract(z.lineTwoPtY, z.lineTwoPtX), subtract(y.lineOnePtY, y.lineOnePtX));
var xCoeff = multiplyScalar(multiplyScalar(m, m), y.lineOnePtX);
var yCoeff = unaryMinus(multiplyScalar(m, y.lineOnePtX));
var constant = x.pointX;
var xCoeff = subtract(z.lineTwoPtY, y.lineOnePtY);
var yCoeff = subtract(y.lineOnePtX, z.lineTwoPtX);
var constant = subtract(multiplyScalar(z.lineTwoPtX, y.lineOnePtY), multiplyScalar(y.lineOnePtX, z.lineTwoPtY));
return _distancePointLine2D(x.pointX, x.pointY, xCoeff, yCoeff, constant);

@@ -116,0 +120,0 @@ } else {

@@ -7,4 +7,4 @@ "use strict";

exports.createFilter = void 0;
var _applyCallback = require("../../utils/applyCallback.js");
var _array = require("../../utils/array.js");
var _function = require("../../utils/function.js");
var _factory = require("../../utils/factory.js");

@@ -65,15 +65,6 @@ var name = 'filter';

function _filterCallback(x, callback) {
// figure out what number of arguments the callback function expects
var args = (0, _function.maxArgumentCount)(callback);
return (0, _array.filter)(x, function (value, index, array) {
// invoke the callback function with the right number of arguments
if (args === 1) {
return callback(value);
} else if (args === 2) {
return callback(value, [index]);
} else {
// 3 or -1
return callback(value, [index], array);
}
return (0, _applyCallback.applyCallback)(callback, value, [index], array, 'filter');
});
}

@@ -7,3 +7,3 @@ "use strict";

exports.createForEach = void 0;
var _function = require("../../utils/function.js");
var _applyCallback = require("../../utils/applyCallback.js");
var _array = require("../../utils/array.js");

@@ -47,3 +47,3 @@ var _factory = require("../../utils/factory.js");

/**
* forEach for a multi dimensional array
* forEach for a multidimensional array
* @param {Array} array

@@ -55,4 +55,2 @@ * @param {Function} callback

function _forEach(array, callback) {
// figure out what number of arguments the callback function expects
var args = (0, _function.maxArgumentCount)(callback);
var recurse = function recurse(value, index) {

@@ -66,10 +64,3 @@ if (Array.isArray(value)) {

// invoke the callback function with the right number of arguments
if (args === 1) {
callback(value);
} else if (args === 2) {
callback(value, index);
} else {
// 3 or -1
callback(value, index, array);
}
return (0, _applyCallback.applyCallback)(callback, value, index, array, 'forEach');
}

@@ -76,0 +67,0 @@ };

@@ -7,3 +7,3 @@ "use strict";

exports.createMap = void 0;
var _function = require("../../utils/function.js");
var _applyCallback = require("../../utils/applyCallback.js");
var _factory = require("../../utils/factory.js");

@@ -35,10 +35,5 @@ var name = 'map';

*
* // The calling convention for the callback can cause subtleties:
* math.map([1, 2, 3], math.format)
* // throws TypeError: map attempted to call 'format(1,[0])' but argument 2 of type Array does not match expected type number or function or Object or string or boolean
* // [This happens because `format` _can_ take a second argument,
* // but its semantics don't match that of the 2nd argument `map` provides]
*
* // To avoid this error, use a function that takes exactly the
* // desired arguments:
* // The callback is normally called with three arguments:
* // callback(value, index, Array)
* // If you want to call with only one argument, use:
* math.map([1, 2, 3], x => math.format(x)) // returns ['1', '2', '3']

@@ -73,4 +68,2 @@ *

function _map(array, callback) {
// figure out what number of arguments the callback function expects
var args = (0, _function.maxArgumentCount)(callback);
var recurse = function recurse(value, index) {

@@ -83,29 +76,4 @@ if (Array.isArray(value)) {

} else {
try {
// invoke the callback function with the right number of arguments
if (args === 1) {
return callback(value);
} else if (args === 2) {
return callback(value, index);
} else {
// 3 or -1
return callback(value, index, array);
}
} catch (err) {
// But maybe the arguments still weren't right
if (err instanceof TypeError && 'data' in err && err.data.category === 'wrongType') {
var newmsg = "map attempted to call '".concat(err.data.fn, "(").concat(value);
var indexString = JSON.stringify(index);
if (args === 2) {
newmsg += ',' + indexString;
} else if (args !== 1) {
newmsg += ",".concat(indexString, ",").concat(array);
}
newmsg += ")' but argument ".concat(err.data.index + 1, " of type ");
newmsg += "".concat(err.data.actual, " does not match expected type ");
newmsg += err.data.expected.join(' or ');
throw new TypeError(newmsg);
}
throw err;
}
// invoke the callback function with the right number of arguments
return (0, _applyCallback.applyCallback)(callback, value, index, array, 'map');
}

@@ -112,0 +80,0 @@ };

@@ -62,3 +62,3 @@ "use strict";

*
* X = math.sqrtm(A)
* math.sqrtm(A)
*

@@ -65,0 +65,0 @@ * Examples:

@@ -9,4 +9,4 @@ /**

*
* @version 11.8.0
* @date 2023-04-03
* @version 11.8.1
* @date 2023-06-13
*

@@ -13,0 +13,0 @@ * @license

@@ -70,2 +70,9 @@ "use strict";

},
Unit: typed.referToSelf(function (self) {
return function (x) {
var clone = x.clone();
clone.value = self(x.value);
return clone;
};
}),
Fraction: function Fraction(x) {

@@ -72,0 +79,0 @@ return new BigNumber(x.n).div(x.d).times(x.s);

@@ -46,3 +46,3 @@ "use strict";

*
* @param {number | string | Fraction | BigNumber | Array | Matrix} [args]
* @param {number | string | Fraction | BigNumber | Unit | Array | Matrix} [args]
* Arguments specifying the value, or numerator and denominator of

@@ -75,2 +75,9 @@ * the fraction

Unit: typed.referToSelf(function (self) {
return function (x) {
var clone = x.clone();
clone.value = self(x.value);
return clone;
};
}),
Object: function Object(x) {

@@ -77,0 +84,0 @@ return new Fraction(x);

@@ -128,5 +128,9 @@ "use strict";

},
Unit: function Unit(x) {
throw new Error('Second argument with valueless unit expected');
},
Unit: typed.referToSelf(function (self) {
return function (x) {
var clone = x.clone();
clone.value = self(x.value);
return clone;
};
}),
"null": function _null(x) {

@@ -133,0 +137,0 @@ return 0;

@@ -17,3 +17,3 @@ "use strict";

*
* splitUnit(unit: Unit, parts: Array.<Unit>)
* math.splitUnit(unit: Unit, parts: Array.<Unit>)
*

@@ -20,0 +20,0 @@ * Example:

@@ -157,3 +157,3 @@ "use strict";

precision = options;
} else if (options.precision) {
} else if (options.precision !== undefined) {
precision = options.precision;

@@ -219,3 +219,3 @@ }

* Format a BigNumber in engineering notation. Like '1.23e+6', '2.3e+0', '3.500e-3'
* @param {BigNumber | string} value
* @param {BigNumber} value
* @param {number} [precision] Optional number of significant figures to return.

@@ -232,3 +232,4 @@ */

if (valueStr.indexOf('e') !== -1) {
valueStr = valueWithoutExp.toString();
var BigNumber = value.constructor;
valueStr = new BigNumber(valueStr).toFixed();
}

@@ -235,0 +236,0 @@ return valueStr + 'e' + (e >= 0 ? '+' : '') + newExp.toString();

@@ -7,5 +7,5 @@ "use strict";

exports.version = void 0;
var version = '11.8.0';
var version = '11.8.1';
// Note: This file is automatically generated when building math.js.
// Changes made in this file will be overwritten.
exports.version = version;

@@ -7,2 +7,3 @@ /**

import { addScalarDependencies } from './dependenciesAddScalar.generated.js';
import { deepEqualDependencies } from './dependenciesDeepEqual.generated.js';
import { divideScalarDependencies } from './dependenciesDivideScalar.generated.js';

@@ -13,3 +14,2 @@ import { multiplyScalarDependencies } from './dependenciesMultiplyScalar.generated.js';

import { typedDependencies } from './dependenciesTyped.generated.js';
import { unaryMinusDependencies } from './dependenciesUnaryMinus.generated.js';
import { createDistance } from '../../factoriesAny.js';

@@ -19,2 +19,3 @@ export var distanceDependencies = {

addScalarDependencies,
deepEqualDependencies,
divideScalarDependencies,

@@ -25,4 +26,3 @@ multiplyScalarDependencies,

typedDependencies,
unaryMinusDependencies,
createDistance
};

@@ -878,2 +878,3 @@ /**

addScalar,
deepEqual,
divideScalar,

@@ -883,4 +884,3 @@ multiplyScalar,

subtract,
typed,
unaryMinus
typed
});

@@ -887,0 +887,0 @@ export var dotMultiply = /* #__PURE__ */createDotMultiply({

@@ -33,3 +33,3 @@ import { factory } from '../../utils/factory.js';

* // get and set variables and functions
* const x = parser.get('x') // 7
* const x = parser.get('x') // 3.5
* const f = parser.get('f') // function

@@ -36,0 +36,0 @@ * const g = f(3, 2) // 9

@@ -43,3 +43,3 @@ import { factory } from '../utils/factory.js';

* // get and set variables and functions
* const x = parser.get('x') // 7
* const x = parser.get('x') // 3.5
* const f = parser.get('f') // function

@@ -46,0 +46,0 @@ * const g = f(3, 2) // 9

@@ -0,6 +1,6 @@

import { applyCallback } from '../../utils/applyCallback.js';
import { filter, filterRegExp } from '../../utils/array.js';
import { factory } from '../../utils/factory.js';
import { isFunctionAssignmentNode, isSymbolNode } from '../../utils/is.js';
import { filter, filterRegExp } from '../../utils/array.js';
import { maxArgumentCount } from '../../utils/function.js';
import { compileInlineExpression } from './utils/compileInlineExpression.js';
import { factory } from '../../utils/factory.js';
var name = 'filter';

@@ -64,15 +64,6 @@ var dependencies = ['typed'];

function _filter(x, callback) {
// figure out what number of arguments the callback function expects
var args = maxArgumentCount(callback);
return filter(x, function (value, index, array) {
// invoke the callback function with the right number of arguments
if (args === 1) {
return callback(value);
} else if (args === 2) {
return callback(value, [index + 1]);
} else {
// 3 or -1
return callback(value, [index + 1], array);
}
return applyCallback(callback, value, [index + 1], array, 'filter');
});
}

@@ -1,5 +0,5 @@

import { isFunctionAssignmentNode, isSymbolNode } from '../../utils/is.js';
import { maxArgumentCount } from '../../utils/function.js';
import { applyCallback } from '../../utils/applyCallback.js';
import { forEach } from '../../utils/array.js';
import { factory } from '../../utils/factory.js';
import { isFunctionAssignmentNode, isSymbolNode } from '../../utils/is.js';
import { compileInlineExpression } from './utils/compileInlineExpression.js';

@@ -39,4 +39,2 @@ var name = 'forEach';

'Array | Matrix, function': function ArrayMatrixFunction(array, callback) {
// figure out what number of arguments the callback function expects
var args = maxArgumentCount(callback);
var recurse = function recurse(value, index) {

@@ -50,10 +48,3 @@ if (Array.isArray(value)) {

// invoke the callback function with the right number of arguments
if (args === 1) {
callback(value);
} else if (args === 2) {
callback(value, index);
} else {
// 3 or -1
callback(value, index, array);
}
return applyCallback(callback, value, index, array, 'forEach');
}

@@ -60,0 +51,0 @@ };

@@ -1,5 +0,5 @@

import { isFunctionAssignmentNode, isSymbolNode } from '../../utils/is.js';
import { maxArgumentCount } from '../../utils/function.js';
import { applyCallback } from '../../utils/applyCallback.js';
import { map } from '../../utils/array.js';
import { factory } from '../../utils/factory.js';
import { isFunctionAssignmentNode, isSymbolNode } from '../../utils/is.js';
import { compileInlineExpression } from './utils/compileInlineExpression.js';

@@ -51,3 +51,3 @@ var name = 'map';

/**
* Map for a multi dimensional array. One-based indexes
* Map for a multidimensional array. One-based indexes
* @param {Array} array

@@ -60,4 +60,2 @@ * @param {function} callback

function _map(array, callback, orig) {
// figure out what number of arguments the callback function expects
var argsCount = maxArgumentCount(callback);
function recurse(value, index) {

@@ -71,10 +69,3 @@ if (Array.isArray(value)) {

// invoke the (typed) callback function with the right number of arguments
if (argsCount === 1) {
return callback(value);
} else if (argsCount === 2) {
return callback(value, index);
} else {
// 3 or -1
return callback(value, index, orig);
}
return applyCallback(callback, value, index, orig, 'map');
}

@@ -81,0 +72,0 @@ }

@@ -32,4 +32,4 @@ import { isConstantNode, typeOf } from '../../utils/is.js';

*
* derivative(expr, variable)
* derivative(expr, variable, options)
* math.derivative(expr, variable)
* math.derivative(expr, variable, options)
*

@@ -36,0 +36,0 @@ * Examples:

@@ -32,3 +32,3 @@ import { factory } from '../../utils/factory.js';

*
* leafCount(expr)
* math.leafCount(expr)
*

@@ -35,0 +35,0 @@ * Examples:

@@ -27,3 +27,3 @@ import { factory } from '../../utils/factory.js';

*
* polynomialRoot(constant, linearCoeff, quadraticCoeff, cubicCoeff)
* math.polynomialRoot(constant, linearCoeff, quadraticCoeff, cubicCoeff)
*

@@ -30,0 +30,0 @@ * Examples:

@@ -42,6 +42,6 @@ import { isInteger } from '../../utils/number.js';

*
* rationalize(expr)
* rationalize(expr, detailed)
* rationalize(expr, scope)
* rationalize(expr, scope, detailed)
* math.rationalize(expr)
* math.rationalize(expr, detailed)
* math.rationalize(expr, scope)
* math.rationalize(expr, scope, detailed)
*

@@ -48,0 +48,0 @@ * Examples:

@@ -20,3 +20,3 @@ import { createMap } from '../../utils/map.js';

*
* resolve(expr, scope)
* math.resolve(expr, scope)
*

@@ -23,0 +23,0 @@ * Examples:

@@ -141,9 +141,9 @@ import { isParenthesisNode } from '../../utils/is.js';

*
* simplify(expr)
* simplify(expr, rules)
* simplify(expr, rules)
* simplify(expr, rules, scope)
* simplify(expr, rules, scope, options)
* simplify(expr, scope)
* simplify(expr, scope, options)
* math.simplify(expr)
* math.simplify(expr, rules)
* math.simplify(expr, rules)
* math.simplify(expr, rules, scope)
* math.simplify(expr, rules, scope, options)
* math.simplify(expr, scope)
* math.simplify(expr, scope, options)
*

@@ -150,0 +150,0 @@ * Examples:

@@ -43,4 +43,4 @@ import { isFraction, isMatrix, isNode, isArrayNode, isConstantNode, isIndexNode, isObjectNode, isOperatorNode } from '../../utils/is.js';

*
* simplifyConstant(expr)
* simplifyConstant(expr, options)
* math.simplifyConstant(expr)
* math.simplifyConstant(expr, options)
*

@@ -47,0 +47,0 @@ * Examples:

@@ -70,4 +70,4 @@ import { isAccessorNode, isArrayNode, isConstantNode, isFunctionNode, isIndexNode, isObjectNode, isOperatorNode } from '../../utils/is.js';

*
* simplifyCore(expr)
* simplifyCore(expr, options)
* math.simplifyCore(expr)
* math.simplifyCore(expr, options)
*

@@ -74,0 +74,0 @@ * Examples:

@@ -28,16 +28,16 @@ import { isConstantNode } from '../../utils/is.js';

*
* symbolicEqual(expr1, expr2)
* symbolicEqual(expr1, expr2, options)
* math.symbolicEqual(expr1, expr2)
* math.symbolicEqual(expr1, expr2, options)
*
* Examples:
*
* symbolicEqual('x*y', 'y*x') // Returns true
* symbolicEqual('x*y', 'y*x', {context: {multiply: {commutative: false}}}) // Returns false
* symbolicEqual('x/y', '(y*x^(-1))^(-1)') // Returns true
* symbolicEqual('abs(x)','x') // Returns false
* symbolicEqual('abs(x)','x', simplify.positiveContext) // Returns true
* math.symbolicEqual('x*y', 'y*x') // Returns true
* math.symbolicEqual('x*y', 'y*x', {context: {multiply: {commutative: false}}}) // Returns false
* math.symbolicEqual('x/y', '(y*x^(-1))^(-1)') // Returns true
* math.symbolicEqual('abs(x)','x') // Returns false
* math.symbolicEqual('abs(x)','x', simplify.positiveContext) // Returns true
*
* See also:
*
* simplify, evaluate
* simplify, evaluate
*

@@ -44,0 +44,0 @@ * @param {Node|string} expr1 The first expression to compare

import { isBigNumber } from '../../utils/is.js';
import { factory } from '../../utils/factory.js';
var name = 'distance';
var dependencies = ['typed', 'addScalar', 'subtract', 'divideScalar', 'multiplyScalar', 'unaryMinus', 'sqrt', 'abs'];
var dependencies = ['typed', 'addScalar', 'subtract', 'divideScalar', 'multiplyScalar', 'deepEqual', 'sqrt', 'abs'];
export var createDistance = /* #__PURE__ */factory(name, dependencies, _ref => {

@@ -12,3 +12,3 @@ var {

divideScalar,
unaryMinus,
deepEqual,
sqrt,

@@ -35,6 +35,6 @@ abs

* math.distance([[x1,y1,z1], [x2,y2,z2], [x3,y3,z3]])
* math.distance([x1,y1], [x2,y2,z2])
* math.distance([x1,y1], [x2,y2], [x3,y3])
* math.distance([pointX,pointY], [a,b,c])
* math.distance([pointX,pointY], [lineOnePtX,lineOnePtY], [lineTwoPtX,lineTwoPtY])
* math.distance({pointX, pointY}, {lineOnePtX, lineOnePtY}, {lineTwoPtX, lineTwoPtY})
* math.distance([x1,y1,z1], [x0, y0, z0, a, b, c])
* math.distance([pointX,pointY,pointZ], [x0, y0, z0, a, b, c])
* math.distance({pointX, pointY, pointZ}, {x0, y0, z0, a, b, c})

@@ -55,7 +55,7 @@ *

* math.distance([10, 10], [8, 1, 3]) // Returns 11.535230316796387
* math.distance([10, 10], [2, 3], [-8, 0]) // Returns 8.759953130362847
* math.distance([0, 0], [3, 0], [0, 4]) // Returns 2.4
* math.distance(
* {pointX: 1, pointY: 4},
* {lineOnePtX: 6, lineOnePtY: 3},
* {lineTwoPtX: 2, lineTwoPtY: 8}) // Returns 2.720549372624744
* {pointX: 0, pointY: 0},
* {lineOnePtX: 3, lineOnePtY: 0},
* {lineTwoPtX: 0, lineTwoPtY: 4}) // Returns 2.4
* math.distance([2, 3, 1], [1, 1, 2, 5, 0, 1]) // Returns 2.3204774044612857

@@ -83,6 +83,8 @@ * math.distance(

}
var m = divideScalar(subtract(z[1], z[0]), subtract(y[1], y[0]));
var xCoeff = multiplyScalar(multiplyScalar(m, m), y[0]);
var yCoeff = unaryMinus(multiplyScalar(m, y[0]));
var constant = x[1];
if (deepEqual(y, z)) {
throw new TypeError('LinePoint1 should not be same with LinePoint2');
}
var xCoeff = subtract(z[1], y[1]);
var yCoeff = subtract(y[0], z[0]);
var constant = subtract(multiplyScalar(z[0], y[1]), multiplyScalar(y[0], z[1]));
return _distancePointLine2D(x[0], x[1], xCoeff, yCoeff, constant);

@@ -104,7 +106,9 @@ } else {

}
if (deepEqual(_objectToArray(y), _objectToArray(z))) {
throw new TypeError('LinePoint1 should not be same with LinePoint2');
}
if ('pointX' in x && 'pointY' in x && 'lineOnePtX' in y && 'lineOnePtY' in y && 'lineTwoPtX' in z && 'lineTwoPtY' in z) {
var m = divideScalar(subtract(z.lineTwoPtY, z.lineTwoPtX), subtract(y.lineOnePtY, y.lineOnePtX));
var xCoeff = multiplyScalar(multiplyScalar(m, m), y.lineOnePtX);
var yCoeff = unaryMinus(multiplyScalar(m, y.lineOnePtX));
var constant = x.pointX;
var xCoeff = subtract(z.lineTwoPtY, y.lineOnePtY);
var yCoeff = subtract(y.lineOnePtX, z.lineTwoPtX);
var constant = subtract(multiplyScalar(z.lineTwoPtX, y.lineOnePtY), multiplyScalar(y.lineOnePtX, z.lineTwoPtY));
return _distancePointLine2D(x.pointX, x.pointY, xCoeff, yCoeff, constant);

@@ -111,0 +115,0 @@ } else {

@@ -0,3 +1,3 @@

import { applyCallback } from '../../utils/applyCallback.js';
import { filter, filterRegExp } from '../../utils/array.js';
import { maxArgumentCount } from '../../utils/function.js';
import { factory } from '../../utils/factory.js';

@@ -59,15 +59,6 @@ var name = 'filter';

function _filterCallback(x, callback) {
// figure out what number of arguments the callback function expects
var args = maxArgumentCount(callback);
return filter(x, function (value, index, array) {
// invoke the callback function with the right number of arguments
if (args === 1) {
return callback(value);
} else if (args === 2) {
return callback(value, [index]);
} else {
// 3 or -1
return callback(value, [index], array);
}
return applyCallback(callback, value, [index], array, 'filter');
});
}

@@ -1,2 +0,2 @@

import { maxArgumentCount } from '../../utils/function.js';
import { applyCallback } from '../../utils/applyCallback.js';
import { forEach as forEachArray } from '../../utils/array.js';

@@ -42,3 +42,3 @@ import { factory } from '../../utils/factory.js';

/**
* forEach for a multi dimensional array
* forEach for a multidimensional array
* @param {Array} array

@@ -49,4 +49,2 @@ * @param {Function} callback

function _forEach(array, callback) {
// figure out what number of arguments the callback function expects
var args = maxArgumentCount(callback);
var recurse = function recurse(value, index) {

@@ -60,10 +58,3 @@ if (Array.isArray(value)) {

// invoke the callback function with the right number of arguments
if (args === 1) {
callback(value);
} else if (args === 2) {
callback(value, index);
} else {
// 3 or -1
callback(value, index, array);
}
return applyCallback(callback, value, index, array, 'forEach');
}

@@ -70,0 +61,0 @@ };

@@ -1,2 +0,2 @@

import { maxArgumentCount } from '../../utils/function.js';
import { applyCallback } from '../../utils/applyCallback.js';
import { factory } from '../../utils/factory.js';

@@ -30,10 +30,5 @@ var name = 'map';

*
* // The calling convention for the callback can cause subtleties:
* math.map([1, 2, 3], math.format)
* // throws TypeError: map attempted to call 'format(1,[0])' but argument 2 of type Array does not match expected type number or function or Object or string or boolean
* // [This happens because `format` _can_ take a second argument,
* // but its semantics don't match that of the 2nd argument `map` provides]
*
* // To avoid this error, use a function that takes exactly the
* // desired arguments:
* // The callback is normally called with three arguments:
* // callback(value, index, Array)
* // If you want to call with only one argument, use:
* math.map([1, 2, 3], x => math.format(x)) // returns ['1', '2', '3']

@@ -67,4 +62,2 @@ *

function _map(array, callback) {
// figure out what number of arguments the callback function expects
var args = maxArgumentCount(callback);
var recurse = function recurse(value, index) {

@@ -77,29 +70,4 @@ if (Array.isArray(value)) {

} else {
try {
// invoke the callback function with the right number of arguments
if (args === 1) {
return callback(value);
} else if (args === 2) {
return callback(value, index);
} else {
// 3 or -1
return callback(value, index, array);
}
} catch (err) {
// But maybe the arguments still weren't right
if (err instanceof TypeError && 'data' in err && err.data.category === 'wrongType') {
var newmsg = "map attempted to call '".concat(err.data.fn, "(").concat(value);
var indexString = JSON.stringify(index);
if (args === 2) {
newmsg += ',' + indexString;
} else if (args !== 1) {
newmsg += ",".concat(indexString, ",").concat(array);
}
newmsg += ")' but argument ".concat(err.data.index + 1, " of type ");
newmsg += "".concat(err.data.actual, " does not match expected type ");
newmsg += err.data.expected.join(' or ');
throw new TypeError(newmsg);
}
throw err;
}
// invoke the callback function with the right number of arguments
return applyCallback(callback, value, index, array, 'map');
}

@@ -106,0 +74,0 @@ };

@@ -58,3 +58,3 @@ import { isMatrix } from '../../utils/is.js';

*
* X = math.sqrtm(A)
* math.sqrtm(A)
*

@@ -61,0 +61,0 @@ * Examples:

@@ -66,2 +66,7 @@ import { factory } from '../../../utils/factory.js';

},
Unit: typed.referToSelf(self => x => {
var clone = x.clone();
clone.value = self(x.value);
return clone;
}),
Fraction: function Fraction(x) {

@@ -68,0 +73,0 @@ return new BigNumber(x.n).div(x.d).times(x.s);

@@ -42,3 +42,3 @@ import { factory } from '../../../utils/factory.js';

*
* @param {number | string | Fraction | BigNumber | Array | Matrix} [args]
* @param {number | string | Fraction | BigNumber | Unit | Array | Matrix} [args]
* Arguments specifying the value, or numerator and denominator of

@@ -71,2 +71,7 @@ * the fraction

Unit: typed.referToSelf(self => x => {
var clone = x.clone();
clone.value = self(x.value);
return clone;
}),
Object: function Object(x) {

@@ -73,0 +78,0 @@ return new Fraction(x);

@@ -124,5 +124,7 @@ import { factory } from '../utils/factory.js';

},
Unit: function Unit(x) {
throw new Error('Second argument with valueless unit expected');
},
Unit: typed.referToSelf(self => x => {
var clone = x.clone();
clone.value = self(x.value);
return clone;
}),
null: function _null(x) {

@@ -129,0 +131,0 @@ return 0;

@@ -13,3 +13,3 @@ import { factory } from '../../../utils/factory.js';

*
* splitUnit(unit: Unit, parts: Array.<Unit>)
* math.splitUnit(unit: Unit, parts: Array.<Unit>)
*

@@ -16,0 +16,0 @@ * Example:

@@ -149,3 +149,3 @@ import { isInteger } from '../number.js';

precision = options;
} else if (options.precision) {
} else if (options.precision !== undefined) {
precision = options.precision;

@@ -211,3 +211,3 @@ }

* Format a BigNumber in engineering notation. Like '1.23e+6', '2.3e+0', '3.500e-3'
* @param {BigNumber | string} value
* @param {BigNumber} value
* @param {number} [precision] Optional number of significant figures to return.

@@ -224,3 +224,4 @@ */

if (valueStr.indexOf('e') !== -1) {
valueStr = valueWithoutExp.toString();
var BigNumber = value.constructor;
valueStr = new BigNumber(valueStr).toFixed();
}

@@ -227,0 +228,0 @@ return valueStr + 'e' + (e >= 0 ? '+' : '') + newExp.toString();

@@ -1,3 +0,3 @@

export var version = '11.8.0';
export var version = '11.8.1';
// Note: This file is automatically generated when building math.js.
// Changes made in this file will be overwritten.
{
"name": "mathjs",
"version": "11.8.0",
"version": "11.8.1",
"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.",

@@ -28,3 +28,3 @@ "author": "Jos de Jong <wjosdejong@gmail.com> (https://github.com/josdejong)",

"dependencies": {
"@babel/runtime": "^7.21.0",
"@babel/runtime": "^7.22.5",
"complex.js": "^2.1.1",

@@ -40,28 +40,28 @@ "decimal.js": "^10.4.3",

"devDependencies": {
"@babel/core": "7.21.4",
"@babel/plugin-transform-object-assign": "7.18.6",
"@babel/plugin-transform-runtime": "7.21.4",
"@babel/preset-env": "7.21.4",
"@babel/register": "7.21.0",
"@babel/core": "7.22.5",
"@babel/plugin-transform-object-assign": "7.22.5",
"@babel/plugin-transform-runtime": "7.22.5",
"@babel/preset-env": "7.22.5",
"@babel/register": "7.22.5",
"@types/assert": "1.5.6",
"@types/mocha": "10.0.1",
"@typescript-eslint/eslint-plugin": "5.57.0",
"@typescript-eslint/parser": "5.57.0",
"@typescript-eslint/eslint-plugin": "5.59.11",
"@typescript-eslint/parser": "5.59.11",
"assert": "2.0.0",
"babel-loader": "9.1.2",
"benchmark": "2.1.4",
"c8": "7.13.0",
"c8": "7.14.0",
"codecov": "3.8.3",
"core-js": "3.29.1",
"core-js": "3.31.0",
"del": "6.1.1",
"dtslint": "4.2.1",
"eslint": "8.37.0",
"eslint": "8.42.0",
"eslint-config-prettier": "8.8.0",
"eslint-config-standard": "17.0.0",
"eslint-config-standard": "17.1.0",
"eslint-plugin-import": "2.27.5",
"eslint-plugin-mocha": "10.1.0",
"eslint-plugin-n": "15.7.0",
"eslint-plugin-n": "16.0.0",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-promise": "6.1.1",
"expect-type": "0.15.0",
"expect-type": "0.16.0",
"expr-eval": "2.0.2",

@@ -74,3 +74,3 @@ "fancy-log": "2.0.0",

"jsep": "1.3.8",
"karma": "6.4.1",
"karma": "6.4.2",
"karma-browserstack-launcher": "1.6.0",

@@ -91,8 +91,8 @@ "karma-firefox-launcher": "2.1.2",

"pad-right": "0.2.2",
"prettier": "2.8.7",
"prettier": "2.8.8",
"process": "0.11.10",
"sylvester": "0.0.21",
"ts-node": "10.9.1",
"typescript": "5.0.3",
"webpack": "5.77.0",
"typescript": "5.1.3",
"webpack": "5.86.0",
"zeros": "1.0.0"

@@ -99,0 +99,0 @@ },

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc