Comparing version 1.0.13 to 1.0.14
@@ -18,3 +18,3 @@ module.exports = { | ||
}, | ||
ignorePatterns: ['.eslintrc.js', 'dist/**'], | ||
ignorePatterns: ['.eslintrc.js', 'build/**'], | ||
rules: { | ||
@@ -21,0 +21,0 @@ '@typescript-eslint/interface-name-prefix': 'off', |
{ | ||
"name": "mathjslab", | ||
"version": "1.0.13", | ||
"version": "1.0.14", | ||
"description": "MathJSLab - An interpreter with language syntax like MATLAB/Octave", | ||
"main": "dist/mathjslab.js", | ||
"types": "dist/src/index.d.ts", | ||
"main": "build/mathjslab.js", | ||
"types": "build/src/index.d.ts", | ||
"repository": { | ||
@@ -48,3 +48,3 @@ "type": "git", | ||
"build": "webpack --mode production", | ||
"clean": "rimraf dist src/parser.js", | ||
"clean": "rimraf build src/parser.js", | ||
"publish-mathjslab": "npm publish --access public" | ||
@@ -51,0 +51,0 @@ }, |
@@ -14,4 +14,9 @@ /** | ||
/** | ||
* baseFunctionTable type | ||
* aliasNameTable type. | ||
*/ | ||
export type TAliasNameTable = Record<string, RegExp>; | ||
/** | ||
* baseFunctionTable type. | ||
*/ | ||
export type TBaseFunctionTableEntry = { | ||
@@ -25,8 +30,17 @@ mapper?: boolean; | ||
/** | ||
* TEvaluatorConfig type | ||
* commandWordListTable type. | ||
*/ | ||
type TAliasNameTable = Record<string, RegExp>; | ||
export type TCommandWordListFunction = (...args: string[]) => void; | ||
export type TCommandWordListTableEntry = { | ||
func: TCommandWordListFunction; | ||
}; | ||
export type TCommandWordListTable = { [k: string]: TCommandWordListTableEntry }; | ||
/** | ||
* TEvaluatorConfig type. | ||
*/ | ||
export type TEvaluatorConfig = { | ||
aliasTable?: TAliasNameTable; | ||
externalFuctionTable?: TBaseFunctionTable; | ||
externalFunctionTable?: TBaseFunctionTable; | ||
externalCmdWListTable?: TCommandWordListTable; | ||
}; | ||
@@ -134,4 +148,5 @@ | ||
/* eslint-disable-next-line no-var */ | ||
var EvaluatorPointer: any; | ||
const commandsTable: string[]; | ||
var EvaluatorPointer: Evaluator; | ||
/* eslint-disable-next-line no-var */ | ||
var commandsTable: string[]; | ||
} | ||
@@ -150,3 +165,3 @@ | ||
public static response = { | ||
INFO: -2, | ||
EXTERNAL: -2, | ||
WARNING: -1, | ||
@@ -202,2 +217,4 @@ OK: 0, | ||
public commandWordListTable: TCommandWordListTable = {}; | ||
/** | ||
@@ -214,7 +231,2 @@ * Parser (generated by Jison). | ||
/** | ||
* Evaluator exit message. | ||
*/ | ||
public exitMessage: string = ''; | ||
/** | ||
* Operator table. | ||
@@ -349,5 +361,11 @@ */ | ||
} | ||
if (config.externalFuctionTable) { | ||
Object.assign(evaluator.baseFunctionTable, config.externalFuctionTable); | ||
if (config.externalFunctionTable) { | ||
Object.assign(evaluator.baseFunctionTable, config.externalFunctionTable); | ||
} | ||
if (config.externalCmdWListTable) { | ||
Object.assign(evaluator.commandWordListTable, config.externalCmdWListTable); | ||
} | ||
for (const cmd in evaluator.commandWordListTable) { | ||
global.commandsTable.push(cmd); | ||
} | ||
} else { | ||
@@ -696,3 +714,5 @@ evaluator.aliasName = (name: string): string => name; | ||
let aliasTreeName: string; | ||
if (this.debug) console.log('Evaluator(tree:' + JSON.stringify(tree, null, 2) + ',local:' + local + ',fname:' + fname + ')'); | ||
if (this.debug) { | ||
console.log('Evaluator(tree:' + JSON.stringify(tree, null, 2) + ',local:' + local + ',fname:' + fname + ')'); | ||
} | ||
if ('list' in tree) { | ||
@@ -929,12 +949,4 @@ const result = { list: new Array(tree.list.length) }; | ||
case 'CmdWList': | ||
switch (tree.id) { | ||
case 'help': | ||
this.exitStatus = Evaluator.response.INFO; | ||
// this.exitMessage = helpCommand(tree.args); | ||
break; | ||
case 'doc': | ||
this.exitStatus = Evaluator.response.INFO; | ||
// this.exitMessage = docCommand(tree.args); | ||
break; | ||
} | ||
this.commandWordListTable[tree.id].func(...tree.args.map((word: { str: string }) => word.str)); | ||
this.exitStatus = Evaluator.response.EXTERNAL; | ||
return tree; | ||
@@ -956,2 +968,3 @@ default: | ||
const result = this.Evaluator(tree, false, ''); | ||
/* If not an assignment then assign result to `ans` name. */ | ||
const assign_op = ['=', '+=', '.+=', '-=', '.-=', '*=', '/=', '\\=', '^=', '.*=', './=', '.\\=', '.^=', '.**=', '|=', '&=']; | ||
@@ -961,6 +974,2 @@ if (assign_op.indexOf(result.type) == -1) { | ||
} | ||
if (this.exitStatus >= 0) { | ||
/* not (WARNING or INFO) */ | ||
this.exitMessage = ''; | ||
} | ||
return result; | ||
@@ -1324,2 +1333,6 @@ } catch (e) { | ||
} | ||
public toMathML(text: string): string { | ||
return this.UnparseML(this.Parse(text)); | ||
} | ||
} |
{ | ||
"extends": "./tsconfig.json", | ||
"exclude": ["node_modules", "webpack.config.ts", "test", "dist", "**/*spec.ts"] | ||
"exclude": ["node_modules", "webpack.config.ts", "test", "build", "**/*spec.ts"] | ||
} |
@@ -52,3 +52,3 @@ { | ||
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ | ||
"outDir": "./dist", /* Specify an output folder for all emitted files. */ | ||
"outDir": "./build", /* Specify an output folder for all emitted files. */ | ||
// "removeComments": true, /* Disable emitting comments. */ | ||
@@ -55,0 +55,0 @@ // "noEmit": true, /* Disable emitting files from a compilation. */ |
@@ -29,3 +29,3 @@ import path from 'path'; | ||
output: { | ||
path: path.resolve(__dirname, 'dist'), | ||
path: path.resolve(__dirname, 'build'), | ||
filename: 'mathjslab.js', | ||
@@ -32,0 +32,0 @@ library: 'mathjslab', |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 1 instance in 1 package
400904
6298