-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
n-api: add napi_delete_property() #13934
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
Conversation
|
@mhdawson I changed the function signature slightly. I added a return value because |
src/node_api.cc
Outdated
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.
Check that result is not null before assigning to it. Some callers may not care about the result, so allow them to pass null to ignore it.
src/node_api.cc
Outdated
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.
NAPI_PREAMBLE(env) already calls CHECK_ENV(env), so the latter is redundant here.
doc/api/n-api.md
Outdated
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.
Mention result is optional.
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 once @jasongin's comments are addressed.
|
Comments addressed. |
doc/api/n-api.md
Outdated
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.
Can key be a napi number? Either way it's fine but just thought that it could be helpful to point that out in the docs.
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 found this section in the documentation that provides some blanket statements for all of the methods for working with properties. Specifically, see:
JavaScript value: these are represented in N-API by napi_value. This can be a napi_value representing a String, Number or Symbol.
Given that, and the surrounding documentation, I'd prefer to keep this as is in this PR. However, I think the n-api documentation as a whole should be made more consistent with the rest of the Node docs. For example, I think each method should document that key can be a number, string, or symbol. That way, users don't have to read the entire page/section/whatever to get that information.
test/addons-napi/test_object/test.js
Outdated
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.
why not just assert('foo' in obj)?
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.
No specific reason. Just being more explicit.
Fixes: nodejs#13924 PR-URL: nodejs#13934 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Jason Ginchereau <[email protected]>
Fixes: nodejs#13924 PR-URL: nodejs#13934 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Jason Ginchereau <[email protected]>
Fixes: #13924 PR-URL: #13934 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Jason Ginchereau <[email protected]>
Fixes: #13924 PR-URL: #13934 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Jason Ginchereau <[email protected]>
Fixes: nodejs#13924 PR-URL: nodejs#13934 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Jason Ginchereau <[email protected]>
Fixes: #13924 Backport-PR-URL: #19447 PR-URL: #13934 Reviewed-By: Michael Dawson <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Jason Ginchereau <[email protected]>
Refs: #13924
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesAffected core subsystem(s)
n-api