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.5.0 to 1.5.1

3

CHANGES.md

@@ -5,2 +5,5 @@ # Release notes

## 1.5.1
- Bug fix in `Evaluator` ('IDX' node processing).
## 1.5.0

@@ -7,0 +10,0 @@ - The file 'FunctionHandle.ts' and its corresponding test file has been created. The `FunctionHandle` type has been created and made a member of `AST.NodeExpr` through `ElementType`. `Evaluator.nameTable` entries has been changed to `AST.NodeExpr`. Changes in `Evaluator.Evaluator`, removing function definition, and altering processing of node types 'IDENT' and 'IDX' to use function handles. Now the function definitions and use is the same like in MATLAB®/Octave.

7

lib/src/Evaluator.d.ts

@@ -12,5 +12,6 @@ /**

/**
* aliasNameTable type.
* aliasNameTable and AliasFunction type.
*/
export type AliasNameTable = Record<string, RegExp>;
export type AliasFunction = (name: string) => string;
/**

@@ -20,2 +21,3 @@ * builtInFunctionTable type.

export type BuiltInFunctionTableEntry = {
type: 'BUILTIN';
mapper: boolean;

@@ -143,2 +145,3 @@ ev: boolean[];

readonly scalarToArray: typeof MultiArray.scalarToMultiArray;
readonly arrayToScalar: typeof MultiArray.MultiArrayToScalar;
readonly linearLength: typeof MultiArray.linearLength;

@@ -158,3 +161,3 @@ readonly getDimension: typeof MultiArray.getDimension;

*/
aliasName: (name: string) => string;
aliasName: AliasFunction;
/**

@@ -161,0 +164,0 @@ * Evaluator object constructor

import * as AST from './AST';
export type FunctionTableEntry = AST.NodeFunction;
export interface VariableTableEntry {
type: number;
parameter?: AST.NodeIdentifier[];
expression?: AST.NodeExpr;
}
import { AliasFunction, BuiltInFunctionTable, BuiltInFunctionTableEntry } from './Evaluator';
export declare class SymbolTable {
static readonly NAME = 1;
static readonly FUNCTION_HANDLER = 2;
static readonly ANON_FUNCTION_HANDLER = 3;
variableTable: Record<string, VariableTableEntry>;
functionTable: Record<string, FunctionTableEntry>;
variableTable: Record<string, AST.NodeExpr>;
functionTable: Record<string, AST.NodeFunction>;
builtInTable: BuiltInFunctionTable;
aliasName: AliasFunction;
parent: SymbolTable | null;
child: SymbolTable[];
scope: string | null;
constructor(parent?: SymbolTable | null, scope?: string | null, node?: any);
lookupVariable(id: string): [VariableTableEntry, string | null] | null;
insertVariable(id: string, expression: AST.NodeExpr, parameter?: AST.NodeIdentifier[]): [VariableTableEntry, string | null];
lookupFunction(id: string): [FunctionTableEntry, string | null] | null;
insertFunction(id: string, entry: FunctionTableEntry): [FunctionTableEntry, string | null];
constructor(builtInTable: BuiltInFunctionTable, aliasName: AliasFunction, parent?: SymbolTable | null, scope?: string | null, node?: any);
lookupVariable(id: string): [AST.NodeExpr, string | null] | null;
insertVariable(id: string, expression: AST.NodeExpr): [AST.NodeExpr, string | null];
lookupFunction(id: string): [AST.NodeFunction | BuiltInFunctionTableEntry, string | null] | null;
insertFunction(id: string, entry: AST.NodeFunction): [AST.NodeFunction, string | null];
}
{
"name": "mathjslab",
"version": "1.5.0",
"version": "1.5.1",
"description": "MathJSLab - An interpreter with language syntax like MATLAB®/Octave. ISBN 978-65-00-82338-7",

@@ -59,13 +59,13 @@ "main": "lib/mathjslab.js",

"@types/jest": "29.5.11",
"@types/node": "^20.10.6",
"@types/node": "^20.11.0",
"@types/supertest": "^6.0.2",
"@types/webpack": "^5.28.5",
"@typescript-eslint/eslint-plugin": "^6.18.0",
"@typescript-eslint/eslint-plugin": "^6.18.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.2",
"eslint-plugin-prettier": "^5.1.3",
"jest": "29.7.0",
"lint-staged": "^15.2.0",
"prettier": "^3.1.1",
"prettier": "^3.2.2",
"rimraf": "^5.0.5",

@@ -72,0 +72,0 @@ "ts-jest": "29.1.1",

import * as AST from './AST';
import { AliasFunction, BuiltInFunctionTable, BuiltInFunctionTableEntry } from './Evaluator';
export type FunctionTableEntry = AST.NodeFunction;
export interface VariableTableEntry {
type: number;
parameter?: AST.NodeIdentifier[];
expression?: AST.NodeExpr;
}
export class SymbolTable {
public static readonly NAME = 1;
public static readonly FUNCTION_HANDLER = 2;
public static readonly ANON_FUNCTION_HANDLER = 3;
variableTable: Record<string, VariableTableEntry>;
functionTable: Record<string, FunctionTableEntry>;
variableTable: Record<string, AST.NodeExpr>;
functionTable: Record<string, AST.NodeFunction>;
builtInTable: BuiltInFunctionTable;
aliasName: AliasFunction;
parent: SymbolTable | null;

@@ -21,3 +13,3 @@ child: SymbolTable[];

constructor(parent?: SymbolTable | null, scope?: string | null, node?: any) {
constructor(builtInTable: BuiltInFunctionTable, aliasName: AliasFunction, parent?: SymbolTable | null, scope?: string | null, node?: any) {
const thisParent = typeof parent !== 'undefined' ? parent : null;

@@ -29,2 +21,4 @@ if (thisParent) {

this.functionTable = {};
this.builtInTable = builtInTable;
this.aliasName = aliasName;
this.parent = thisParent;

@@ -38,3 +32,3 @@ this.child = [];

public lookupVariable(id: string): [VariableTableEntry, string | null] | null {
public lookupVariable(id: string): [AST.NodeExpr, string | null] | null {
/* eslint-disable-next-line @typescript-eslint/no-this-alias */

@@ -52,12 +46,8 @@ let table: SymbolTable | null = this;

public insertVariable(id: string, expression: AST.NodeExpr, parameter?: AST.NodeIdentifier[]): [VariableTableEntry, string | null] {
this.variableTable[id] = {
type: parameter ? SymbolTable.FUNCTION_HANDLER : SymbolTable.NAME,
expression,
parameter: parameter ?? [],
};
public insertVariable(id: string, expression: AST.NodeExpr): [AST.NodeExpr, string | null] {
this.variableTable[id] = expression;
return [this.variableTable[id], this.scope];
}
public lookupFunction(id: string): [FunctionTableEntry, string | null] | null {
public lookupFunction(id: string): [AST.NodeFunction | BuiltInFunctionTableEntry, string | null] | null {
/* eslint-disable-next-line @typescript-eslint/no-this-alias */

@@ -75,3 +65,3 @@ let table: SymbolTable | null = this;

public insertFunction(id: string, entry: FunctionTableEntry): [FunctionTableEntry, string | null] {
public insertFunction(id: string, entry: AST.NodeFunction): [AST.NodeFunction, string | null] {
this.functionTable[id] = entry;

@@ -78,0 +68,0 @@ return [this.functionTable[id], this.scope];

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