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

Add API for deletion of object properties #151

Closed
wants to merge 3 commits into from
Closed

Add API for deletion of object properties #151

wants to merge 3 commits into from

Conversation

rolftimmermans
Copy link
Contributor

An API that uses napi_delete_property was missing.

This adds a few overloaded Object::Delete() methods that remove a given property.

/// Delete property.
bool Delete(
Value key ///< Property key
);
Copy link
Member

Choose a reason for hiding this comment

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

I don’t think we need this key since Value has an operator napi_value member, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed I guess so; I just copied the definitions from Object::Has. Should I remove all of them?

Copy link
Member

Choose a reason for hiding this comment

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

I think I had to add the overloads that take Value in order to avoid compiler errors in some situations about ambiguous calls to overloaded methods.

Copy link
Member

Choose a reason for hiding this comment

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

@jasongin I think it should be safe to remove those – if you’re talking about #86, that’s happening because there were two multiple arguments that were used for overloading …

@rolftimmermans I’m not sure, but it certainly doesn’t have to happen in this PR :)

Copy link
Member

Choose a reason for hiding this comment

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

Oh, wait, maybe that is about Strings that also have an operator std::string? That would make sense but we should have tests for that :)

Copy link
Member

@jasongin jasongin left a comment

Choose a reason for hiding this comment

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

There should be a Delete() overload that takes a uint32_t index, that corresponds to napi_delete_element().

@rolftimmermans
Copy link
Contributor Author

@jasongin Done – I couldn't find any tests though, is that correct?

@jasongin
Copy link
Member

jasongin commented Oct 2, 2017

@rolftimmermans Test coverage is not great right now but you are welcome to contribute to improving it!

@mhdawson
Copy link
Member

mhdawson commented Oct 3, 2017

@rolftimmermans the tests are in https://github.com/nodejs/node-addon-api/tree/master/test and you can run them with npm test.

At some point we should require tests for any new APIs' but as @jasongin mentions we don't have great coverage yet so at this point it would be nice but not required.

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 I see you already found the tests.

mhdawson pushed a commit that referenced this pull request Oct 3, 2017
PR-URL: #151
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jason Ginchereau <jasongin@microsoft.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
@mhdawson
Copy link
Member

mhdawson commented Oct 3, 2017

Landed as b1c4cb9

@mhdawson mhdawson closed this Oct 3, 2017
kevindavies8 added a commit to kevindavies8/node-addon-api-Develop that referenced this pull request Aug 24, 2022
PR-URL: nodejs/node-addon-api#151
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jason Ginchereau <jasongin@microsoft.com>
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#151
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jason Ginchereau <jasongin@microsoft.com>
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#151
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jason Ginchereau <jasongin@microsoft.com>
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#151
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jason Ginchereau <jasongin@microsoft.com>
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.

4 participants