Skip to content
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

Closed
wants to merge 5 commits into from
Closed

Conversation

anisha-rohra
Copy link

No description provided.

doc/object.md Outdated
Object is a Javascript object value. A common usecase is to assign many values to a single object.

Copy link
Member

@mhdawson mhdawson May 1, 2018

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:

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 .
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra space

Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

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`
Copy link
Member

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.
Copy link
Member

@mhdawson mhdawson May 1, 2018

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`

Copy link
Member

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.
Copy link
Member

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.
Copy link
Member

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);
Copy link
Member

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 .

Copy link
Author

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
Copy link
Member

@mhdawson mhdawson May 1, 2018

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.

Copy link
Member

@mhdawson mhdawson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

mhdawson pushed a commit that referenced this pull request May 30, 2018
PR-URL: #254
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
@mhdawson
Copy link
Member

Landed as 43ff9fa

@mhdawson mhdawson closed this May 30, 2018
kevindavies8 added a commit to kevindavies8/node-addon-api-Develop that referenced this pull request Aug 24, 2022
PR-URL: nodejs/node-addon-api#254
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Marlyfleitas added a commit to Marlyfleitas/node-api-addon-Development that referenced this pull request Aug 26, 2022
PR-URL: nodejs/node-addon-api#254
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
wroy7860 added a commit to wroy7860/addon-api-benchmark-node that referenced this pull request Sep 19, 2022
PR-URL: nodejs/node-addon-api#254
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
johnfrench3 pushed a commit to johnfrench3/node-addon-api-git that referenced this pull request Aug 11, 2023
PR-URL: nodejs/node-addon-api#254
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants