Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple parameters to FunctionCallOperator, suggestion that the space should be optional #13

Open
jcalfee opened this issue May 15, 2022 · 1 comment

Comments

@jcalfee
Copy link

jcalfee commented May 15, 2022

In FunctionCallOperator I am looking to support multiple arguments. Adding a console log shows the function is being called twice (strange) and the second time the second argument is undefined (bug?).

> meval('Spread(4,2)', { Spread: function(a, b){return [a, b]} })
[ 4 ]
[ 4, undefined ]

FunctionCallOperator

  execute (context, myIndex, entities) {
    console.log(this.args) // !!
    let prevIndex = myIndex - 1;
    let leftSide = this.resolveSide(entities[prevIndex], context);
    let result = leftSide.apply(null, this.args);

    entities.splice(prevIndex, 2, result);
  }

Also, seems like the spread operator should work since that is outside of the parser:

> meval('Spread(4,2)', { Spread: function(...args){return args} })
[ 4 ]
[ 4 ]

Also here:

> meval('Math.max(2,4)', {})
[ 2 ]
2
@jcalfee
Copy link
Author

jcalfee commented May 15, 2022

I see .. Everything works above if I put a after each comma. So, Math.max(2, 4) works but Math.max(2,4) does not.

@jcalfee jcalfee changed the title Multiple parameters to FunctionCallOperator Multiple parameters to FunctionCallOperator, suggestion that the space should be optional May 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant