diff options
author | ExE Boss <3889017+ExE-Boss@users.noreply.github.com> | 2021-01-18 02:30:00 +0300 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2021-01-23 06:49:04 +0300 |
commit | 3ec71143f2afe2d955936f5692dd3b615dbee46e (patch) | |
tree | 03819232ad8c71406cc010efdd66d6f843cb1758 /src/node_options.cc | |
parent | 432a5710537ec0f0a4359f5a8d7d0fede9c9b4c4 (diff) |
lib: support returning Safe collections from C++
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/36989
Refs: https://github.com/nodejs/node/pull/36652
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'src/node_options.cc')
-rw-r--r-- | src/node_options.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/node_options.cc b/src/node_options.cc index 9f59e7ee4f8..08b5fda6991 100644 --- a/src/node_options.cc +++ b/src/node_options.cc @@ -917,6 +917,12 @@ void GetOptions(const FunctionCallbackInfo<Value>& args) { }); Local<Map> options = Map::New(isolate); + if (options + ->SetPrototype(context, env->primordials_safe_map_prototype_object()) + .IsNothing()) { + return; + } + for (const auto& item : _ppop_instance.options_) { Local<Value> value; const auto& option_info = item.second; @@ -1005,6 +1011,12 @@ void GetOptions(const FunctionCallbackInfo<Value>& args) { Local<Value> aliases; if (!ToV8Value(context, _ppop_instance.aliases_).ToLocal(&aliases)) return; + if (aliases.As<Object>() + ->SetPrototype(context, env->primordials_safe_map_prototype_object()) + .IsNothing()) { + return; + } + Local<Object> ret = Object::New(isolate); if (ret->Set(context, env->options_string(), options).IsNothing() || ret->Set(context, env->aliases_string(), aliases).IsNothing()) { |