diff --git a/doc/api/n-api.md b/doc/api/n-api.md index db43ee18affaf4..22fe991142f850 100644 --- a/doc/api/n-api.md +++ b/doc/api/n-api.md @@ -3731,6 +3731,12 @@ if (status != napi_ok) return status; ### Structures #### napi_property_attributes + ```c typedef enum { @@ -3742,6 +3748,14 @@ typedef enum { // Used with napi_define_class to distinguish static properties // from instance properties. Ignored by napi_define_properties. napi_static = 1 << 10, + + // Default for class methods. + napi_default_method = napi_writable | napi_configurable, + + // Default for object properties, like in JS obj[prop]. + napi_default_property = napi_writable | + napi_enumerable | + napi_configurable, } napi_property_attributes; ``` @@ -3760,6 +3774,10 @@ They can be one or more of the following bitflags: * `napi_static`: The property will be defined as a static property on a class as opposed to an instance property, which is the default. This is used only by [`napi_define_class`][]. It is ignored by `napi_define_properties`. +* `napi_default_method`: The property is configureable, writeable but not + enumerable like a method in a JS class. +* `napi_default_property`: The property is writable, enumerable and configurable + like a property set via JS code `obj.key = value`. #### napi_property_descriptor diff --git a/src/js_native_api_types.h b/src/js_native_api_types.h index 115ccebf26132e..7011c80e671a15 100644 --- a/src/js_native_api_types.h +++ b/src/js_native_api_types.h @@ -30,6 +30,16 @@ typedef enum { // Used with napi_define_class to distinguish static properties // from instance properties. Ignored by napi_define_properties. napi_static = 1 << 10, + +#ifdef NAPI_EXPERIMENTAL + // Default for class methods. + napi_default_method = napi_writable | napi_configurable, + + // Default for object properties, like in JS obj[prop]. + napi_default_jsproperty = napi_writable | + napi_enumerable | + napi_configurable, +#endif // NAPI_EXPERIMENTAL } napi_property_attributes; typedef enum {