-
Notifications
You must be signed in to change notification settings - Fork 465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated Object documentation #254
Conversation
doc/object.md
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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().
doc/object.md
Outdated
- `[in] value`: The property that is being assigned to a key. | ||
|
||
Assigns the value to the key . |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
extra space
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about
Add a property with the specified key with the specified value to the object.
doc/object.md
Outdated
void Napi::Object::Set (____ key, ____ value); | ||
``` | ||
- `[in] key`: The property that is being assigned a value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about
The name for the property being assigned.
doc/object.md
Outdated
``` | ||
- `[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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about
The value being assigned to the property
doc/object.md
Outdated
- `const char*` | ||
- `const std::string&` | ||
- `uint32_t` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
doc/object.md
Outdated
Value Napi::Object::Get(____ key); | ||
``` | ||
- `[in] key`: The property whose assigned value is being returned. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about
The name of the property to return the value for.
- `const std::string &` | ||
- `uint32_t` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should say what it returns if the property does not exist.
doc/object.md
Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about
the name of the property to check.
doc/object.md
Outdated
- `[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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
..if the object has a property name
key` and false otherwise.
|
||
```cpp | ||
PropertyLValue<std::string> Napi::Object::operator[] (const char* utf8name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some examples in the introduction which shows using these might help .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how to use these myself, do you know of any existing examples I can take a look at?
doc/object.md
Outdated
Returns an indexed property or array element as a [Value](value.md). | ||
|
||
### Example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think moving the examples up into the intro would be better and adding some that use the operators as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR-URL: #254 Reviewed-By: Michael Dawson <[email protected]>
Landed as 43ff9fa |
PR-URL: nodejs/node-addon-api#254 Reviewed-By: Michael Dawson <[email protected]>
PR-URL: nodejs/node-addon-api#254 Reviewed-By: Michael Dawson <[email protected]>
PR-URL: nodejs/node-addon-api#254 Reviewed-By: Michael Dawson <[email protected]>
PR-URL: nodejs/node-addon-api#254 Reviewed-By: Michael Dawson <[email protected]>
No description provided.