summaryrefslogtreecommitdiff
path: root/quickjs-libc.c
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2025-04-07 14:33:30 +0200
committerFabrice Bellard <fabrice@bellard.org>2025-04-07 14:33:30 +0200
commitf05760c585f7744dcf3c0f47bfe1bd038a4d4f15 (patch)
tree207c952f72196e94ee1044b4f879109819d69f80 /quickjs-libc.c
parent2b6cf578af214f3e80777446e5bfa4be53734e74 (diff)
downloadquickjs-f05760c585f7744dcf3c0f47bfe1bd038a4d4f15.tar.gz
quickjs-f05760c585f7744dcf3c0f47bfe1bd038a4d4f15.zip
qjs: added performance.now()
Diffstat (limited to 'quickjs-libc.c')
-rw-r--r--quickjs-libc.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/quickjs-libc.c b/quickjs-libc.c
index a659084..2c71132 100644
--- a/quickjs-libc.c
+++ b/quickjs-libc.c
@@ -3836,7 +3836,7 @@ static JSValue js_console_log(JSContext *ctx, JSValueConst this_val,
void js_std_add_helpers(JSContext *ctx, int argc, char **argv)
{
- JSValue global_obj, console, args;
+ JSValue global_obj, console, args, performance;
int i;
/* XXX: should these global definitions be enumerable? */
@@ -3847,6 +3847,11 @@ void js_std_add_helpers(JSContext *ctx, int argc, char **argv)
JS_NewCFunction(ctx, js_console_log, "log", 1));
JS_SetPropertyStr(ctx, global_obj, "console", console);
+ performance = JS_NewObject(ctx);
+ JS_SetPropertyStr(ctx, performance, "now",
+ JS_NewCFunction(ctx, js_os_now, "now", 0));
+ JS_SetPropertyStr(ctx, global_obj, "performance", performance);
+
/* same methods as the mozilla JS shell */
if (argc >= 0) {
args = JS_NewArray(ctx);