som-exp-sdk
Version:
Evaluate the User Expression
28 lines (27 loc) • 885 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseExpression = void 0;
class BaseExpression {
constructor() {
this.evaluateExpression = (expression) => {
let output;
try {
if (expression) {
console.log(`User input to be evaluated is: ${expression}`);
output = eval(expression);
}
}
catch (e) {
console.log(`Error while evaluating the expression. Error is ${e}`);
}
return output;
};
this.removeSpaces = (inputStr) => {
return !!inputStr ? (inputStr.split(" ").join("")) : "";
};
this.wrapInSpace = (inputStr) => {
return !!inputStr ? (` ${inputStr} `) : "";
};
}
}
exports.BaseExpression = BaseExpression;