Comparing version 1.1.5 to 1.1.6
@@ -18,3 +18,3 @@ module.exports = { | ||
}, | ||
ignorePatterns: ['.eslintrc.js', 'build/**'], | ||
ignorePatterns: ['.eslintrc.js', 'lib/**'], | ||
rules: { | ||
@@ -21,0 +21,0 @@ '@typescript-eslint/interface-name-prefix': 'off', |
{ | ||
"name": "mathjslab", | ||
"version": "1.1.5", | ||
"version": "1.1.6", | ||
"description": "MathJSLab - An interpreter with language syntax like MATLAB/Octave. ISBN 978-65-00-82338-7", | ||
@@ -5,0 +5,0 @@ "main": "lib/mathjslab.js", |
@@ -49,3 +49,3 @@ # MathJSLab | ||
MathJSLab works on any [ES6](http://es6-features.org/) compatible | ||
MathJSLab works on any [ES5](https://www.ecma-international.org/wp-content/uploads/ECMA-262_5th_edition_december_2009.pdf) compatible | ||
[JavaScript](https://www.ecma-international.org/publications-and-standards/standards/ecma-262/) | ||
@@ -52,0 +52,0 @@ engine, including [Node.js](https://nodejs.org/), |
@@ -8,3 +8,3 @@ export class CharString { | ||
get string(): string { | ||
return this.str.substring(1,this.str.length-1) | ||
return this.str.substring(1, this.str.length - 1); | ||
} | ||
@@ -11,0 +11,0 @@ static isThis(obj: any): boolean { |
@@ -150,4 +150,3 @@ import { Decimal } from 'decimal.js'; | ||
} | ||
} | ||
else { | ||
} else { | ||
value.type = ComplexDecimal.numberClass.complex; | ||
@@ -171,4 +170,3 @@ } | ||
} | ||
} | ||
else { | ||
} else { | ||
this.type = ComplexDecimal.numberClass.complex; | ||
@@ -451,3 +449,3 @@ } | ||
public static maxNumberType(...args: ComplexDecimal[]): number { | ||
return Math.max(...args.map(arg => arg.type)); | ||
return Math.max(...args.map((arg) => arg.type)); | ||
} | ||
@@ -646,6 +644,4 @@ | ||
const right_prec = ComplexDecimal.toMaxPrecision(right); | ||
return ( | ||
left_prec.re.eq(0) && left_prec.im.eq(0) && !(right_prec.re.eq(0) && right_prec.im.eq(0)) || | ||
!(left_prec.re.eq(0) && left_prec.im.eq(0)) && right_prec.re.eq(0) && right_prec.im.eq(0) | ||
) | ||
return (left_prec.re.eq(0) && left_prec.im.eq(0) && !(right_prec.re.eq(0) && right_prec.im.eq(0))) || | ||
(!(left_prec.re.eq(0) && left_prec.im.eq(0)) && right_prec.re.eq(0) && right_prec.im.eq(0)) | ||
? ComplexDecimal.true() | ||
@@ -652,0 +648,0 @@ : ComplexDecimal.false(); |
@@ -74,3 +74,3 @@ /** | ||
*/ | ||
interface NodeReserved extends PrimaryNode { } | ||
interface NodeReserved extends PrimaryNode {} | ||
@@ -205,3 +205,3 @@ /** | ||
*/ | ||
public nameTable: { [k: string]: { args: Array<any>, expr: any } } = {}; | ||
public nameTable: { [k: string]: { args: Array<any>; expr: any } } = {}; | ||
@@ -244,3 +244,3 @@ public readonlyNameTable: string[] = []; | ||
private incDecOp(pre: boolean, operation: 'plus' | 'minus'): ((tree: any) => any) { | ||
private incDecOp(pre: boolean, operation: 'plus' | 'minus'): (tree: any) => any { | ||
if (pre) { | ||
@@ -252,13 +252,10 @@ return (tree: any): any => { | ||
return this.nameTable[tree.id].expr; | ||
} else { | ||
throw new Error('in x++ or ++x, x must be defined first.'); | ||
} | ||
else { | ||
throw new Error('in x++ or ++x, x must be defined first.') | ||
} | ||
} | ||
else { | ||
} else { | ||
throw new SyntaxError(`invalid ${operation === 'plus' ? 'increment' : 'decrement'} variable.`); | ||
} | ||
} | ||
} | ||
else { | ||
}; | ||
} else { | ||
return (tree: any): any => { | ||
@@ -270,11 +267,9 @@ if (tree.type === 'NAME') { | ||
return value; | ||
} else { | ||
throw new Error('in x++ or ++x, x must be defined first.'); | ||
} | ||
else { | ||
throw new Error('in x++ or ++x, x must be defined first.') | ||
} | ||
} | ||
else { | ||
} else { | ||
throw new SyntaxError(`invalid ${operation === 'plus' ? 'increment' : 'decrement'} variable.`); | ||
} | ||
} | ||
}; | ||
} | ||
@@ -664,4 +659,3 @@ } | ||
return tree; | ||
} | ||
else { | ||
} else { | ||
throw new Error(`${invalidMessage}.`); | ||
@@ -668,0 +662,0 @@ } |
@@ -242,3 +242,3 @@ import { ComplexDecimal } from './complex-decimal'; | ||
result.dim = [result.array.length, result.array.length ? result.array[0].length : 0]; | ||
result.type = Math.max(...result.array.map(row => ComplexDecimal.maxNumberType(...row))); | ||
result.type = Math.max(...result.array.map((row) => ComplexDecimal.maxNumberType(...row))); | ||
return result; | ||
@@ -348,3 +348,3 @@ } | ||
} | ||
result.type = Math.max(...result.array.map(row => ComplexDecimal.maxNumberType(...row))); | ||
result.type = Math.max(...result.array.map((row) => ComplexDecimal.maxNumberType(...row))); | ||
return result; | ||
@@ -361,3 +361,3 @@ } | ||
result.array = [temp]; | ||
result.type = Math.max(...result.array.map(row => ComplexDecimal.maxNumberType(...row))); | ||
result.type = Math.max(...result.array.map((row) => ComplexDecimal.maxNumberType(...row))); | ||
return result; | ||
@@ -409,3 +409,3 @@ } | ||
} | ||
result.type = Math.max(...result.array.map(row => ComplexDecimal.maxNumberType(...row))); | ||
result.type = Math.max(...result.array.map((row) => ComplexDecimal.maxNumberType(...row))); | ||
return result; | ||
@@ -449,3 +449,3 @@ } else { | ||
} | ||
result.type = Math.max(...result.array.map(row => ComplexDecimal.maxNumberType(...row))); | ||
result.type = Math.max(...result.array.map((row) => ComplexDecimal.maxNumberType(...row))); | ||
if (result.dim[0] == 1 && result.dim[1] == 1) { | ||
@@ -480,3 +480,3 @@ return result.array[0][0]; | ||
} | ||
result.type = Math.max(...result.array.map(row => ComplexDecimal.maxNumberType(...row))); | ||
result.type = Math.max(...result.array.map((row) => ComplexDecimal.maxNumberType(...row))); | ||
return result; | ||
@@ -505,3 +505,3 @@ } | ||
} | ||
result.type = Math.max(...result.array.map(row => ComplexDecimal.maxNumberType(...row))); | ||
result.type = Math.max(...result.array.map((row) => ComplexDecimal.maxNumberType(...row))); | ||
return result; | ||
@@ -529,3 +529,3 @@ } | ||
} | ||
result.type = Math.max(...result.array.map(row => ComplexDecimal.maxNumberType(...row))); | ||
result.type = Math.max(...result.array.map((row) => ComplexDecimal.maxNumberType(...row))); | ||
return result; | ||
@@ -548,3 +548,3 @@ } | ||
} | ||
result.type = Math.max(...result.array.map(row => ComplexDecimal.maxNumberType(...row))); | ||
result.type = Math.max(...result.array.map((row) => ComplexDecimal.maxNumberType(...row))); | ||
return result; | ||
@@ -574,3 +574,3 @@ } | ||
} | ||
result.type = Math.max(...result.array.map(row => ComplexDecimal.maxNumberType(...row))); | ||
result.type = Math.max(...result.array.map((row) => ComplexDecimal.maxNumberType(...row))); | ||
return result; | ||
@@ -600,3 +600,3 @@ } else if (left.dim[0] === right.dim[0]) { | ||
} | ||
result.type = Math.max(...result.array.map(row => ComplexDecimal.maxNumberType(...row))); | ||
result.type = Math.max(...result.array.map((row) => ComplexDecimal.maxNumberType(...row))); | ||
return result; | ||
@@ -626,3 +626,3 @@ } else if (left.dim[1] === right.dim[1]) { | ||
} | ||
result.type = Math.max(...result.array.map(row => ComplexDecimal.maxNumberType(...row))); | ||
result.type = Math.max(...result.array.map((row) => ComplexDecimal.maxNumberType(...row))); | ||
return result; | ||
@@ -638,3 +638,3 @@ } else if (left.dim[0] === 1 && right.dim[1] === 1) { | ||
} | ||
result.type = Math.max(...result.array.map(row => ComplexDecimal.maxNumberType(...row))); | ||
result.type = Math.max(...result.array.map((row) => ComplexDecimal.maxNumberType(...row))); | ||
return result; | ||
@@ -650,6 +650,8 @@ } else if (left.dim[1] === 1 && right.dim[0] === 1) { | ||
} | ||
result.type = Math.max(...result.array.map(row => ComplexDecimal.maxNumberType(...row))); | ||
result.type = Math.max(...result.array.map((row) => ComplexDecimal.maxNumberType(...row))); | ||
return result; | ||
} else { | ||
throw new Error(`operator ${op}: nonconformant arguments (op1 is ${left.dim[0]}x${left.dim[1]}, op2 is ${right.dim[0]}x${right.dim[1]}).`); | ||
throw new Error( | ||
`operator ${op}: nonconformant arguments (op1 is ${left.dim[0]}x${left.dim[1]}, op2 is ${right.dim[0]}x${right.dim[1]}).`, | ||
); | ||
} | ||
@@ -937,3 +939,3 @@ } | ||
} | ||
result.type = Math.max(...result.array.map(row => ComplexDecimal.maxNumberType(...row))); | ||
result.type = Math.max(...result.array.map((row) => ComplexDecimal.maxNumberType(...row))); | ||
return result; | ||
@@ -955,3 +957,3 @@ } | ||
} | ||
result.type = Math.max(...result.array.map(row => ComplexDecimal.maxNumberType(...row))); | ||
result.type = Math.max(...result.array.map((row) => ComplexDecimal.maxNumberType(...row))); | ||
return result; | ||
@@ -1005,3 +1007,3 @@ } | ||
} | ||
temp.type = Math.max(...temp.array.map(row => ComplexDecimal.maxNumberType(...row))); | ||
temp.type = Math.max(...temp.array.map((row) => ComplexDecimal.maxNumberType(...row))); | ||
return temp; | ||
@@ -1030,8 +1032,7 @@ } else { | ||
for (let j = 0; j < temp.dim[1]; j++) { | ||
result.array[0][j] = ComplexDecimal.minMaxArrayComplex(cmp, ...temp.array.map(row => row[j])); | ||
result.array[0][j] = ComplexDecimal.minMaxArrayComplex(cmp, ...temp.array.map((row) => row[j])); | ||
} | ||
} | ||
else { | ||
} else { | ||
for (let j = 0; j < temp.dim[1]; j++) { | ||
result.array[0][j] = ComplexDecimal.minMaxArrayReal(cmp, ...temp.array.map(row => row[j])); | ||
result.array[0][j] = ComplexDecimal.minMaxArrayReal(cmp, ...temp.array.map((row) => row[j])); | ||
} | ||
@@ -1045,4 +1046,3 @@ } | ||
} | ||
} | ||
else { | ||
} else { | ||
return M; | ||
@@ -1097,3 +1097,3 @@ } | ||
} | ||
result.type = Math.max(...result.array.map(row => ComplexDecimal.maxNumberType(...row))); | ||
result.type = Math.max(...result.array.map((row) => ComplexDecimal.maxNumberType(...row))); | ||
if (temp.dim[1] === 1) { | ||
@@ -1270,3 +1270,3 @@ return result.array[0][0]; | ||
result.array = I; | ||
result.type = Math.max(...result.array.map(row => ComplexDecimal.maxNumberType(...row))); | ||
result.type = Math.max(...result.array.map((row) => ComplexDecimal.maxNumberType(...row))); | ||
return result; | ||
@@ -1325,3 +1325,3 @@ } else { | ||
} | ||
temp.type = Math.max(...temp.array.map(row => ComplexDecimal.maxNumberType(...row))); | ||
temp.type = Math.max(...temp.array.map((row) => ComplexDecimal.maxNumberType(...row))); | ||
return temp; | ||
@@ -1413,3 +1413,3 @@ } | ||
} | ||
X.type = Math.max(...X.array.map(row => ComplexDecimal.maxNumberType(...row))); | ||
X.type = Math.max(...X.array.map((row) => ComplexDecimal.maxNumberType(...row))); | ||
return X; | ||
@@ -1416,0 +1416,0 @@ } |
@@ -135,3 +135,3 @@ import { ComplexDecimal } from './complex-decimal'; | ||
} else { | ||
throw new Error('invalid exponent in \'^\'.'); | ||
throw new Error("invalid exponent in '^'."); | ||
} | ||
@@ -138,0 +138,0 @@ } |
430813
6564