Skip to content

Commit

Permalink
Fixed example in addon.md. (#820)
Browse files Browse the repository at this point in the history
PR-URL: nodejs/node-addon-api#820
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: Gabriel Schulhof <[email protected]>
  • Loading branch information
kevindavies8 committed Oct 13, 2020
1 parent 2a65eb9 commit 316e909
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 316e909

Please sign in to comment.