Skip to content

Commit

Permalink
doc: minor doc corrections and clarifications
Browse files Browse the repository at this point in the history
- class_property_descriptor - Contructor => Constructor
- object - returns *undefined* not NULL if key doesn't exist
- object_wrap - Contructor => Constructor
- property_descriptor - environemnt => environment

PR-URL: nodejs/node-addon-api#426
Reviewed-By: Michael Dawson <[email protected]>
Reviewed-By: NickNaso <[email protected]>
  • Loading branch information
John French committed Mar 4, 2019
1 parent cf48bf7 commit 23c549a
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 8 deletions.
4 changes: 2 additions & 2 deletions doc/class_property_descriptor.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ This prevents using descriptors from a different class when defining a new class

## Methods

### Contructor
### Constructor

Creates new instance of `Napi::ClassPropertyDescriptor` descriptor object.

Expand All @@ -33,4 +33,4 @@ Returns the original N-API `napi_property_descriptor` wrapped inside the `Napi::
operator const napi_property_descriptor&() const { return _desc; }
```
Returns the original N-API `napi_property_descriptor` wrapped inside the `Napi::ClassPropertyDescriptor`
Returns the original N-API `napi_property_descriptor` wrapped inside the `Napi::ClassPropertyDescriptor`
1 change: 0 additions & 1 deletion doc/number.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ Napi::Number Napi::Number::New(napi_env env, double value);
- `[in] env`: The `napi_env` environment in which to construct the `Napi::Number` object.
- `[in] value`: The C++ primitive from which to instantiate the `Napi::Number`.


Creates a new instance of a `Napi::Number` object.

### Int32Value
Expand Down
2 changes: 1 addition & 1 deletion doc/object.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Napi::Value Napi::Object::Get(____ key);
```
- `[in] key`: The name of the property to return the value for.

Returns the [`Napi::Value`](value.md) associated with the key property. Returns NULL if no such key exists.
Returns the [`Napi::Value`](value.md) associated with the key property. Returns the value *undefined* if the key does not exist.

The `key` can be any of the following types:
- `napi_value`
Expand Down
2 changes: 1 addition & 1 deletion doc/object_wrap.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ against the class constructor.

## Methods

### Contructor
### Constructor

Creates a new instance of a JavaScript object that wraps native instance.

Expand Down
2 changes: 1 addition & 1 deletion doc/property_descriptor.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ static Napi::PropertyDescriptor Napi::PropertyDescriptor::Function (
void *data = nullptr);
```

* `[in] env`: The environemnt in which to create this accessor.
* `[in] env`: The environment in which to create this accessor.
* `[in] name`: The name of the Callable function.
* `[in] cb`: The function
* `[in] attributes`: Potential attributes for the getter function.
Expand Down
4 changes: 2 additions & 2 deletions tools/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Here is the list of things that can be fixed easily.


### Major Reconstructions
The implementation of `Napi::ObjectWrap` is significantly different from NAN's. `Napi::ObjectWrap` takes a pointer to the wrapped object and creates a reference to the wrapped object inside ObjectWrap constructor. `Napi::ObjectWrap` also associated wrapped object's instance methods to Javascript module instead of static methods like NAN.
The implementation of `Napi::ObjectWrap` is significantly different from NAN's. `Napi::ObjectWrap` takes a pointer to the wrapped object and creates a reference to the wrapped object inside ObjectWrap constructor. `Napi::ObjectWrap` also associates wrapped object's instance methods to Javascript module instead of static methods like NAN.

So if you use Nan::ObjectWrap in your module, you will need to execute the following steps.

Expand All @@ -39,7 +39,7 @@ and define it as
...
}
```
This way, the `Napi::ObjectWrap` constructor will be invoked after the object has been instanciated and `Napi::ObjectWrap` can use the `this` pointer to create reference to the wrapped object.
This way, the `Napi::ObjectWrap` constructor will be invoked after the object has been instantiated and `Napi::ObjectWrap` can use the `this` pointer to create a reference to the wrapped object.

2. Move your original constructor code into the new constructor. Delete your original constructor.
3. In your class initialization function, associate native methods in the following way. The `&` character before methods is required because they are not static methods but instance methods.
Expand Down

0 comments on commit 23c549a

Please sign in to comment.