]> git.kaiwu.me - njs.git/commitdiff
Added njs_vm_object_keys().
authorDmitry Volyntsev <xeioex@nginx.com>
Mon, 11 Jan 2021 19:53:10 +0000 (19:53 +0000)
committerDmitry Volyntsev <xeioex@nginx.com>
Mon, 11 Jan 2021 19:53:10 +0000 (19:53 +0000)
src/njs.h
src/njs_vm.c

index 1e4963f467eb02f1396af394cf2f8ae6463e0eb8..39b68fb29901757e39fdb1996f0283e9a8e1d7b2 100644 (file)
--- a/src/njs.h
+++ b/src/njs.h
@@ -402,6 +402,8 @@ NJS_EXPORT njs_int_t njs_value_is_buffer(const njs_value_t *value);
 
 NJS_EXPORT njs_int_t njs_vm_object_alloc(njs_vm_t *vm, njs_value_t *retval,
     ...);
+NJS_EXPORT njs_value_t *njs_vm_object_keys(njs_vm_t *vm, njs_value_t *value,
+    njs_value_t *retval);
 NJS_EXPORT njs_value_t *njs_vm_object_prop(njs_vm_t *vm,
     njs_value_t *value, const njs_str_t *key, njs_opaque_value_t *retval);
 
index 0277ff3a66c2ca55b7072daf54e970b5b3895b79..bb6018ce3ce768c022acfa52b7e912b77d6570d8 100644 (file)
@@ -976,6 +976,23 @@ done:
 }
 
 
+njs_value_t *
+njs_vm_object_keys(njs_vm_t *vm, njs_value_t *value, njs_value_t *retval)
+{
+    njs_array_t  *keys;
+
+    keys = njs_value_own_enumerate(vm, value, NJS_ENUM_KEYS,
+                                   NJS_ENUM_STRING, 0);
+    if (njs_slow_path(keys == NULL)) {
+        return NULL;
+    }
+
+    njs_set_array(retval, keys);
+
+    return retval;
+}
+
+
 njs_int_t
 njs_vm_array_alloc(njs_vm_t *vm, njs_value_t *retval, uint32_t spare)
 {