You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
1.1 KiB

=proto
int duk_next(duk_context *ctx, int enum_index, int get_value);
=stack
[ ... enum! ... ] -> [ ... enum! ... ] (if enum empty; function returns zero)
[ ... enum! ... ] -> [ ... enum! ... key! ] (if enum not empty and get_value == 0; function returns non-zero)
[ ... enum! ... ] -> [ ... enum! ... key! value! ] (if enum not empty and get_value != 0; function returns non-zero)
=summary
<p>Get the next key (and optionally value) from an enumerator created with
<tt><a href="#duk_enum">duk_enum()</a></tt>. If the enumeration has been
exhausted, nothing is pushed to the stack and the function returns zero.
Otherwise the key is pushed to the stack, followed by the value if
<tt>get_value</tt> is non-zero, and the function returns non-zero.
</p>
<p>Note that getting the value may invoke a getter which may have arbitrary
side effects (and may throw an error).</p>
=example
while (duk_next(ctx, enum_idx, 1)) {
printf("key=%s, value=%s\n", duk_to_string(ctx, -2), duk_to_string(ctx, -1));
duk_pop_2(ctx);
}
=tags
object
property
=seealso
duk_enum