Property key filter API (#4311)
Co-authored-by: Robert Fancsik <frobert@inf.u-szeged.hu> JerryScript-DCO-1.0-Signed-off-by: Daniel Balla dballa@inf.u-szeged.hu
This commit is contained in:
@@ -80,6 +80,22 @@ Enum that contains JerryScript **iterator** value types:
|
||||
|
||||
*New in version [[NEXT_RELEASE]]*.
|
||||
|
||||
## jerry_property_filter_t
|
||||
|
||||
Enum that contains JerryScript **property filter** options bits:
|
||||
|
||||
- JERRY_PROPERTY_FILTER_ALL - List all property keys independently from key type or property value attributes (equivalent to Reflect.ownKeys call)
|
||||
- JERRY_PROPERTY_FILTER_TRAVERSE_PROTOTYPE_CHAIN - Include keys from the objects's prototype chain as well
|
||||
- JERRY_PROPERTY_FILTER_EXLCUDE_NON_CONFIGURABLE - Exclude property key if the property is non-configurable
|
||||
- JERRY_PROPERTY_FILTER_EXLCUDE_NON_ENUMERABLE - Exclude property key if the property is non-enumerable
|
||||
- JERRY_PROPERTY_FILTER_EXLCUDE_NON_WRITABLE - Exclude property key if the property is non-writable
|
||||
- JERRY_PROPERTY_FILTER_EXLCUDE_STRINGS - Exclude property key if it is a string
|
||||
- JERRY_PROPERTY_FILTER_EXLCUDE_SYMBOLS - Exclude property key if it is a symbol
|
||||
- JERRY_PROPERTY_FILTER_EXLCUDE_INTEGER_INDICES - Exclude property key if it is an integer index
|
||||
- JERRY_PROPERTY_FILTER_INTEGER_INDICES_AS_NUMBER - By default integer index property keys are converted to string. Enabling this flags keeps integer index property keys as numbers
|
||||
|
||||
*New in version [[NEXT_RELEASE]]*.
|
||||
|
||||
## jerry_error_t
|
||||
|
||||
Possible types of an error:
|
||||
@@ -7263,6 +7279,44 @@ best-practice example.
|
||||
- [jerry_object_native_info_t](#jerry_object_native_info_t)
|
||||
|
||||
|
||||
## jerry_object_get_property_names
|
||||
|
||||
**Summary**
|
||||
|
||||
Gets the property keys for the given object using the selected filters.
|
||||
|
||||
**Prototype**
|
||||
|
||||
```c
|
||||
jerry_value_t
|
||||
jerry_object_get_property_names (jerry_value_t obj_val,
|
||||
jerry_property_filter_t filter);
|
||||
```
|
||||
|
||||
- `obj_val` - object value
|
||||
- `filter` - any combination of [jerry_property_filter_t](#jerry_property_filter_t) options
|
||||
- return value
|
||||
- array containing the filtered property keys in successful operation
|
||||
- error marked with error flag, otherwise
|
||||
|
||||
**Example**
|
||||
|
||||
```c
|
||||
{
|
||||
jerry_value_t global_object = jerry_get_global_object ();
|
||||
jerry_value_t keys = jerry_object_get_property_names (object, JERRY_PROPERTY_FILTER_ALL);
|
||||
|
||||
... // usage of keys
|
||||
|
||||
jerry_release_value (keys);
|
||||
jerry_release_value (global_object);
|
||||
}
|
||||
```
|
||||
|
||||
**See also**
|
||||
|
||||
- [jerry_property_filter_t](#jerry_property_filter_t)
|
||||
|
||||
## jerry_foreach_object_property
|
||||
|
||||
**Summary**
|
||||
|
||||
Reference in New Issue
Block a user