Skip to content

Customize coercion rules for HostObjects with valueOf #358

Open
@zoryn

Description

@zoryn

Currently HostObjects that are not primitive types are always coerced to a string in JStoPrimitiveNode.java.
Is there any way to customize this behavior to coerce HostObject into a number? I have a host object which is a number with optional annotations. I want to be able to use it in arithmetic operations in JS code. Ability to specify equivalent of valueOf function for HostObject will be useful in this scenario. This cab be implemented as a new Proxy interface with valueOf method.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions