1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:37:35 +00:00

LibJS: Use String::join and String::trim in Temporal AOs

This commit is contained in:
Timothy Flynn 2023-01-27 14:38:48 -05:00 committed by Linus Groh
parent c59268d15b
commit 9e4dbea0ee
2 changed files with 7 additions and 6 deletions

View file

@ -853,8 +853,7 @@ ThrowCompletionOr<String> format_seconds_string_part(VM& vm, u8 second, u16 mill
fraction_string = TRY_OR_THROW_OOM(vm, String::formatted("{:09}", fraction));
// c. Set fraction to the longest possible substring of fraction starting at position 0 and not ending with the code unit 0x0030 (DIGIT ZERO).
// FIXME: Add String::trim()
fraction_string = TRY_OR_THROW_OOM(vm, String::from_utf8(fraction_string.bytes_as_string_view().trim("0"sv, TrimMode::Right)));
fraction_string = TRY_OR_THROW_OOM(vm, fraction_string.trim("0"sv, TrimMode::Right));
}
// 6. Else,
else {
@ -1806,8 +1805,7 @@ ThrowCompletionOr<Object*> prepare_temporal_fields(VM& vm, Object const& fields,
// 4. If requiredFields is partial and any is false, then
if (required_fields.has<PrepareTemporalFieldsPartial>() && !any) {
// a. Throw a TypeError exception.
// FIXME: Add & use String::join()
return vm.throw_completion<TypeError>(ErrorType::TemporalObjectMustHaveOneOf, DeprecatedString::join(", "sv, field_names));
return vm.throw_completion<TypeError>(ErrorType::TemporalObjectMustHaveOneOf, TRY_OR_THROW_OOM(vm, String::join(", "sv, field_names)));
}
// 5. Return result.