mirror of
https://github.com/bellard/quickjs.git
synced 2025-05-15 18:52:00 +08:00
flush stdout in console.log() (#309)
This commit is contained in:
parent
159fe289e3
commit
00b709dfff
@ -3825,6 +3825,15 @@ static JSValue js_print(JSContext *ctx, JSValueConst this_val,
|
|||||||
return JS_UNDEFINED;
|
return JS_UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static JSValue js_console_log(JSContext *ctx, JSValueConst this_val,
|
||||||
|
int argc, JSValueConst *argv)
|
||||||
|
{
|
||||||
|
JSValue ret;
|
||||||
|
ret = js_print(ctx, this_val, argc, argv);
|
||||||
|
fflush(stdout);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
void js_std_add_helpers(JSContext *ctx, int argc, char **argv)
|
void js_std_add_helpers(JSContext *ctx, int argc, char **argv)
|
||||||
{
|
{
|
||||||
JSValue global_obj, console, args;
|
JSValue global_obj, console, args;
|
||||||
@ -3835,7 +3844,7 @@ void js_std_add_helpers(JSContext *ctx, int argc, char **argv)
|
|||||||
|
|
||||||
console = JS_NewObject(ctx);
|
console = JS_NewObject(ctx);
|
||||||
JS_SetPropertyStr(ctx, console, "log",
|
JS_SetPropertyStr(ctx, console, "log",
|
||||||
JS_NewCFunction(ctx, js_print, "log", 1));
|
JS_NewCFunction(ctx, js_console_log, "log", 1));
|
||||||
JS_SetPropertyStr(ctx, global_obj, "console", console);
|
JS_SetPropertyStr(ctx, global_obj, "console", console);
|
||||||
|
|
||||||
/* same methods as the mozilla JS shell */
|
/* same methods as the mozilla JS shell */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user