nerdamer-ts
Version:
javascript light-weight symbolic math expression evaluator
100 lines • 5.03 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Core = void 0;
const FunctionProvider_1 = require("../Providers/FunctionProvider");
const OperatorDictionary_1 = require("../Providers/OperatorDictionary");
const VariableDictionary_1 = require("../Providers/VariableDictionary");
const Tokenizer_1 = require("../Parser/Tokenizer");
const Expression_1 = require("../Parser/Expression");
const pow_1 = require("../Functions/Core/operations/pow");
const Parser_1 = require("../Parser/Parser");
const Settings_1 = require("../Settings");
const Math2_1 = require("../Functions/Math2");
const Symbol_1 = require("../Types/Symbol");
const Utils = __importStar(require("./Utils"));
const Errors_1 = require("./Errors");
const Groups_1 = require("../Types/Groups");
const Frac_1 = require("../Types/Frac");
const Vector_1 = require("../Types/Vector");
const Matrix_1 = require("../Types/Matrix");
const Scientific_1 = __importDefault(require("../Types/Scientific"));
const LaTeX_1 = require("../LaTeX/LaTeX");
const bigInt_1 = __importDefault(require("../3rdparty/bigInt"));
const decimal_js_1 = __importDefault(require("decimal.js"));
const exceptions = __importStar(require("./Errors"));
class Core {
constructor() {
this.groups = Groups_1.Groups;
this.Symbol = Symbol_1.Symbol;
this.Expression = Expression_1.Expression;
this.Frac = Frac_1.Frac;
this.Vector = Vector_1.Vector;
this.Matrix = Matrix_1.Matrix;
this.Parser = Parser_1.Parser;
this.Scientific = Scientific_1.default;
this.Math2 = Math2_1.Math2;
this.LaTeX = LaTeX_1.LaTeX;
this.PARENTHESIS = Settings_1.Settings.PARENTHESIS;
this.Settings = Settings_1.Settings;
this.err = Errors_1.err;
this.bigInt = bigInt_1.default;
this.bigDec = decimal_js_1.default;
this.exceptions = exceptions;
const functionProvider = this.functionProvider = new FunctionProvider_1.FunctionProvider();
const operators = this.operators = new OperatorDictionary_1.OperatorDictionary();
const variableDictionary = this.variableDictionary = new VariableDictionary_1.VariableDictionary();
const units = {};
const tokenizer = new Tokenizer_1.Tokenizer(functionProvider, operators, units);
const peekers = this.peekers = {
pre_operator: [],
post_operator: [],
pre_function: [],
post_function: []
};
const EXPRESSIONS = this.EXPRESSIONS = [];
Expression_1.Expression.$EXPRESSIONS = EXPRESSIONS;
(0, pow_1.primeFactors)(314146179365);
//link the Math2 object to Settings.FUNCTION_MODULES
Settings_1.Settings.FUNCTION_MODULES.push(Math2_1.Math2);
variableDictionary.reserveNames(Math2_1.Math2); //reserve the names in Math2
const parser = new Parser_1.Parser(tokenizer, operators, functionProvider, variableDictionary, peekers, units);
Parser_1.ParseDeps.parser = parser;
this.PARSER = parser;
variableDictionary.reserveNames(variableDictionary.getAllConstants());
variableDictionary.reserveNames(functionProvider.getFunctionDescriptors());
parser.initConstants();
//bug fix for error but needs to be revisited
if (!parser.error)
parser.error = Errors_1.err;
//Store the log and log10 functions
Settings_1.Settings.LOG_FNS = {
log: functionProvider.getFunctionDescriptor('log'),
log10: functionProvider.getFunctionDescriptor('log10')
};
this.Utils = Object.assign(Object.assign({}, Utils), { clearU: (u) => variableDictionary.clearU(u), getU: (symbol) => variableDictionary.getU(symbol), importFunctions: () => functionProvider.importFunctions(), reserveNames: (module) => variableDictionary.reserveNames(module), isReserved: (name) => variableDictionary.isReserved(name), round: Utils.nround });
}
}
exports.Core = Core;
//# sourceMappingURL=Core.js.map