File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -75,8 +75,8 @@ Creates a new `Napi::Object` value.
7575Napi::Object Napi::Object::New (
7676 napi_env env,
7777 napi_value prototypeOrNull,
78- std::vector<napi_value>& propertyNames,
79- std::vector<napi_value>& propertyValues);
78+ const std::vector<napi_value>& propertyNames,
79+ const std::vector<napi_value>& propertyValues);
8080```
8181- `[in] env`: The `napi_env` environment in which to construct the `Napi::Value`
8282 object.
Original file line number Diff line number Diff line change @@ -1644,22 +1644,24 @@ inline Object Object::New(napi_env env) {
16441644#ifdef NODE_API_EXPERIMENTAL_HAS_CREATE_OBJECT_WITH_PROPERTIES
16451645inline Object Object::New (napi_env env,
16461646 napi_value prototypeOrNull,
1647- std::vector<napi_value>& propertyNames,
1648- std::vector<napi_value>& propertyValues) {
1647+ const std::vector<napi_value>& propertyNames,
1648+ const std::vector<napi_value>& propertyValues) {
16491649 if (propertyNames.size () != propertyValues.size ()) {
16501650 NAPI_THROW (
16511651 Napi::Error::New (env, " Mismatch in size of property names and values" ),
16521652 Object ());
16531653 }
16541654
16551655 napi_value value;
1656- napi_status status =
1657- node_api_create_object_with_properties (env,
1658- prototypeOrNull,
1659- propertyNames.data (),
1660- propertyValues.data (),
1661- propertyNames.size (),
1662- &value);
1656+ // TODO(@KevinEady): remove const_cast when
1657+ // https://github.com/nodejs/node/pull/65621 is fully backported.
1658+ napi_status status = node_api_create_object_with_properties (
1659+ env,
1660+ prototypeOrNull,
1661+ const_cast <napi_value*>(propertyNames.data ()),
1662+ const_cast <napi_value*>(propertyValues.data ()),
1663+ propertyNames.size (),
1664+ &value);
16631665
16641666 NAPI_THROW_IF_FAILED (env, status, Object ());
16651667 return Object (env, value);
Original file line number Diff line number Diff line change @@ -955,8 +955,8 @@ class Object : public TypeTaggable {
955955 static Object New (
956956 napi_env env, // /< Node-API environment
957957 napi_value prototypeOrNull, // /< Prototype (Object) or null / empty Value
958- std::vector<napi_value>& propertyNames, // /< Property names
959- std::vector<napi_value>& propertyValues // /< Property values
958+ const std::vector<napi_value>& propertyNames, // /< Property names
959+ const std::vector<napi_value>& propertyValues // /< Property values
960960 );
961961#endif
962962
You can’t perform that action at this time.
0 commit comments