Skip to content

Add a normal method to convert PropertyLValue into Value #1651

Open
@neko-para

Description

@neko-para

Currently, a PropertyLValue can only be converted into Value via the type convertion.

// cast into var
Napi::Value val = obj["key"];
val.ToString();

// explicit cast
Napi::Value(obj["key"]).ToString();

It‘s fairly common to directly use it as a value, but the methods above are quite annoying. The first one needs to name the value, and the second one needs to move the cursor back. Thus I'd suggest adding a helper function behaves like the converter.

demo usage

obj["key"].value().ToString();

possible impl

Value value() const { return *this; }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions