feat(ext/napi): add node_api_create_object_with_named_properties#32906
Merged
bartlomieju merged 1 commit intomainfrom Mar 24, 2026
Merged
feat(ext/napi): add node_api_create_object_with_named_properties#32906bartlomieju merged 1 commit intomainfrom
bartlomieju merged 1 commit intomainfrom
Conversation
Implement `node_api_create_object_with_named_properties` which creates a JavaScript object with properties specified by C string names (UTF-8) and napi_value values. This is the "named" counterpart to the existing `node_api_create_object_with_properties` which takes napi_value keys. The function creates internalized V8 strings for the property names (enabling deduplication and faster property lookups) and constructs the object using `v8::Object::with_prototype_and_properties`. - ext/napi/js_native_api.rs — Implementation - Symbol exports — Registered in symbol_exports.json and all three platform .def files (Linux, macOS, Windows) - libs/napi_sys/src/functions.rs — FFI declaration - tests/napi/ — Native test functions and JS integration tests Closes #32595 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implement
node_api_create_object_with_named_properties— a conveniencefunction that creates a JavaScript object with properties specified by UTF-8
C string names and
napi_valuevalues.This is the "named" counterpart to the existing
node_api_create_object_with_properties(which takesnapi_valuekeys),following the same pattern as
napi_set_named_propertyvsnapi_set_property.API signature
Changes
ext/napi/js_native_api.rs— Implementation using internalized V8strings for property names (enables deduplication and faster lookups)
symbol_exports.jsonand all threeplatform
.deffileslibs/napi_sys/src/functions.rs— FFI declarationtests/napi/— Native test functions and JS integration tests coveringboth normal and empty property cases
Closes #32595
Test plan
cargo test --test integration -- napipasses (both napi_tests andfinalizer test)
🤖 Generated with Claude Code