fparse
fparse copied to clipboard
Using objects as values
It would be useful to allow passing object values into formula to process inside custom functions.
Example:
const fObj = new Formula()
fObj.distance = (point1, point2) => Math.sqrt(Math.pow(point1.x - point2.x, 2) + Math.pow(point1.y - point2.y, 2))
fObj.setFormula('distance(x,y)')
console.log(fObj.evaluate({ x: { 1, 3 }, y: { 4, 5 } }))
The example is simplified. Points can be N-dimentional etc.