Skip to content

Commit

Permalink
Fixed example in addon.md. (#820)
Browse files Browse the repository at this point in the history
PR-URL: #820
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Gabriel Schulhof <[email protected]>
  • Loading branch information
nempoBu4 authored Oct 13, 2020
1 parent ceb27d4 commit 826e466
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions doc/addon.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class ExampleAddon : public Napi::Addon<ExampleAddon> {

// We can also attach plain objects to `exports`, and instance methods as
// properties of those sub-objects.
InstanceValue("subObject", DefineProperties(Napi::Object::New(), {
InstanceMethod("decrement", &ExampleAddon::Decrement
})), napi_enumerable)
InstanceValue("subObject", DefineProperties(Napi::Object::New(env), {
InstanceMethod("decrement", &ExampleAddon::Decrement)
}), napi_enumerable)
});
}
private:
Expand Down Expand Up @@ -80,7 +80,7 @@ The above code can be used from JavaScript as follows:
const exampleAddon = require('bindings')('example_addon');
console.log(exampleAddon.increment()); // prints 43
console.log(exampleAddon.increment()); // prints 44
consnole.log(exampleAddon.subObject.decrement()); // prints 43
console.log(exampleAddon.subObject.decrement()); // prints 43
```

When Node.js loads an instance of the add-on, a new instance of the class is
Expand Down

0 comments on commit 826e466

Please sign in to comment.