exprify 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/README.md +135 -0
- package/dist/exprify.cjs.js +519 -0
- package/dist/exprify.cjs.js.map +1 -0
- package/dist/exprify.esm.js +511 -0
- package/dist/exprify.esm.js.map +1 -0
- package/dist/exprify.js +532 -0
- package/dist/exprify.js.map +1 -0
- package/dist/exprify.min.js +3 -0
- package/dist/exprify.min.js.map +1 -0
- package/package.json +53 -0
- package/src/core/Exprify.js +70 -0
- package/src/functions/externalFunctions.js +19 -0
- package/src/functions/internalFunctions.js +53 -0
- package/src/index.js +38 -0
- package/src/math/operations.js +48 -0
- package/src/parser/evaluator.js +57 -0
- package/src/parser/infixToPostfix.js +78 -0
- package/src/parser/tokenizer.js +145 -0
- package/src/utils/typeConverter.js +63 -0
- package/src/variables/variables.js +28 -0
package/dist/exprify.js
ADDED
|
@@ -0,0 +1,532 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* exprify v1.0.0
|
|
3
|
+
* (c) 2026 Nirmal Paul and other contributors
|
|
4
|
+
*
|
|
5
|
+
* Released under the GPL-3.0 License
|
|
6
|
+
* Date: 2026-04-02
|
|
7
|
+
*/
|
|
8
|
+
(function (global, factory) {
|
|
9
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
10
|
+
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
11
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Exprify = {}));
|
|
12
|
+
})(this, (function (exports) { 'use strict';
|
|
13
|
+
|
|
14
|
+
function tokenize(expr, context) {
|
|
15
|
+
let tokens = [];
|
|
16
|
+
let current = "";
|
|
17
|
+
let quote = "";
|
|
18
|
+
|
|
19
|
+
for (let i = 0; i < expr.length; i++) {
|
|
20
|
+
|
|
21
|
+
let char = expr[i];
|
|
22
|
+
|
|
23
|
+
const isOperator =
|
|
24
|
+
char === '(' || char === ')' ||
|
|
25
|
+
char === '^' || char === '*' ||
|
|
26
|
+
char === '/' || char === '%' ||
|
|
27
|
+
char === '+' || char === '-';
|
|
28
|
+
|
|
29
|
+
const isQuote = char === '"' || char === "'" || char === "`";
|
|
30
|
+
|
|
31
|
+
if (isQuote) {
|
|
32
|
+
if (quote === "") {
|
|
33
|
+
quote = char;
|
|
34
|
+
current += char;
|
|
35
|
+
} else if (quote === char) {
|
|
36
|
+
current += char;
|
|
37
|
+
quote = "";
|
|
38
|
+
|
|
39
|
+
tokens.push(context.stringToJS(current, context.variablesDB));
|
|
40
|
+
current = "";
|
|
41
|
+
} else {
|
|
42
|
+
current += char;
|
|
43
|
+
}
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (quote !== "") {
|
|
48
|
+
current += char;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (char === "#") {
|
|
53
|
+
|
|
54
|
+
let bracket = 0;
|
|
55
|
+
let funcName = "";
|
|
56
|
+
let arg = "";
|
|
57
|
+
let args = [];
|
|
58
|
+
let quoteFunc = "";
|
|
59
|
+
|
|
60
|
+
while (i < expr.length - 1) {
|
|
61
|
+
i++;
|
|
62
|
+
char = expr[i];
|
|
63
|
+
|
|
64
|
+
if (bracket === 0) {
|
|
65
|
+
if (char === "(") {
|
|
66
|
+
bracket++;
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (char === " ")
|
|
71
|
+
throw new Error("Function name cannot contain space");
|
|
72
|
+
|
|
73
|
+
if (isQuote)
|
|
74
|
+
throw new Error("Function name cannot contain quotes");
|
|
75
|
+
|
|
76
|
+
if (funcName === "" && /[0-9.]/.test(char))
|
|
77
|
+
throw new Error("Function name cannot start with number");
|
|
78
|
+
|
|
79
|
+
funcName += char;
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (isQuote) {
|
|
84
|
+
if (quoteFunc === "") quoteFunc = char;
|
|
85
|
+
else if (quoteFunc === char) quoteFunc = "";
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (quoteFunc === "") {
|
|
89
|
+
|
|
90
|
+
if (char === "(") bracket++;
|
|
91
|
+
else if (char === ")") {
|
|
92
|
+
bracket--;
|
|
93
|
+
|
|
94
|
+
if (bracket === 0) {
|
|
95
|
+
if (arg !== "") args.push(arg);
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (char === "," && bracket === 1) {
|
|
101
|
+
if (arg === "")
|
|
102
|
+
throw new Error(`Missing argument in #${funcName}()`);
|
|
103
|
+
|
|
104
|
+
args.push(arg);
|
|
105
|
+
arg = "";
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
arg += char;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
args = args.map(a => context.evaluate(a));
|
|
114
|
+
|
|
115
|
+
let fn =
|
|
116
|
+
context.func_DB_intrnl[funcName] ||
|
|
117
|
+
context.func_DB_extrnl[funcName];
|
|
118
|
+
|
|
119
|
+
if (!fn) {
|
|
120
|
+
throw new Error(`#${funcName}() not defined`);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
tokens.push(fn(...args));
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (isOperator) {
|
|
128
|
+
|
|
129
|
+
if (current !== "") {
|
|
130
|
+
tokens.push(context.stringToJS(current, context.variablesDB));
|
|
131
|
+
current = "";
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
tokens.push(char);
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (char === " ") {
|
|
139
|
+
if (current !== "") {
|
|
140
|
+
tokens.push(context.stringToJS(current, context.variablesDB));
|
|
141
|
+
current = "";
|
|
142
|
+
}
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
current += char;
|
|
147
|
+
|
|
148
|
+
if (i === expr.length - 1 && current !== "") {
|
|
149
|
+
tokens.push(context.stringToJS(current, context.variablesDB));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (quote !== "") {
|
|
154
|
+
throw new Error("Unclosed string literal");
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return tokens;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function infixToPostfix(tokens, operator_precedence) {
|
|
161
|
+
let output = [];
|
|
162
|
+
let stack = [];
|
|
163
|
+
|
|
164
|
+
for (let i = 0; i < tokens.length; i++) {
|
|
165
|
+
|
|
166
|
+
let token = tokens[i];
|
|
167
|
+
|
|
168
|
+
const isOperator =
|
|
169
|
+
token === '^' || token === '*' ||
|
|
170
|
+
token === '/' || token === '%' ||
|
|
171
|
+
token === '+' || token === '-';
|
|
172
|
+
|
|
173
|
+
const isLeftParen = token === "(";
|
|
174
|
+
const isRightParen = token === ")";
|
|
175
|
+
|
|
176
|
+
const isOperand = !isOperator && !isLeftParen && !isRightParen;
|
|
177
|
+
|
|
178
|
+
if (isOperand) {
|
|
179
|
+
output.push(token);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
else if (isOperator) {
|
|
183
|
+
|
|
184
|
+
while (stack.length > 0) {
|
|
185
|
+
|
|
186
|
+
let top = stack[stack.length - 1];
|
|
187
|
+
|
|
188
|
+
if (top === "(") break;
|
|
189
|
+
|
|
190
|
+
let topPrec = operator_precedence[top] || 0;
|
|
191
|
+
let currPrec = operator_precedence[token];
|
|
192
|
+
|
|
193
|
+
// Right associativity for ^
|
|
194
|
+
if (
|
|
195
|
+
(token === '^' && currPrec < topPrec) ||
|
|
196
|
+
(token !== '^' && currPrec <= topPrec)
|
|
197
|
+
) {
|
|
198
|
+
output.push(stack.pop());
|
|
199
|
+
} else {
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
stack.push(token);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
else if (isLeftParen) {
|
|
208
|
+
stack.push(token);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
else if (isRightParen) {
|
|
212
|
+
|
|
213
|
+
while (stack.length > 0 && stack[stack.length - 1] !== "(") {
|
|
214
|
+
output.push(stack.pop());
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (stack.length === 0) {
|
|
218
|
+
throw new Error("Mismatched parentheses: missing '('");
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
stack.pop();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
while (stack.length > 0) {
|
|
226
|
+
|
|
227
|
+
let top = stack.pop();
|
|
228
|
+
|
|
229
|
+
if (top === "(" || top === ")") {
|
|
230
|
+
throw new Error("Mismatched parentheses");
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
output.push(top);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
return output;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
function evaluatePostfix(postfix, mathOperations) {
|
|
240
|
+
|
|
241
|
+
let stack = [];
|
|
242
|
+
|
|
243
|
+
const isOperator = (val) =>
|
|
244
|
+
val === '^' || val === '*' ||
|
|
245
|
+
val === '/' || val === '%' ||
|
|
246
|
+
val === '+' || val === '-';
|
|
247
|
+
|
|
248
|
+
for (let i = 0; i < postfix.length; i++) {
|
|
249
|
+
|
|
250
|
+
let token = postfix[i];
|
|
251
|
+
|
|
252
|
+
if (!isOperator(token)) {
|
|
253
|
+
stack.push(token);
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
if (stack.length < 2) {
|
|
258
|
+
throw new Error("Invalid expression: insufficient operands");
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
let b = stack.pop(); // second
|
|
262
|
+
let a = stack.pop(); // first
|
|
263
|
+
|
|
264
|
+
let result;
|
|
265
|
+
|
|
266
|
+
switch (token) {
|
|
267
|
+
case '^':
|
|
268
|
+
result = mathOperations.power(a, b);
|
|
269
|
+
break;
|
|
270
|
+
case '*':
|
|
271
|
+
result = mathOperations.multiply(a, b);
|
|
272
|
+
break;
|
|
273
|
+
case '/':
|
|
274
|
+
result = mathOperations.divide(a, b);
|
|
275
|
+
break;
|
|
276
|
+
case '%':
|
|
277
|
+
result = mathOperations.modulus(a, b);
|
|
278
|
+
break;
|
|
279
|
+
case '+':
|
|
280
|
+
result = mathOperations.add(a, b);
|
|
281
|
+
break;
|
|
282
|
+
case '-':
|
|
283
|
+
result = mathOperations.subtract(a, b);
|
|
284
|
+
break;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
stack.push(result);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
if (stack.length !== 1) {
|
|
291
|
+
throw new Error("Invalid expression: leftover values in stack");
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return stack[0];
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const isValidNumberPair = (a, b) =>
|
|
298
|
+
(typeof a === typeof b) &&
|
|
299
|
+
(typeof a === 'number' || typeof a === 'bigint');
|
|
300
|
+
|
|
301
|
+
const mathOperations = Object.freeze({
|
|
302
|
+
|
|
303
|
+
operator_precedence: {
|
|
304
|
+
'^': 4,
|
|
305
|
+
'*': 3,
|
|
306
|
+
'/': 3,
|
|
307
|
+
'%': 3,
|
|
308
|
+
'+': 1,
|
|
309
|
+
'-': 1,
|
|
310
|
+
},
|
|
311
|
+
|
|
312
|
+
power: function(a, b) {
|
|
313
|
+
if (isValidNumberPair(a, b)) return a ** b;
|
|
314
|
+
throw new Error("Invalid types for ^");
|
|
315
|
+
},
|
|
316
|
+
|
|
317
|
+
multiply: function(a, b) {
|
|
318
|
+
if (isValidNumberPair(a, b)) return a * b;
|
|
319
|
+
throw new Error("Invalid types for *");
|
|
320
|
+
},
|
|
321
|
+
|
|
322
|
+
divide: function(a, b) {
|
|
323
|
+
if (isValidNumberPair(a, b)) {
|
|
324
|
+
if (b === 0) throw new Error("Division by zero");
|
|
325
|
+
return a / b;
|
|
326
|
+
}
|
|
327
|
+
throw new Error("Invalid types for /");
|
|
328
|
+
},
|
|
329
|
+
|
|
330
|
+
add: function(a, b) {
|
|
331
|
+
if (isValidNumberPair(a, b)) return a + b;
|
|
332
|
+
if (typeof a === 'string' && typeof b === 'string') return a + b;
|
|
333
|
+
throw new Error("Invalid types for +");
|
|
334
|
+
},
|
|
335
|
+
subtract: function(a, b) {
|
|
336
|
+
if (isValidNumberPair(a, b)) return a - b;
|
|
337
|
+
throw new Error("Invalid types for -");
|
|
338
|
+
},
|
|
339
|
+
|
|
340
|
+
modulus: function(a, b) {
|
|
341
|
+
if (isValidNumberPair(a, b)) return a % b;
|
|
342
|
+
throw new Error("Invalid types for %");
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
|
|
346
|
+
const and = (...args) => args.every(Boolean);
|
|
347
|
+
const or = (...args) => args.some(Boolean);
|
|
348
|
+
const not = (val) => !val;
|
|
349
|
+
|
|
350
|
+
const gt = (a, b) => a > b;
|
|
351
|
+
const lt = (a, b) => a < b;
|
|
352
|
+
const eq = (a, b) => a === b;
|
|
353
|
+
const gte = (a, b) => a >= b;
|
|
354
|
+
const lte = (a, b) => a <= b;
|
|
355
|
+
|
|
356
|
+
const internalFunctions = Object.freeze({
|
|
357
|
+
|
|
358
|
+
max: (...args) => {
|
|
359
|
+
if (!args.every(v => typeof v === 'number')) {
|
|
360
|
+
throw new Error("max() expects numbers only");
|
|
361
|
+
}
|
|
362
|
+
return Math.max(...args);
|
|
363
|
+
},
|
|
364
|
+
|
|
365
|
+
min: (...args) => {
|
|
366
|
+
if (!args.every(v => typeof v === 'number')) {
|
|
367
|
+
throw new Error("min() expects numbers only");
|
|
368
|
+
}
|
|
369
|
+
return Math.min(...args);
|
|
370
|
+
},
|
|
371
|
+
|
|
372
|
+
and,
|
|
373
|
+
"&&": and,
|
|
374
|
+
|
|
375
|
+
or,
|
|
376
|
+
"||": or,
|
|
377
|
+
|
|
378
|
+
not,
|
|
379
|
+
"!": not,
|
|
380
|
+
|
|
381
|
+
greaterThan: gt,
|
|
382
|
+
">": gt,
|
|
383
|
+
|
|
384
|
+
lessThan: lt,
|
|
385
|
+
"<": lt,
|
|
386
|
+
|
|
387
|
+
isEqual: eq,
|
|
388
|
+
"==": eq,
|
|
389
|
+
|
|
390
|
+
greaterThanOrEqual: gte,
|
|
391
|
+
">=": gte,
|
|
392
|
+
|
|
393
|
+
lessThanOrEqual: lte,
|
|
394
|
+
"<=": lte,
|
|
395
|
+
|
|
396
|
+
if: (cond, t, f = false) => cond ? t : f
|
|
397
|
+
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
const externalFunctions = {};
|
|
401
|
+
|
|
402
|
+
const variablesDB = {};
|
|
403
|
+
|
|
404
|
+
function stringToJS(str, variablesDB) {
|
|
405
|
+
if (typeof str !== "string" || str.length === 0) {
|
|
406
|
+
throw new Error("Invalid input: expected a non-empty string.");
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
const firstChar = str[0];
|
|
410
|
+
const lastChar = str[str.length - 1];
|
|
411
|
+
|
|
412
|
+
// HEX (0x...)
|
|
413
|
+
if (/^0x[0-9a-fA-F]+n?$/.test(str)) {
|
|
414
|
+
|
|
415
|
+
// BigInt hex (0xFFn)
|
|
416
|
+
if (lastChar === 'n') {
|
|
417
|
+
return BigInt(str.slice(0, -1));
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
return Number(str);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
if (/^[+-]?(\d+(\.\d+)?|\.\d+)(e[+-]?\d+)?n?$/i.test(str)) {
|
|
424
|
+
|
|
425
|
+
// BigInt
|
|
426
|
+
if (lastChar === 'n') {
|
|
427
|
+
const numPart = str.slice(0, -1);
|
|
428
|
+
|
|
429
|
+
if (numPart.includes('.') || /e/i.test(numPart)) {
|
|
430
|
+
throw new Error(`Invalid BigInt: ${str}`);
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
return BigInt(numPart);
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
return Number(str);
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
if (
|
|
440
|
+
(firstChar === '"' && lastChar === '"') ||
|
|
441
|
+
(firstChar === "'" && lastChar === "'") ||
|
|
442
|
+
(firstChar === '`' && lastChar === '`')
|
|
443
|
+
) {
|
|
444
|
+
return str.slice(1, -1);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
if (
|
|
448
|
+
firstChar === '"' ||
|
|
449
|
+
firstChar === "'" ||
|
|
450
|
+
firstChar === '`'
|
|
451
|
+
) {
|
|
452
|
+
throw new Error(`Unmatched or missing quotes: ${str}`);
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
if (str === "true") return true;
|
|
456
|
+
if (str === "false") return false;
|
|
457
|
+
|
|
458
|
+
if (str in variablesDB) {
|
|
459
|
+
return variablesDB[str];
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
throw new Error(
|
|
463
|
+
`${str} is not defined. Use setVariable("${str}", value) first.`
|
|
464
|
+
);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
class ViewPoint {
|
|
468
|
+
|
|
469
|
+
constructor() {
|
|
470
|
+
// Shared state
|
|
471
|
+
this.variablesDB = variablesDB;
|
|
472
|
+
this.func_DB_intrnl = internalFunctions;
|
|
473
|
+
this.func_DB_extrnl = externalFunctions;
|
|
474
|
+
|
|
475
|
+
this.operator_precedence = mathOperations.operator_precedence;
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
setVariable(name, value) {
|
|
479
|
+
this.variablesDB[name] = value;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
addFunction(name, fn) {
|
|
483
|
+
this.func_DB_extrnl[name] = fn;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
stringToJS(str) {
|
|
487
|
+
return stringToJS.call(this, str, this.variablesDB);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
evaluate(expr) {
|
|
491
|
+
|
|
492
|
+
if (typeof expr !== "string") {
|
|
493
|
+
throw new Error("Expression must be a string");
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
const context = {
|
|
497
|
+
variablesDB: this.variablesDB,
|
|
498
|
+
func_DB_intrnl: this.func_DB_intrnl,
|
|
499
|
+
func_DB_extrnl: this.func_DB_extrnl,
|
|
500
|
+
stringToJS: this.stringToJS.bind(this),
|
|
501
|
+
evaluate: this.evaluate.bind(this)
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
// Step 1: Tokenize
|
|
505
|
+
const tokens = tokenize(expr, context);
|
|
506
|
+
|
|
507
|
+
// Step 2: Infix → Postfix
|
|
508
|
+
const postfix = infixToPostfix(
|
|
509
|
+
tokens,
|
|
510
|
+
this.operator_precedence
|
|
511
|
+
);
|
|
512
|
+
|
|
513
|
+
// Step 3: Evaluate Postfix
|
|
514
|
+
const result = evaluatePostfix(
|
|
515
|
+
postfix,
|
|
516
|
+
mathOperations
|
|
517
|
+
);
|
|
518
|
+
|
|
519
|
+
return result;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
exports.Exprify = ViewPoint;
|
|
524
|
+
exports.externalFunctions = externalFunctions;
|
|
525
|
+
exports.internalFunctions = internalFunctions;
|
|
526
|
+
exports.mathOperations = mathOperations;
|
|
527
|
+
exports.variablesDB = variablesDB;
|
|
528
|
+
|
|
529
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
530
|
+
|
|
531
|
+
}));
|
|
532
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exprify.js","sources":["../src/parser/tokenizer.js","../src/parser/infixToPostfix.js","../src/parser/evaluator.js","../src/math/operations.js","../src/functions/internalFunctions.js","../src/functions/externalFunctions.js","../src/variables/variables.js","../src/utils/typeConverter.js","../src/core/Exprify.js"],"sourcesContent":["export function tokenize(expr, context) {\r\n let tokens = [];\r\n let current = \"\";\r\n let quote = \"\";\r\n\r\n for (let i = 0; i < expr.length; i++) {\r\n\r\n let char = expr[i];\r\n\r\n const isOperator =\r\n char === '(' || char === ')' ||\r\n char === '^' || char === '*' ||\r\n char === '/' || char === '%' ||\r\n char === '+' || char === '-';\r\n\r\n const isQuote = char === '\"' || char === \"'\" || char === \"`\";\r\n\r\n if (isQuote) {\r\n if (quote === \"\") {\r\n quote = char;\r\n current += char;\r\n } else if (quote === char) {\r\n current += char;\r\n quote = \"\";\r\n\r\n tokens.push(context.stringToJS(current, context.variablesDB));\r\n current = \"\";\r\n } else {\r\n current += char;\r\n }\r\n continue;\r\n }\r\n\r\n if (quote !== \"\") {\r\n current += char;\r\n continue;\r\n }\r\n\r\n if (char === \"#\") {\r\n\r\n let bracket = 0;\r\n let funcName = \"\";\r\n let arg = \"\";\r\n let args = [];\r\n let quoteFunc = \"\";\r\n\r\n while (i < expr.length - 1) {\r\n i++;\r\n char = expr[i];\r\n\r\n if (bracket === 0) {\r\n if (char === \"(\") {\r\n bracket++;\r\n continue;\r\n }\r\n\r\n if (char === \" \")\r\n throw new Error(\"Function name cannot contain space\");\r\n\r\n if (isQuote)\r\n throw new Error(\"Function name cannot contain quotes\");\r\n\r\n if (funcName === \"\" && /[0-9.]/.test(char))\r\n throw new Error(\"Function name cannot start with number\");\r\n\r\n funcName += char;\r\n continue;\r\n }\r\n\r\n if (isQuote) {\r\n if (quoteFunc === \"\") quoteFunc = char;\r\n else if (quoteFunc === char) quoteFunc = \"\";\r\n }\r\n\r\n if (quoteFunc === \"\") {\r\n\r\n if (char === \"(\") bracket++;\r\n else if (char === \")\") {\r\n bracket--;\r\n\r\n if (bracket === 0) {\r\n if (arg !== \"\") args.push(arg);\r\n break;\r\n }\r\n }\r\n\r\n if (char === \",\" && bracket === 1) {\r\n if (arg === \"\")\r\n throw new Error(`Missing argument in #${funcName}()`);\r\n\r\n args.push(arg);\r\n arg = \"\";\r\n continue;\r\n }\r\n }\r\n\r\n arg += char;\r\n }\r\n\r\n args = args.map(a => context.evaluate(a));\r\n\r\n let fn =\r\n context.func_DB_intrnl[funcName] ||\r\n context.func_DB_extrnl[funcName];\r\n\r\n if (!fn) {\r\n throw new Error(`#${funcName}() not defined`);\r\n }\r\n\r\n tokens.push(fn(...args));\r\n continue;\r\n }\r\n\r\n if (isOperator) {\r\n\r\n if (current !== \"\") {\r\n tokens.push(context.stringToJS(current, context.variablesDB));\r\n current = \"\";\r\n }\r\n\r\n tokens.push(char);\r\n continue;\r\n }\r\n\r\n if (char === \" \") {\r\n if (current !== \"\") {\r\n tokens.push(context.stringToJS(current, context.variablesDB));\r\n current = \"\";\r\n }\r\n continue;\r\n }\r\n\r\n current += char;\r\n\r\n if (i === expr.length - 1 && current !== \"\") {\r\n tokens.push(context.stringToJS(current, context.variablesDB));\r\n }\r\n }\r\n\r\n if (quote !== \"\") {\r\n throw new Error(\"Unclosed string literal\");\r\n }\r\n\r\n return tokens;\r\n}","export function infixToPostfix(tokens, operator_precedence) {\r\n let output = [];\r\n let stack = [];\r\n\r\n for (let i = 0; i < tokens.length; i++) {\r\n\r\n let token = tokens[i];\r\n\r\n const isOperator =\r\n token === '^' || token === '*' ||\r\n token === '/' || token === '%' ||\r\n token === '+' || token === '-';\r\n\r\n const isLeftParen = token === \"(\";\r\n const isRightParen = token === \")\";\r\n\r\n const isOperand = !isOperator && !isLeftParen && !isRightParen;\r\n\r\n if (isOperand) {\r\n output.push(token);\r\n }\r\n\r\n else if (isOperator) {\r\n\r\n while (stack.length > 0) {\r\n\r\n let top = stack[stack.length - 1];\r\n\r\n if (top === \"(\") break;\r\n\r\n let topPrec = operator_precedence[top] || 0;\r\n let currPrec = operator_precedence[token];\r\n\r\n // Right associativity for ^\r\n if (\r\n (token === '^' && currPrec < topPrec) ||\r\n (token !== '^' && currPrec <= topPrec)\r\n ) {\r\n output.push(stack.pop());\r\n } else {\r\n break;\r\n }\r\n }\r\n\r\n stack.push(token);\r\n }\r\n\r\n else if (isLeftParen) {\r\n stack.push(token);\r\n }\r\n\r\n else if (isRightParen) {\r\n\r\n while (stack.length > 0 && stack[stack.length - 1] !== \"(\") {\r\n output.push(stack.pop());\r\n }\r\n\r\n if (stack.length === 0) {\r\n throw new Error(\"Mismatched parentheses: missing '('\");\r\n }\r\n\r\n stack.pop();\r\n }\r\n }\r\n\r\n while (stack.length > 0) {\r\n\r\n let top = stack.pop();\r\n\r\n if (top === \"(\" || top === \")\") {\r\n throw new Error(\"Mismatched parentheses\");\r\n }\r\n\r\n output.push(top);\r\n }\r\n\r\n return output;\r\n}","export function evaluatePostfix(postfix, mathOperations) {\r\n\r\n let stack = [];\r\n\r\n const isOperator = (val) =>\r\n val === '^' || val === '*' ||\r\n val === '/' || val === '%' ||\r\n val === '+' || val === '-';\r\n\r\n for (let i = 0; i < postfix.length; i++) {\r\n\r\n let token = postfix[i];\r\n\r\n if (!isOperator(token)) {\r\n stack.push(token);\r\n continue;\r\n }\r\n\r\n if (stack.length < 2) {\r\n throw new Error(\"Invalid expression: insufficient operands\");\r\n }\r\n\r\n let b = stack.pop(); // second\r\n let a = stack.pop(); // first\r\n\r\n let result;\r\n\r\n switch (token) {\r\n case '^':\r\n result = mathOperations.power(a, b);\r\n break;\r\n case '*':\r\n result = mathOperations.multiply(a, b);\r\n break;\r\n case '/':\r\n result = mathOperations.divide(a, b);\r\n break;\r\n case '%':\r\n result = mathOperations.modulus(a, b);\r\n break;\r\n case '+':\r\n result = mathOperations.add(a, b);\r\n break;\r\n case '-':\r\n result = mathOperations.subtract(a, b);\r\n break;\r\n }\r\n\r\n stack.push(result);\r\n }\r\n\r\n if (stack.length !== 1) {\r\n throw new Error(\"Invalid expression: leftover values in stack\");\r\n }\r\n\r\n return stack[0];\r\n}","const isValidNumberPair = (a, b) =>\r\n (typeof a === typeof b) &&\r\n (typeof a === 'number' || typeof a === 'bigint');\r\n\r\nexport const mathOperations = Object.freeze({\r\n\r\n operator_precedence: {\r\n '^': 4,\r\n '*': 3,\r\n '/': 3,\r\n '%': 3,\r\n '+': 1,\r\n '-': 1,\r\n },\r\n\r\n power: function(a, b) {\r\n if (isValidNumberPair(a, b)) return a ** b;\r\n throw new Error(\"Invalid types for ^\");\r\n },\r\n\r\n multiply: function(a, b) {\r\n if (isValidNumberPair(a, b)) return a * b;\r\n throw new Error(\"Invalid types for *\");\r\n },\r\n\r\n divide: function(a, b) {\r\n if (isValidNumberPair(a, b)) {\r\n if (b === 0) throw new Error(\"Division by zero\");\r\n return a / b;\r\n }\r\n throw new Error(\"Invalid types for /\");\r\n },\r\n\r\n add: function(a, b) {\r\n if (isValidNumberPair(a, b)) return a + b;\r\n if (typeof a === 'string' && typeof b === 'string') return a + b;\r\n throw new Error(\"Invalid types for +\");\r\n },\r\n subtract: function(a, b) {\r\n if (isValidNumberPair(a, b)) return a - b;\r\n throw new Error(\"Invalid types for -\");\r\n },\r\n\r\n modulus: function(a, b) {\r\n if (isValidNumberPair(a, b)) return a % b;\r\n throw new Error(\"Invalid types for %\");\r\n }\r\n});","const and = (...args) => args.every(Boolean);\r\nconst or = (...args) => args.some(Boolean);\r\nconst not = (val) => !val;\r\n\r\nconst gt = (a, b) => a > b;\r\nconst lt = (a, b) => a < b;\r\nconst eq = (a, b) => a === b;\r\nconst gte = (a, b) => a >= b;\r\nconst lte = (a, b) => a <= b;\r\n\r\nexport const internalFunctions = Object.freeze({\r\n\r\n max: (...args) => {\r\n if (!args.every(v => typeof v === 'number')) {\r\n throw new Error(\"max() expects numbers only\");\r\n }\r\n return Math.max(...args);\r\n },\r\n\r\n min: (...args) => {\r\n if (!args.every(v => typeof v === 'number')) {\r\n throw new Error(\"min() expects numbers only\");\r\n }\r\n return Math.min(...args);\r\n },\r\n\r\n and,\r\n \"&&\": and,\r\n\r\n or,\r\n \"||\": or,\r\n\r\n not,\r\n \"!\": not,\r\n\r\n greaterThan: gt,\r\n \">\": gt,\r\n\r\n lessThan: lt,\r\n \"<\": lt,\r\n\r\n isEqual: eq,\r\n \"==\": eq,\r\n\r\n greaterThanOrEqual: gte,\r\n \">=\": gte,\r\n\r\n lessThanOrEqual: lte,\r\n \"<=\": lte,\r\n\r\n if: (cond, t, f = false) => cond ? t : f\r\n\r\n});","export const externalFunctions = {};\r\n\r\n// Add user-defined function\r\nexport function addFunction(name, fn) {\r\n\r\n if (typeof name !== \"string\" || name.trim() === \"\") {\r\n throw new Error(\"Function name must be a non-empty string\");\r\n }\r\n\r\n if (typeof fn !== \"function\") {\r\n throw new Error(\"Function must be a valid function\");\r\n }\r\n\r\n if (name in externalFunctions) {\r\n throw new Error(`Function '${name}' already exists`);\r\n }\r\n\r\n externalFunctions[name] = fn;\r\n}\r\n","export const variablesDB = {};\r\n\r\n// Valid JS variable name (full check)\r\nconst validVarName = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/;\r\n\r\nexport function setVariable(name, value, { override = true } = {}) {\r\n\r\n // Name validation\r\n if (typeof name !== \"string\" || name.trim() === \"\") {\r\n throw new Error(\"Variable Name Error: Name must be a non-empty string\");\r\n }\r\n\r\n if (!validVarName.test(name)) {\r\n throw new Error(`Variable Name Error: '${name}' is not a valid variable name`);\r\n }\r\n\r\n // Value validation\r\n if (value === undefined) {\r\n throw new Error(`Variable Value Error: '${name}' cannot be undefined`);\r\n }\r\n\r\n // Prevent overwrite (optional)\r\n if (!override && name in variablesDB) {\r\n throw new Error(`Variable '${name}' already exists`);\r\n }\r\n\r\n variablesDB[name] = value;\r\n}","export function stringToJS(str, variablesDB) {\r\n if (typeof str !== \"string\" || str.length === 0) {\r\n throw new Error(\"Invalid input: expected a non-empty string.\");\r\n }\r\n\r\n const firstChar = str[0];\r\n const lastChar = str[str.length - 1];\r\n\r\n // HEX (0x...)\r\n if (/^0x[0-9a-fA-F]+n?$/.test(str)) {\r\n\r\n // BigInt hex (0xFFn)\r\n if (lastChar === 'n') {\r\n return BigInt(str.slice(0, -1));\r\n }\r\n\r\n return Number(str);\r\n }\r\n\r\n if (/^[+-]?(\\d+(\\.\\d+)?|\\.\\d+)(e[+-]?\\d+)?n?$/i.test(str)) {\r\n\r\n // BigInt\r\n if (lastChar === 'n') {\r\n const numPart = str.slice(0, -1);\r\n\r\n if (numPart.includes('.') || /e/i.test(numPart)) {\r\n throw new Error(`Invalid BigInt: ${str}`);\r\n }\r\n\r\n return BigInt(numPart);\r\n }\r\n\r\n return Number(str);\r\n }\r\n\r\n if (\r\n (firstChar === '\"' && lastChar === '\"') ||\r\n (firstChar === \"'\" && lastChar === \"'\") ||\r\n (firstChar === '`' && lastChar === '`')\r\n ) {\r\n return str.slice(1, -1);\r\n }\r\n\r\n if (\r\n firstChar === '\"' ||\r\n firstChar === \"'\" ||\r\n firstChar === '`'\r\n ) {\r\n throw new Error(`Unmatched or missing quotes: ${str}`);\r\n }\r\n\r\n if (str === \"true\") return true;\r\n if (str === \"false\") return false;\r\n\r\n if (str in variablesDB) {\r\n return variablesDB[str];\r\n }\r\n\r\n throw new Error(\r\n `${str} is not defined. Use setVariable(\"${str}\", value) first.`\r\n );\r\n}\r\nexport default stringToJS;","import { tokenize } from \"../parser/tokenizer.js\";\r\nimport { infixToPostfix } from \"../parser/infixToPostfix.js\";\r\nimport { evaluatePostfix } from \"../parser/evaluator.js\";\r\n\r\nimport { mathOperations } from \"../math/operations.js\";\r\n\r\nimport { internalFunctions } from \"../functions/internalFunctions.js\";\r\nimport { externalFunctions } from \"../functions/externalFunctions.js\";\r\n\r\nimport { variablesDB } from \"../variables/variables.js\";\r\n\r\nimport { stringToJS } from \"../utils/typeConverter.js\";\r\n\r\nclass ViewPoint {\r\n\r\n constructor() {\r\n // Shared state\r\n this.variablesDB = variablesDB;\r\n this.func_DB_intrnl = internalFunctions;\r\n this.func_DB_extrnl = externalFunctions;\r\n\r\n this.operator_precedence = mathOperations.operator_precedence;\r\n }\r\n\r\n setVariable(name, value) {\r\n this.variablesDB[name] = value;\r\n }\r\n\r\n addFunction(name, fn) {\r\n this.func_DB_extrnl[name] = fn;\r\n }\r\n\r\n stringToJS(str) {\r\n return stringToJS.call(this, str, this.variablesDB);\r\n }\r\n\r\n evaluate(expr) {\r\n\r\n if (typeof expr !== \"string\") {\r\n throw new Error(\"Expression must be a string\");\r\n }\r\n\r\n const context = {\r\n variablesDB: this.variablesDB,\r\n func_DB_intrnl: this.func_DB_intrnl,\r\n func_DB_extrnl: this.func_DB_extrnl,\r\n stringToJS: this.stringToJS.bind(this),\r\n evaluate: this.evaluate.bind(this)\r\n };\r\n\r\n // Step 1: Tokenize\r\n const tokens = tokenize(expr, context);\r\n\r\n // Step 2: Infix → Postfix\r\n const postfix = infixToPostfix(\r\n tokens,\r\n this.operator_precedence\r\n );\r\n\r\n // Step 3: Evaluate Postfix\r\n const result = evaluatePostfix(\r\n postfix,\r\n mathOperations\r\n );\r\n\r\n return result;\r\n }\r\n}\r\n\r\nexport default ViewPoint;"],"names":[],"mappings":";;;;;;;;;;;;;IAAO,SAAS,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE;IACxC,IAAI,IAAI,MAAM,GAAG,EAAE,CAAC;IACpB,IAAI,IAAI,OAAO,GAAG,EAAE,CAAC;IACrB,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;AACnB;IACA,IAAI,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;AAC1C;IACA,QAAQ,IAAI,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;AAC3B;IACA,QAAQ,MAAM,UAAU;IACxB,YAAY,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG;IACxC,YAAY,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG;IACxC,YAAY,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG;IACxC,YAAY,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,CAAC;AACzC;IACA,QAAQ,MAAM,OAAO,GAAG,IAAI,KAAK,GAAG,IAAI,IAAI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AC,IAAI,CAAC;IAC9C,SAAS,CAAC;AACV;IACA;IACA,QAAQ,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC/C;IACA;IACA,QAAQ,MAAM,OAAO,GAAG,cAAc;IACtC,YAAY,MAAM;IAClB,YAAY,IAAI,CAAC,mBAAmB;IACpC,SAAS,CAAC;AACV;IACA;IACA,QAAQ,MAAM,MAAM,GAAG,eAAe;IACtC,YAAY,OAAO;IACnB,YAAY,cAAc;IAC1B,SAAS,CAAC;AACV;IACA,QAAQ,OAAO,MAAM,CAAC;IACtB,KAAK;IACL;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/*! exprify v1.0.0 | * (c) 2026 Nirmal Paul and contributors | GPL-3.0 License*/
|
|
2
|
+
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r((e="undefined"!=typeof globalThis?globalThis:e||self).Exprify={})}(this,function(e){"use strict";const r=(e,r)=>typeof e==typeof r&&("number"==typeof e||"bigint"==typeof e),t=Object.freeze({operator_precedence:{"^":4,"*":3,"/":3,"%":3,"+":1,"-":1},power:function(e,t){if(r(e,t))return e**t;throw new Error("Invalid types for ^")},multiply:function(e,t){if(r(e,t))return e*t;throw new Error("Invalid types for *")},divide:function(e,t){if(r(e,t)){if(0===t)throw new Error("Division by zero");return e/t}throw new Error("Invalid types for /")},add:function(e,t){if(r(e,t))return e+t;if("string"==typeof e&&"string"==typeof t)return e+t;throw new Error("Invalid types for +")},subtract:function(e,t){if(r(e,t))return e-t;throw new Error("Invalid types for -")},modulus:function(e,t){if(r(e,t))return e%t;throw new Error("Invalid types for %")}}),n=(...e)=>e.every(Boolean),i=(...e)=>e.some(Boolean),o=e=>!e,s=(e,r)=>e>r,a=(e,r)=>e<r,f=(e,r)=>e===r,l=(e,r)=>e>=r,u=(e,r)=>e<=r,h=Object.freeze({max:(...e)=>{if(!e.every(e=>"number"==typeof e))throw new Error("max() expects numbers only");return Math.max(...e)},min:(...e)=>{if(!e.every(e=>"number"==typeof e))throw new Error("min() expects numbers only");return Math.min(...e)},and:n,"&&":n,or:i,"||":i,not:o,"!":o,greaterThan:s,">":s,lessThan:a,"<":a,isEqual:f,"==":f,greaterThanOrEqual:l,">=":l,lessThanOrEqual:u,"<=":u,if:(e,r,t=!1)=>e?r:t}),c={},p={};function d(e,r){if("string"!=typeof e||0===e.length)throw new Error("Invalid input: expected a non-empty string.");const t=e[0],n=e[e.length-1];if(/^0x[0-9a-fA-F]+n?$/.test(e))return"n"===n?BigInt(e.slice(0,-1)):Number(e);if(/^[+-]?(\d+(\.\d+)?|\.\d+)(e[+-]?\d+)?n?$/i.test(e)){if("n"===n){const r=e.slice(0,-1);if(r.includes(".")||/e/i.test(r))throw new Error(`Invalid BigInt: ${e}`);return BigInt(r)}return Number(e)}if('"'===t&&'"'===n||"'"===t&&"'"===n||"`"===t&&"`"===n)return e.slice(1,-1);if('"'===t||"'"===t||"`"===t)throw new Error(`Unmatched or missing quotes: ${e}`);if("true"===e)return!0;if("false"===e)return!1;if(e in r)return r[e];throw new Error(`${e} is not defined. Use setVariable("${e}", value) first.`)}e.Exprify=class{constructor(){this.variablesDB=p,this.func_DB_intrnl=h,this.func_DB_extrnl=c,this.operator_precedence=t.operator_precedence}setVariable(e,r){this.variablesDB[e]=r}addFunction(e,r){this.func_DB_extrnl[e]=r}stringToJS(e){return d.call(this,e,this.variablesDB)}evaluate(e){if("string"!=typeof e)throw new Error("Expression must be a string");const r=function(e,r){let t=[],n="",i="";for(let o=0;o<e.length;o++){let s=e[o];const a="("===s||")"===s||"^"===s||"*"===s||"/"===s||"%"===s||"+"===s||"-"===s,f='"'===s||"'"===s||"`"===s;if(f)""===i?(i=s,n+=s):i===s?(n+=s,i="",t.push(r.stringToJS(n,r.variablesDB)),n=""):n+=s;else if(""===i){if("#"===s){let n=0,i="",a="",l=[],u="";for(;o<e.length-1;)if(o++,s=e[o],0!==n){if(f&&(""===u?u=s:u===s&&(u="")),""===u){if("("===s)n++;else if(")"===s&&(n--,0===n)){""!==a&&l.push(a);break}if(","===s&&1===n){if(""===a)throw new Error(`Missing argument in #${i}()`);l.push(a),a="";continue}}a+=s}else{if("("===s){n++;continue}if(" "===s)throw new Error("Function name cannot contain space");if(f)throw new Error("Function name cannot contain quotes");if(""===i&&/[0-9.]/.test(s))throw new Error("Function name cannot start with number");i+=s}l=l.map(e=>r.evaluate(e));let h=r.func_DB_intrnl[i]||r.func_DB_extrnl[i];if(!h)throw new Error(`#${i}() not defined`);t.push(h(...l));continue}a?(""!==n&&(t.push(r.stringToJS(n,r.variablesDB)),n=""),t.push(s)):" "!==s?(n+=s,o===e.length-1&&""!==n&&t.push(r.stringToJS(n,r.variablesDB))):""!==n&&(t.push(r.stringToJS(n,r.variablesDB)),n="")}else n+=s}if(""!==i)throw new Error("Unclosed string literal");return t}(e,{variablesDB:this.variablesDB,func_DB_intrnl:this.func_DB_intrnl,func_DB_extrnl:this.func_DB_extrnl,stringToJS:this.stringToJS.bind(this),evaluate:this.evaluate.bind(this)}),n=function(e,r){let t=[],n=[];for(let i=0;i<e.length;i++){let o=e[i];const s="^"===o||"*"===o||"/"===o||"%"===o||"+"===o||"-"===o,a="("===o,f=")"===o;if(s||a||f){if(s){for(;n.length>0;){let e=n[n.length-1];if("("===e)break;let i=r[e]||0,s=r[o];if(!("^"===o&&s<i||"^"!==o&&s<=i))break;t.push(n.pop())}n.push(o)}else if(a)n.push(o);else if(f){for(;n.length>0&&"("!==n[n.length-1];)t.push(n.pop());if(0===n.length)throw new Error("Mismatched parentheses: missing '('");n.pop()}}else t.push(o)}for(;n.length>0;){let e=n.pop();if("("===e||")"===e)throw new Error("Mismatched parentheses");t.push(e)}return t}(r,this.operator_precedence),i=function(e,r){let t=[];const n=e=>"^"===e||"*"===e||"/"===e||"%"===e||"+"===e||"-"===e;for(let i=0;i<e.length;i++){let o=e[i];if(!n(o)){t.push(o);continue}if(t.length<2)throw new Error("Invalid expression: insufficient operands");let s,a=t.pop(),f=t.pop();switch(o){case"^":s=r.power(f,a);break;case"*":s=r.multiply(f,a);break;case"/":s=r.divide(f,a);break;case"%":s=r.modulus(f,a);break;case"+":s=r.add(f,a);break;case"-":s=r.subtract(f,a)}t.push(s)}if(1!==t.length)throw new Error("Invalid expression: leftover values in stack");return t[0]}(n,t);return i}},e.externalFunctions=c,e.internalFunctions=h,e.mathOperations=t,e.variablesDB=p,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
3
|
+
|