Skip to content

Add a normal method to convert PropertyLValue into Value #1651

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; }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions