Skip to content

Commit 7423cc5

Browse files
Update object_wrap.md (#1094)
* Update object_wrap.md Add the default attributes for methods to the example to make them writeable by default. See #811 for discussion.
1 parent 5aab27e commit 7423cc5

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

doc/object_wrap.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ class Example : public Napi::ObjectWrap<Example> {
3636
Napi::Object Example::Init(Napi::Env env, Napi::Object exports) {
3737
// This method is used to hook the accessor and method callbacks
3838
Napi::Function func = DefineClass(env, "Example", {
39-
InstanceMethod<&Example::GetValue>("GetValue"),
40-
InstanceMethod<&Example::SetValue>("SetValue"),
41-
StaticMethod<&Example::CreateNewItem>("CreateNewItem"),
39+
InstanceMethod<&Example::GetValue>("GetValue", static_cast<napi_property_attributes>(napi_writable | napi_configurable)),
40+
InstanceMethod<&Example::SetValue>("SetValue", static_cast<napi_property_attributes>(napi_writable | napi_configurable)),
41+
StaticMethod<&Example::CreateNewItem>("CreateNewItem", static_cast<napi_property_attributes>(napi_writable | napi_configurable)),
4242
});
4343

4444
Napi::FunctionReference* constructor = new Napi::FunctionReference();

0 commit comments

Comments
 (0)