You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Map object type seems to be missing from the bindings.
Given it requires the use of new to be instantiated (just like e.g. Promise), I guess it should be exposed in those bindings.
I'm currently trying to create an instance of Map with the bindings, but it seems rather complex since using new requires to to use the napi unsafe api... is there something I've missed here ?
My current solution is to use the eval function to create the Map, which is a bit wasteful ^^
let new_map_code = cx.string("(function() { return new Map(); })");let js_map = neon::reflect::eval(cx, new_map_code)?.downcast_or_throw::<JsObject,_>(cx)?;
So would you accept a PR to add Map in the bindings ?
The text was updated successfully, but these errors were encountered:
This would be a great addition and I would be open to merging it as a feature. We tend to limit our features to those that are available through the Node-API and map is not (Promise is). With that said, Map is a global and we already have the utilities to construct globals.
let map = cx.global::<JsFunction>("Map")?
.construct_with(&cx).apply::<JsObject,_>(&mut cx)?;
We could have a JsMap type by checking instanceof of checks. Unfortunately, because there aren't Node-API bindings, we would still need to do property lookups in order to invoke methods.
It's all possible, just going to be a bit heavy on the FFI cost.
The Map object type seems to be missing from the bindings.
Given it requires the use of
new
to be instantiated (just like e.g. Promise), I guess it should be exposed in those bindings.I'm currently trying to create an instance of
Map
with the bindings, but it seems rather complex since using new requires to to use the napi unsafe api... is there something I've missed here ?My current solution is to use the eval function to create the Map, which is a bit wasteful ^^
So would you accept a PR to add Map in the bindings ?
The text was updated successfully, but these errors were encountered: