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
Is your feature request related to a problem? Please describe. napi_create_reference puts a constraint on the value type that the reference can be created on. Currently only object or function (non-primitive types) are allowed. This should be okay-ish in most cases for undefined, null, boolean, string, number, and bigint, we can convert those primitive values to a native representative to keep a "reference" to their values. But this is not the case for symbols, as they are unique values and there is no means to convert them to native values. As such, we can not prevent the symbol values to be GC'ed on the native side.
Describe the solution you'd like
There is a TC39 stage 2 proposal Symbols as WeakMap keys that intends to loosen the constraint on WeakMap keys to allow symbol values. The goal of WeakMap is to have unique values that can be eventually GC'ed. Similarly, the values to be referenced in napi_create_reference have to be unique values and can be eventually GC'ed. Allowing symbols in this case will be helpful to managing those unique values on the native side.
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
napi_create_reference
puts a constraint on the value type that the reference can be created on. Currently onlyobject
orfunction
(non-primitive types) are allowed. This should be okay-ish in most cases forundefined
,null
,boolean
,string
,number
, andbigint
, we can convert those primitive values to a native representative to keep a "reference" to their values. But this is not the case forsymbol
s, as they are unique values and there is no means to convert them to native values. As such, we can not prevent thesymbol
values to be GC'ed on the native side.Describe the solution you'd like
There is a TC39 stage 2 proposal Symbols as WeakMap keys that intends to loosen the constraint on
WeakMap
keys to allowsymbol
values. The goal ofWeakMap
is to have unique values that can be eventually GC'ed. Similarly, the values to be referenced innapi_create_reference
have to be unique values and can be eventually GC'ed. Allowing symbols in this case will be helpful to managing those unique values on the native side.The text was updated successfully, but these errors were encountered: