From cae71ed8416cba63a2be8c9068b3a3e0b148a32a Mon Sep 17 00:00:00 2001 From: Yoshiya Hinosawa Date: Mon, 7 Jan 2019 06:34:52 +0900 Subject: Implement console.groupCollapsed (#1452) This implementation of groupCollapsed is intentionally different from the spec defined by whatwg. See the conversation in #1355 and #1363. --- libdeno/binding.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'libdeno/binding.cc') diff --git a/libdeno/binding.cc b/libdeno/binding.cc index da3ce198d..cbeeee1e9 100644 --- a/libdeno/binding.cc +++ b/libdeno/binding.cc @@ -191,7 +191,7 @@ void PromiseRejectCallback(v8::PromiseRejectMessage promise_reject_message) { void Print(const v8::FunctionCallbackInfo& args) { CHECK_GE(args.Length(), 1); - CHECK_LE(args.Length(), 2); + CHECK_LE(args.Length(), 3); auto* isolate = args.GetIsolate(); DenoIsolate* d = FromIsolate(isolate); auto context = d->context_.Get(d->isolate_); @@ -199,9 +199,13 @@ void Print(const v8::FunctionCallbackInfo& args) { v8::String::Utf8Value str(isolate, args[0]); bool is_err = args.Length() >= 2 ? args[1]->BooleanValue(context).ToChecked() : false; + bool prints_newline = + args.Length() >= 3 ? args[2]->BooleanValue(context).ToChecked() : true; FILE* file = is_err ? stderr : stdout; fwrite(*str, sizeof(**str), str.length(), file); - fprintf(file, "\n"); + if (prints_newline) { + fprintf(file, "\n"); + } fflush(file); } -- cgit v1.2.3