Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mathjslab

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mathjslab - npm Package Compare versions

Comparing version 1.0.12 to 1.0.13

10

package.json
{
"name": "mathjslab",
"version": "1.0.12",
"description": "MathJSLab - Interpreter with language syntax like MATLAB/Octave",
"version": "1.0.13",
"description": "MathJSLab - An interpreter with language syntax like MATLAB/Octave",
"main": "dist/mathjslab.js",

@@ -57,7 +57,7 @@ "types": "dist/src/index.d.ts",

"@types/jest": "29.5.4",
"@types/node": "^20.5.9",
"@types/node": "^20.6.0",
"@types/supertest": "^2.0.12",
"@types/webpack": "^5.28.2",
"@typescript-eslint/eslint-plugin": "^6.5.0",
"eslint": "^8.48.0",
"@typescript-eslint/eslint-plugin": "^6.6.0",
"eslint": "^8.49.0",
"eslint-config-prettier": "^9.0.0",

@@ -64,0 +64,0 @@ "eslint-plugin-import": "^2.28.1",

# MathJSLab
> Interpreter with language syntax like MATLAB®/Octave
> An interpreter with language syntax like MATLAB®/Octave written in TypeScript.

@@ -5,0 +5,0 @@ This package emulates a parser and evaluator for a subset of

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

import { ComplexDecimal } from './complex-decimal';
import { Evaluator } from './evaluator';

@@ -8,9 +7,5 @@

beforeEach(async () => {
evaluator = new Evaluator();
evaluator = Evaluator.initialize();
});
it('ComplexDecimal should be defined', () => {
expect(ComplexDecimal).toBeDefined();
});
it('Evaluator should be defined', () => {

@@ -17,0 +12,0 @@ expect(Evaluator).toBeDefined();

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

export class Evaluator {
/**

@@ -348,4 +347,3 @@ * After run Parser or Evaluate method, the exitStatus property will contains

}
}
else {
} else {
evaluator.aliasName = (name: string): string => name;

@@ -440,3 +438,3 @@ }

public nodeRange(left: any, ...right: any): NodeRange {
//https://www.mathworks.com/help/matlab/ref/end.html
/* https://www.mathworks.com/help/matlab/ref/end.html */
if (right.length == 1) {

@@ -866,4 +864,3 @@ return { start: left, stop: right[0], stride: null };

}
}
else {
} else {
/* arguments selectively evaluated */

@@ -1320,3 +1317,2 @@ for (let i = 0; i < tree.args.length; i++) {

}
}

@@ -9,3 +9,3 @@ import { ComplexDecimal } from './complex-decimal';

beforeEach(async () => {
evaluator = new Evaluator();
evaluator = Evaluator.initialize();
});

@@ -25,19 +25,15 @@

it('Determinant should be 0', () => {
const tree = evaluator.Parse('det([1:3;4:6;7:9])');
const value = evaluator.Evaluate(tree);
it('The determinant must be correctly calculated', () => {
let tree: any;
let value: any;
tree = evaluator.Parse('det([1:3;4:6;7:9])');
value = evaluator.Evaluate(tree);
expect(value.list[0].re.toNumber()).toBe(0);
}, 1000);
it('Determinant should be -67', () => {
const tree = evaluator.Parse('det([2,1,-3; 3,2,4; 2,5,-2])');
const value = evaluator.Evaluate(tree);
tree = evaluator.Parse('det([2,1,-3; 3,2,4; 2,5,-2])');
value = evaluator.Evaluate(tree);
expect(value.list[0].re.toNumber()).toBe(-67);
}, 1000);
it('Determinant should be -444', () => {
const tree = evaluator.Parse('det([-7,6,3,1; -9,1,6,4; -8,-4,3,6; -5,5,9,2])');
const value = evaluator.Evaluate(tree);
tree = evaluator.Parse('det([-7,6,3,1; -9,1,6,4; -8,-4,3,6; -5,5,9,2])');
value = evaluator.Evaluate(tree);
expect(value.list[0].re.toNumber()).toBe(-444);
}, 1000);
});

@@ -24,3 +24,2 @@ import { ComplexDecimal } from './complex-decimal';

export class MultiArray {
/**

@@ -58,6 +57,6 @@ * Functions

*/
public static linearizedFunctions: { [name: string]: { func: Function, lin: boolean[] } } = {
public static linearizedFunctions: { [name: string]: { func: Function; lin: boolean[] } } = {
size: {
func: MultiArray.size,
lin: [false, true]
lin: [false, true],
},

@@ -630,7 +629,9 @@ };

const dim = dimension.re.toNumber();
if ((dim < 1) || !dimension.re.trunc().eq(dimension.re)) {
throw new Error(`size: requested dimension DIM (= ${Math.trunc(dimension.re.toNumber())}) out of range. DIM must be a positive integer`);
if (dim < 1 || !dimension.re.trunc().eq(dimension.re)) {
throw new Error(
`size: requested dimension DIM (= ${Math.trunc(dimension.re.toNumber())}) out of range. DIM must be a positive integer`,
);
}
return dim;
}
};
if (DIM.length === 0) {

@@ -641,4 +642,3 @@ if ('re' in M) {

return result;
}
else {
} else {
const result = new MultiArray([1, 2]);

@@ -648,9 +648,7 @@ result.array = [[new ComplexDecimal(M.dim[0]), new ComplexDecimal(M.dim[1])]];

}
}
else {
} else {
if (DIM.length === 1) {
if ('re' in M) {
return ComplexDecimal.one()
}
else {
return ComplexDecimal.one();
} else {
if ('re' in DIM[0]) {

@@ -660,8 +658,6 @@ const dim = testDimension(DIM[0]);

return ComplexDecimal.one();
}
else {
} else {
return new ComplexDecimal(M.dim[dim - 1]);
}
}
else {
} else {
const result = new MultiArray([1, DIM[0].length]);

@@ -673,4 +669,3 @@ result.array = [[]];

result.array[0].push(ComplexDecimal.one());
}
else {
} else {
result.array[0].push(new ComplexDecimal(M.dim[dim - 1]));

@@ -682,4 +677,3 @@ }

}
}
else {
} else {
if ('re' in M) {

@@ -691,6 +685,5 @@ const result = new MultiArray([1, DIM.length]);

result.array[0].push(ComplexDecimal.one());
})
});
return result;
}
else {
} else {
const result = new MultiArray([1, DIM.length]);

@@ -702,4 +695,3 @@ result.array = [[]];

result.array[0].push(ComplexDecimal.one());
}
else {
} else {
result.array[0].push(new ComplexDecimal(M.dim[dim - 1]));

@@ -706,0 +698,0 @@ }

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