Skip to content

Commit d6ab1ae

Browse files
committed
feat: add sugar method for PropertyLValue (#1651)
1 parent b347dbe commit d6ab1ae

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

napi-inl.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,6 +1577,11 @@ inline Object::PropertyLValue<Key>& Object::PropertyLValue<Key>::operator=(
15771577
return *this;
15781578
}
15791579

1580+
template <typename Key>
1581+
inline Value Object::PropertyLValue<Key>::AsValue() const {
1582+
return Value(*this);
1583+
}
1584+
15801585
template <typename Key>
15811586
inline Object::PropertyLValue<Key>::PropertyLValue(Object object, Key key)
15821587
: _env(object.Env()), _object(object), _key(key) {}

napi.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,9 @@ class Object : public TypeTaggable {
860860
template <typename ValueType>
861861
PropertyLValue& operator=(ValueType value);
862862

863+
/// Converts an L-value to a value. For convenience.
864+
Value AsValue() const;
865+
863866
private:
864867
PropertyLValue() = delete;
865868
PropertyLValue(Object object, Key key);

0 commit comments

Comments
 (0)