Conversation
| if you don't find what you need please refer to: | ||
| [C++ wrapper classes for the ABI-stable C APIs for Node.js](https://nodejs.github.io/node-addon-api/) No newline at end of file | ||
| Object is a Javascript object value. A common usecase is to assign many values to a single object. | ||
|
|
There was a problem hiding this comment.
My suggestion for the intro would be:
The Object class corresponds to a JavaScript object. It is extended by following node-addon-api classes that you may use when working with more specific types:
- Value and extends Array
- ArrayBuffer
- Buffer, Function,
- TypedArray.
This class provides a number of convenience methods, most of which are used to set or set properties on a JavaScript object. For example, Set() and Get().
| - `[in] key`: The property that is being assigned a value. | ||
| - `[in] value`: The property that is being assigned to a key. | ||
|
|
||
| Assigns the value to the key . |
There was a problem hiding this comment.
How about
Add a property with the specified key with the specified value to the object.
| ```cpp | ||
| void Napi::Object::Set (____ key, ____ value); | ||
| ``` | ||
| - `[in] key`: The property that is being assigned a value. |
There was a problem hiding this comment.
How about
The name for the property being assigned.
| void Napi::Object::Set (____ key, ____ value); | ||
| ``` | ||
| - `[in] key`: The property that is being assigned a value. | ||
| - `[in] value`: The property that is being assigned to a key. |
There was a problem hiding this comment.
How about
The value being assigned to the property
| Alternatively, the key can be any of the following types: | ||
| - `const char*` | ||
| - `const std::string&` | ||
| - `uint32_t` |
There was a problem hiding this comment.
This part I find a bit confusing. I might be easier to just say key's can be of the following types, and values can be of the following types.
| ```cpp | ||
| Value Napi::Object::Get(____ key); | ||
| ``` | ||
| - `[in] key`: The property whose assigned value is being returned. |
There was a problem hiding this comment.
How about
The name of the property to return the value for.
| - `const char *` | ||
| - `const std::string &` | ||
| - `uint32_t` | ||
|
|
There was a problem hiding this comment.
We should say what it returns if the property does not exist.
| ```cpp | ||
| bool Napi::Object::Has (____ key) const; | ||
| ``` | ||
| - `[in] key`: The property that is being checked for having an assigned value. |
There was a problem hiding this comment.
How about
the name of the property to check.
| ``` | ||
| - `[in] key`: The property that is being checked for having an assigned value. | ||
|
|
||
| Returns a `bool` that is *true* if the `key` has a value property associated with it and *false* otherwise. |
There was a problem hiding this comment.
..if the object has a property name key` and false otherwise.
| ### Operator[]() | ||
|
|
||
| ```cpp | ||
| PropertyLValue<std::string> Napi::Object::operator[] (const char* utf8name); |
There was a problem hiding this comment.
Some examples in the introduction which shows using these might help .
There was a problem hiding this comment.
Not sure how to use these myself, do you know of any existing examples I can take a look at?
|
|
||
| Returns an indexed property or array element as a [Value](value.md). | ||
|
|
||
| ### Example |
There was a problem hiding this comment.
I think moving the examples up into the intro would be better and adding some that use the operators as well.
PR-URL: #254 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
|
Landed as 43ff9fa |
PR-URL: nodejs/node-addon-api#254 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
PR-URL: nodejs/node-addon-api#254 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
PR-URL: nodejs/node-addon-api#254 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
PR-URL: nodejs/node-addon-api#254 Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
No description provided.