Socket
Socket
Sign inDemoInstall

mathjs

Package Overview
Dependencies
Maintainers
1
Versions
279
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mathjs - npm Package Compare versions

Comparing version 12.4.2 to 12.4.3

2

bin/cli.js

@@ -116,3 +116,3 @@ #!/usr/bin/env node

if (hasOwnProperty(math.expression.mathWithTransform, func)) {
if (func.indexOf(keyword) === 0 && ignore.indexOf(func) === -1) {
if (func.indexOf(keyword) === 0 && !ignore.includes(func)) {
matches.push(func)

@@ -119,0 +119,0 @@ }

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

*
* @version 12.4.2
* @date 2024-04-24
* @version 12.4.3
* @date 2024-05-31
*

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

@@ -95,12 +95,2 @@ "use strict";

/**
* Test whether an Array contains a specific item.
* @param {Array.<string>} array
* @param {string} item
* @return {boolean}
*/
function contains(array, item) {
return array.indexOf(item) !== -1;
}
/**
* Validate an option

@@ -112,3 +102,3 @@ * @param {Object} options Object with options

function validateOption(options, name, values) {
if (options[name] !== undefined && !contains(values, options[name])) {
if (options[name] !== undefined && !values.includes(options[name])) {
// unknown value

@@ -115,0 +105,0 @@ console.warn('Warning: Unknown value "' + options[name] + '" for configuration option "' + name + '". ' + 'Available options: ' + values.map(function (value) {

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

var _object = require("../../utils/object.js");
var _array = require("../../utils/array.js");
var _ArgumentsError = require("../../error/ArgumentsError.js");

@@ -229,3 +228,3 @@ function importFactory(typed, load, math, importedFactories) {

var name = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : factory.fn;
if ((0, _array.contains)(name, '.')) {
if (name.includes('.')) {
throw new Error('Factory name should not contain a nested path. ' + 'Name: ' + JSON.stringify(name));

@@ -240,3 +239,3 @@ }

factory.dependencies.map(_factory.stripOptionalNotation).forEach(function (dependency) {
if ((0, _array.contains)(dependency, '.')) {
if (dependency.includes('.')) {
throw new Error('Factory dependency should not contain a nested path. ' + 'Name: ' + JSON.stringify(dependency));

@@ -324,3 +323,3 @@ }

function factoryAllowedInExpressions(factory) {
return factory.fn.indexOf('.') === -1 &&
return !factory.fn.includes('.') &&
// FIXME: make checking on path redundant, check on meta data instead

@@ -327,0 +326,0 @@ !(0, _object.hasOwnProperty)(unsafe, factory.fn) && (!factory.meta || !factory.meta.isClass);

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

/**
* multiply, divide, modulus
* multiply, divide
* @return {Node} node

@@ -1027,3 +1027,3 @@ * @private

function parseRule2(state) {
var node = parsePercentage(state);
var node = parseModulusPercentage(state);
var last = node;

@@ -1050,3 +1050,3 @@ var tokenStates = [];

tokenStates.pop();
last = parsePercentage(state);
last = parseModulusPercentage(state);
node = new OperatorNode('/', 'divide', [node, last]);

@@ -1072,7 +1072,7 @@ } else {

/**
* percentage or mod
* modulus and percentage
* @return {Node} node
* @private
*/
function parsePercentage(state) {
function parseModulusPercentage(state) {
var node, name, fn, params;

@@ -1240,3 +1240,3 @@ node = parseUnary(state);

node = new ConstantNode(CONSTANTS[name]);
} else if (NUMERIC_CONSTANTS.indexOf(name) !== -1) {
} else if (NUMERIC_CONSTANTS.includes(name)) {
// NaN, Infinity

@@ -1271,3 +1271,3 @@ node = new ConstantNode(numeric(name, 'number'));

var params;
while ((state.token === '(' || state.token === '[' || state.token === '.') && (!types || types.indexOf(state.token) !== -1)) {
while ((state.token === '(' || state.token === '[' || state.token === '.') && (!types || types.includes(state.token))) {
// eslint-disable-line no-unmodified-loop-condition

@@ -1274,0 +1274,0 @@ params = [];

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

'Object, FunctionAssignmentNode, string': function ObjectFunctionAssignmentNodeString(constNodes, node, varName) {
if (node.params.indexOf(varName) === -1) {
if (!node.params.includes(varName)) {
constNodes[node] = true;

@@ -169,0 +169,0 @@ return true;

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

} else {
if (oper.indexOf(node.op) === -1) {
if (!oper.includes(node.op)) {
throw new Error('Operator ' + node.op + ' invalid in polynomial expression');

@@ -737,3 +737,3 @@ }

// ***** OperatorName *****
if ('+-*^'.indexOf(node.op) === -1) throw new Error('Operator ' + node.op + ' invalid');
if (!'+-*^'.includes(node.op)) throw new Error('Operator ' + node.op + ' invalid');
if (noPai !== null) {

@@ -740,0 +740,0 @@ // -(unary),^ : children of *,+,-

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

var operatorFunctions = ['add', 'multiply'];
if (operatorFunctions.indexOf(node.name) === -1) {
if (!operatorFunctions.includes(node.name)) {
var args = node.args.map(function (arg) {

@@ -366,0 +366,0 @@ return foldFraction(arg, options);

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

} catch (err) {
if (err instanceof TypeError && err.message.indexOf('median') !== -1) {
if (err instanceof TypeError && err.message.includes('median')) {
throw new TypeError(err.message.replace('median', 'mad'));

@@ -64,0 +64,0 @@ } else {

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

} catch (err) {
if (err instanceof TypeError && err.message.indexOf(' variance') !== -1) {
if (err instanceof TypeError && err.message.includes(' variance')) {
throw new TypeError(err.message.replace(' variance', ' std'));

@@ -97,0 +97,0 @@ } else {

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

var details;
if (String(err).indexOf('Unexpected type') !== -1) {
if (String(err).includes('Unexpected type')) {
details = arguments.length > 2 ? ' (type: ' + (0, _is.typeOf)(value) + ', value: ' + JSON.stringify(value) + ')' : ' (type: ' + err.data.actual + ')';
return new TypeError('Cannot calculate ' + fnName + ', unexpected type of argument' + details);
}
if (String(err).indexOf('complex numbers') !== -1) {
if (String(err).includes('complex numbers')) {
details = arguments.length > 2 ? ' (type: ' + (0, _is.typeOf)(value) + ', value: ' + JSON.stringify(value) + ')' : '';

@@ -28,0 +28,0 @@ return new TypeError('Cannot calculate ' + fnName + ', no ordering relation is defined for complex numbers' + details);

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

*
* @version 12.4.2
* @date 2024-04-24
* @version 12.4.3
* @date 2024-05-31
*

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

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

exports.concat = concat;
exports.contains = contains;
exports.filter = filter;

@@ -662,12 +661,2 @@ exports.filterRegExp = filterRegExp;

/**
* Test whether an array or string contains an item
* @param {Array | string} array
* @param {*} item
* @return {boolean}
*/
function contains(array, item) {
return array.indexOf(item) !== -1;
}
/**
* Recursively concatenate two matrices.

@@ -674,0 +663,0 @@ * The contents of the matrices is not cloned.

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

var valueStr = valueWithoutExp.toPrecision(precision);
if (valueStr.indexOf('e') !== -1) {
if (valueStr.includes('e')) {
var BigNumber = value.constructor;

@@ -213,0 +213,0 @@ valueStr = new BigNumber(valueStr).toFixed();

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

exports.stripOptionalNotation = stripOptionalNotation;
var _array = require("./array.js");
var _object = require("./object.js");

@@ -72,3 +71,3 @@ /**

if (isFactory(factory)) {
if ((0, _array.contains)(factory.dependencies, dependency.fn || dependency.name)) {
if (factory.dependencies.includes(dependency.fn || dependency.name)) {
return true;

@@ -75,0 +74,0 @@ }

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

function isPath(str) {
return str.indexOf('.') !== -1;
return str.includes('.');
}

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

}
if (args.join(' ').indexOf('is moved to') !== -1 && args.join(' ').indexOf('Please use the new location instead') !== -1) {
if (args.join(' ').includes('is moved to') && args.join(' ').includes('Please use the new location instead')) {
// Ignore warnings like:

@@ -66,7 +66,7 @@ // Warning: math.type.isNumber is moved to math.isNumber in v6.0.0. Please use the new location instead.

// FIXME: ugly to have these special cases
if (path.join('.').indexOf('docs.') !== -1) {
if (path.join('.').includes('docs.')) {
// ignore the contents of docs
return;
}
if (path.join('.').indexOf('all.') !== -1) {
if (path.join('.').includes('all.')) {
// ignore the contents of all dependencies

@@ -196,3 +196,3 @@ return;

// FIXME: ugly to have these special cases
if (path.length > 0 && path[0].indexOf('Dependencies') !== -1) {
if (path.length > 0 && path[0].includes('Dependencies')) {
// special case for objects holding a collection of dependencies

@@ -199,0 +199,0 @@ callback(obj, path);

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

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

@@ -86,12 +86,2 @@ import { clone, mapObject, deepExtend } from '../../utils/object.js';

/**
* Test whether an Array contains a specific item.
* @param {Array.<string>} array
* @param {string} item
* @return {boolean}
*/
function contains(array, item) {
return array.indexOf(item) !== -1;
}
/**
* Validate an option

@@ -103,3 +93,3 @@ * @param {Object} options Object with options

function validateOption(options, name, values) {
if (options[name] !== undefined && !contains(values, options[name])) {
if (options[name] !== undefined && !values.includes(options[name])) {
// unknown value

@@ -106,0 +96,0 @@ console.warn('Warning: Unknown value "' + options[name] + '" for configuration option "' + name + '". ' + 'Available options: ' + values.map(value => JSON.stringify(value)).join(', ') + '.');

import { isBigNumber, isComplex, isFraction, isMatrix, isUnit } from '../../utils/is.js';
import { isFactory, stripOptionalNotation } from '../../utils/factory.js';
import { hasOwnProperty, lazy } from '../../utils/object.js';
import { contains } from '../../utils/array.js';
import { ArgumentsError } from '../../error/ArgumentsError.js';

@@ -219,3 +218,3 @@ export function importFactory(typed, load, math, importedFactories) {

var name = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : factory.fn;
if (contains(name, '.')) {
if (name.includes('.')) {
throw new Error('Factory name should not contain a nested path. ' + 'Name: ' + JSON.stringify(name));

@@ -230,3 +229,3 @@ }

factory.dependencies.map(stripOptionalNotation).forEach(dependency => {
if (contains(dependency, '.')) {
if (dependency.includes('.')) {
throw new Error('Factory dependency should not contain a nested path. ' + 'Name: ' + JSON.stringify(dependency));

@@ -310,3 +309,3 @@ }

function factoryAllowedInExpressions(factory) {
return factory.fn.indexOf('.') === -1 &&
return !factory.fn.includes('.') &&
// FIXME: make checking on path redundant, check on meta data instead

@@ -313,0 +312,0 @@ !hasOwnProperty(unsafe, factory.fn) && (!factory.meta || !factory.meta.isClass);

@@ -955,3 +955,3 @@ import _extends from "@babel/runtime/helpers/extends";

/**
* multiply, divide, modulus
* multiply, divide
* @return {Node} node

@@ -1020,3 +1020,3 @@ * @private

function parseRule2(state) {
var node = parsePercentage(state);
var node = parseModulusPercentage(state);
var last = node;

@@ -1043,3 +1043,3 @@ var tokenStates = [];

tokenStates.pop();
last = parsePercentage(state);
last = parseModulusPercentage(state);
node = new OperatorNode('/', 'divide', [node, last]);

@@ -1065,7 +1065,7 @@ } else {

/**
* percentage or mod
* modulus and percentage
* @return {Node} node
* @private
*/
function parsePercentage(state) {
function parseModulusPercentage(state) {
var node, name, fn, params;

@@ -1233,3 +1233,3 @@ node = parseUnary(state);

node = new ConstantNode(CONSTANTS[name]);
} else if (NUMERIC_CONSTANTS.indexOf(name) !== -1) {
} else if (NUMERIC_CONSTANTS.includes(name)) {
// NaN, Infinity

@@ -1264,3 +1264,3 @@ node = new ConstantNode(numeric(name, 'number'));

var params;
while ((state.token === '(' || state.token === '[' || state.token === '.') && (!types || types.indexOf(state.token) !== -1)) {
while ((state.token === '(' || state.token === '[' || state.token === '.') && (!types || types.includes(state.token))) {
// eslint-disable-line no-unmodified-loop-condition

@@ -1267,0 +1267,0 @@ params = [];

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

'Object, FunctionAssignmentNode, string': function ObjectFunctionAssignmentNodeString(constNodes, node, varName) {
if (node.params.indexOf(varName) === -1) {
if (!node.params.includes(varName)) {
constNodes[node] = true;

@@ -165,0 +165,0 @@ return true;

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

} else {
if (oper.indexOf(node.op) === -1) {
if (!oper.includes(node.op)) {
throw new Error('Operator ' + node.op + ' invalid in polynomial expression');

@@ -731,3 +731,3 @@ }

// ***** OperatorName *****
if ('+-*^'.indexOf(node.op) === -1) throw new Error('Operator ' + node.op + ' invalid');
if (!'+-*^'.includes(node.op)) throw new Error('Operator ' + node.op + ' invalid');
if (noPai !== null) {

@@ -734,0 +734,0 @@ // -(unary),^ : children of *,+,-

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

var operatorFunctions = ['add', 'multiply'];
if (operatorFunctions.indexOf(node.name) === -1) {
if (!operatorFunctions.includes(node.name)) {
var args = node.args.map(arg => foldFraction(arg, options));

@@ -345,0 +345,0 @@

@@ -57,3 +57,3 @@ import { flatten } from '../../utils/array.js';

} catch (err) {
if (err instanceof TypeError && err.message.indexOf('median') !== -1) {
if (err instanceof TypeError && err.message.includes('median')) {
throw new TypeError(err.message.replace('median', 'mad'));

@@ -60,0 +60,0 @@ } else {

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

} catch (err) {
if (err instanceof TypeError && err.message.indexOf(' variance') !== -1) {
if (err instanceof TypeError && err.message.includes(' variance')) {
throw new TypeError(err.message.replace(' variance', ' std'));

@@ -93,0 +93,0 @@ } else {

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

var details;
if (String(err).indexOf('Unexpected type') !== -1) {
if (String(err).includes('Unexpected type')) {
details = arguments.length > 2 ? ' (type: ' + typeOf(value) + ', value: ' + JSON.stringify(value) + ')' : ' (type: ' + err.data.actual + ')';
return new TypeError('Cannot calculate ' + fnName + ', unexpected type of argument' + details);
}
if (String(err).indexOf('complex numbers') !== -1) {
if (String(err).includes('complex numbers')) {
details = arguments.length > 2 ? ' (type: ' + typeOf(value) + ', value: ' + JSON.stringify(value) + ')' : '';

@@ -23,0 +23,0 @@ return new TypeError('Cannot calculate ' + fnName + ', no ordering relation is defined for complex numbers' + details);

@@ -622,12 +622,2 @@ import _extends from "@babel/runtime/helpers/extends";

/**
* Test whether an array or string contains an item
* @param {Array | string} array
* @param {*} item
* @return {boolean}
*/
export function contains(array, item) {
return array.indexOf(item) !== -1;
}
/**
* Recursively concatenate two matrices.

@@ -634,0 +624,0 @@ * The contents of the matrices is not cloned.

@@ -203,3 +203,3 @@ import { isBigNumber, isNumber } from '../is.js';

var valueStr = valueWithoutExp.toPrecision(precision);
if (valueStr.indexOf('e') !== -1) {
if (valueStr.includes('e')) {
var BigNumber = value.constructor;

@@ -206,0 +206,0 @@ valueStr = new BigNumber(valueStr).toFixed();

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

import { contains } from './array.js';
import { pickShallow } from './object.js';

@@ -60,3 +59,3 @@

if (isFactory(factory)) {
if (contains(factory.dependencies, dependency.fn || dependency.name)) {
if (factory.dependencies.includes(dependency.fn || dependency.name)) {
return true;

@@ -63,0 +62,0 @@ }

@@ -371,3 +371,3 @@ import { isBigNumber, isObject } from './is.js';

function isPath(str) {
return str.indexOf('.') !== -1;
return str.includes('.');
}

@@ -23,3 +23,3 @@ import _extends from "@babel/runtime/helpers/extends";

}
if (args.join(' ').indexOf('is moved to') !== -1 && args.join(' ').indexOf('Please use the new location instead') !== -1) {
if (args.join(' ').includes('is moved to') && args.join(' ').includes('Please use the new location instead')) {
// Ignore warnings like:

@@ -55,7 +55,7 @@ // Warning: math.type.isNumber is moved to math.isNumber in v6.0.0. Please use the new location instead.

// FIXME: ugly to have these special cases
if (path.join('.').indexOf('docs.') !== -1) {
if (path.join('.').includes('docs.')) {
// ignore the contents of docs
return;
}
if (path.join('.').indexOf('all.') !== -1) {
if (path.join('.').includes('all.')) {
// ignore the contents of all dependencies

@@ -186,3 +186,3 @@ return;

// FIXME: ugly to have these special cases
if (path.length > 0 && path[0].indexOf('Dependencies') !== -1) {
if (path.length > 0 && path[0].includes('Dependencies')) {
// special case for objects holding a collection of dependencies

@@ -189,0 +189,0 @@ callback(obj, path);

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

export var version = '12.4.2';
export var version = '12.4.3';
// Note: This file is automatically generated when building math.js.
// Changes made in this file will be overwritten.
{
"name": "mathjs",
"version": "12.4.2",
"version": "12.4.3",
"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,0 +5,0 @@ "author": "Jos de Jong <wjosdejong@gmail.com> (https://github.com/josdejong)",

@@ -163,2 +163,6 @@ ![math.js](https://raw.github.com/josdejong/mathjs/master/misc/img/mathjs.png)

To test the type definitions:
npm run test:types
Additionally, the tests can be run on FireFox using [headless mode](https://developer.mozilla.org/en-US/Firefox/Headless_mode):

@@ -165,0 +169,0 @@

# Mathjs TypeScript types
The code base of Mathjs is writting in JavaScript. The TypeScript definitions are maintained separately.
The code base of Mathjs is written in JavaScript. The TypeScript definitions are maintained separately.

@@ -55,1 +55,13 @@ ## Library structure

```
## Testing the type definitions
The types are defined in `types/index.d.ts`.
The tests for the type definitions are located in `test/typescript-types/testTypes.ts`.
To run the tests for the type definitions:
```
npm run test:types
```

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

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

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc