duktape
duktape copied to clipboard
duk_put_number_list constant?
The duk_put_number_list documentation mentions: This is useful e.g. when defining numeric constants for modules or classes implemented in C.
My tests showed that the properties created with duk_put_number_list are writable.
An alternative I found to create constant module properties:
duk_push_string(ctx, "key");
duk_push_uint(ctx, 123);
duk_def_prop(ctx, -4, /* put prop in module 'exports' */
DUK_DEFPROP_HAVE_VALUE |
DUK_DEFPROP_HAVE_WRITABLE | DUK_DEFPROP_CLEAR_WRITABLE |
DUK_DEFPROP_HAVE_ENUMERABLE | DUK_DEFPROP_ENUMERABLE);
Best regards Thomas