mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 11:07:35 +00:00
LibJS: Use Stream::format instead of manually formating and printing
This commit is contained in:
parent
6f6d6c654d
commit
fac7045a44
1 changed files with 2 additions and 7 deletions
|
@ -140,15 +140,10 @@ DeprecatedString strip_ansi(StringView format_string)
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
ErrorOr<void> js_out(JS::PrintContext& print_context, CheckedFormatString<Args...> format_string, Args const&... args)
|
ErrorOr<void> js_out(JS::PrintContext& print_context, CheckedFormatString<Args...> format_string, Args const&... args)
|
||||||
{
|
{
|
||||||
DeprecatedString formatted;
|
|
||||||
if (print_context.strip_ansi)
|
if (print_context.strip_ansi)
|
||||||
formatted = DeprecatedString::formatted(strip_ansi(format_string.view()), args...);
|
TRY(print_context.stream.format(strip_ansi(format_string.view()), args...));
|
||||||
else
|
else
|
||||||
formatted = DeprecatedString::formatted(format_string.view(), args...);
|
TRY(print_context.stream.format(format_string.view(), args...));
|
||||||
|
|
||||||
auto bytes = formatted.bytes();
|
|
||||||
while (!bytes.is_empty())
|
|
||||||
bytes = bytes.slice(TRY(print_context.stream.write_some(bytes)));
|
|
||||||
|
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue