mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-19 01:22:54 +00:00
LibJS: Make PrimitiveString::deprecated_string() infallible
Work towards #20449.
This commit is contained in:
parent
c084269e5f
commit
09547ec975
Notes:
sideshowbarker
2024-07-16 20:08:14 +09:00
Author: https://github.com/awesomekling
Commit: 09547ec975
Pull-request: https://github.com/SerenityOS/serenity/pull/20451
Reviewed-by: https://github.com/trflynn89
17 changed files with 42 additions and 43 deletions
|
@ -63,7 +63,7 @@ ThrowCompletionOr<DeprecatedString> JSONObject::stringify_impl(VM& vm, Value val
|
|||
auto replacer_value = TRY(replacer_object.get(i));
|
||||
DeprecatedString item;
|
||||
if (replacer_value.is_string()) {
|
||||
item = TRY(replacer_value.as_string().deprecated_string());
|
||||
item = replacer_value.as_string().deprecated_string();
|
||||
} else if (replacer_value.is_number()) {
|
||||
item = MUST(replacer_value.to_deprecated_string(vm));
|
||||
} else if (replacer_value.is_object()) {
|
||||
|
@ -93,7 +93,7 @@ ThrowCompletionOr<DeprecatedString> JSONObject::stringify_impl(VM& vm, Value val
|
|||
space_mv = min(10, space_mv);
|
||||
state.gap = space_mv < 1 ? DeprecatedString::empty() : DeprecatedString::repeated(' ', space_mv);
|
||||
} else if (space.is_string()) {
|
||||
auto string = TRY(space.as_string().deprecated_string());
|
||||
auto string = space.as_string().deprecated_string();
|
||||
if (string.length() <= 10)
|
||||
state.gap = string;
|
||||
else
|
||||
|
@ -185,7 +185,7 @@ ThrowCompletionOr<DeprecatedString> JSONObject::serialize_json_property(VM& vm,
|
|||
|
||||
// 8. If Type(value) is String, return QuoteJSONString(value).
|
||||
if (value.is_string())
|
||||
return quote_json_string(TRY(value.as_string().deprecated_string()));
|
||||
return quote_json_string(value.as_string().deprecated_string());
|
||||
|
||||
// 9. If Type(value) is Number, then
|
||||
if (value.is_number()) {
|
||||
|
@ -250,7 +250,7 @@ ThrowCompletionOr<DeprecatedString> JSONObject::serialize_json_object(VM& vm, St
|
|||
} else {
|
||||
auto property_list = TRY(object.enumerable_own_property_names(PropertyKind::Key));
|
||||
for (auto& property : property_list)
|
||||
TRY(process_property(TRY(property.as_string().deprecated_string())));
|
||||
TRY(process_property(property.as_string().deprecated_string()));
|
||||
}
|
||||
StringBuilder builder;
|
||||
if (property_strings.is_empty()) {
|
||||
|
@ -487,7 +487,7 @@ ThrowCompletionOr<Value> JSONObject::internalize_json_property(VM& vm, Object* h
|
|||
} else {
|
||||
auto property_list = TRY(value_object.enumerable_own_property_names(Object::PropertyKind::Key));
|
||||
for (auto& property_key : property_list)
|
||||
TRY(process_property(TRY(property_key.as_string().deprecated_string())));
|
||||
TRY(process_property(property_key.as_string().deprecated_string()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue