Parsify uses math.js parser, so you can easily add and modify variables and functions.
In order to gain access to the parser, use it as the first argument:
export default parser => async expression => {// ...};
If you are using TypeScript, install @parsify/math
as a devDependency and import the Parser
interface.
You can then use the parser according to the math.js documentation:
// Set a new variableparser.set('myVariable', 500);parser.get('myVariable');parser.remove('myVariable');// Create a functionparser.set('hello', name => {return `hello, ${name}!`;});/*Remove all functions & variablesNOTE: this will not only remove things created by your plugin, so use it carefully.*/parser.clear()