Skip to content

Using objects as values #58

@structinfo

Description

@structinfo

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions