1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 15:57:35 +00:00

LibJS: Rename CalendarMergeFieldNames to MergeLists

This is an editorial change in the Temporal spec.

See: bebf467
This commit is contained in:
Linus Groh 2022-06-18 13:36:19 +01:00
parent e685896403
commit 0c3d2b656e
4 changed files with 19 additions and 19 deletions

View file

@ -997,27 +997,27 @@ ThrowCompletionOr<Object*> default_merge_calendar_fields(GlobalObject& global_ob
return merged;
}
// 12.2.41 CalendarMergeFieldNames ( receiverFieldNames, inputFieldNames ), https://tc39.es/proposal-temporal/#sec-temporal-calendarmergefieldnames
Vector<String> calendar_merge_field_names(Vector<String> const& receiver_field_names, Vector<String> const& input_field_names)
// 12.2.41 MergeLists ( a, b ), https://tc39.es/proposal-temporal/#sec-temporal-mergelists
Vector<String> merge_lists(Vector<String> const& a, Vector<String> const& b)
{
// 1. Let merged be a new empty List.
Vector<String> merged;
// 2. For each element name of receiverFieldNames, do
for (auto const& field_name : receiver_field_names) {
// a. If merged does not contain name, then
if (!merged.contains_slow(field_name)) {
// i. Append name to merged.
merged.append(field_name);
// 2. For each element element of a, do
for (auto const& element : a) {
// a. If merged does not contain element, then
if (!merged.contains_slow(element)) {
// i. Append element to merged.
merged.append(element);
}
}
// 3. For each element name of inputFieldNames, do
for (auto const& field_name : input_field_names) {
// a. If merged does not contain name, then
if (!merged.contains_slow(field_name)) {
// i. Append name to merged.
merged.append(field_name);
// 3. For each element element of b, do
for (auto const& element : b) {
// a. If merged does not contain element, then
if (!merged.contains_slow(element)) {
// i. Append element to merged.
merged.append(element);
}
}

View file

@ -74,6 +74,6 @@ u8 iso_month(Object& temporal_object);
String iso_month_code(Object& temporal_object);
u8 iso_day(Object& temporal_object);
ThrowCompletionOr<Object*> default_merge_calendar_fields(GlobalObject&, Object const& fields, Object const& additional_fields);
Vector<String> calendar_merge_field_names(Vector<String> const& receiver_field_names, Vector<String> const& input_field_names);
Vector<String> merge_lists(Vector<String> const& a, Vector<String> const& b);
}

View file

@ -231,8 +231,8 @@ JS_DEFINE_NATIVE_FUNCTION(PlainMonthDayPrototype::to_plain_date)
// 9. Let mergedFields be ? CalendarMergeFields(calendar, fields, inputFields).
auto* merged_fields = TRY(calendar_merge_fields(global_object, calendar, *fields, *input_fields));
// 10. Let mergedFieldNames be CalendarMergeFieldNames(receiverFieldNames, inputFieldNames).
auto merged_field_names = calendar_merge_field_names(receiver_field_names, input_field_names);
// 10. Let mergedFieldNames be MergeLists(receiverFieldNames, inputFieldNames).
auto merged_field_names = merge_lists(receiver_field_names, input_field_names);
// 11. Set mergedFields to ? PrepareTemporalFields(mergedFields, mergedFieldNames, «»).
merged_fields = TRY(prepare_temporal_fields(global_object, *merged_fields, merged_field_names, Vector<StringView> {}));

View file

@ -398,8 +398,8 @@ JS_DEFINE_NATIVE_FUNCTION(PlainYearMonthPrototype::to_plain_date)
// 9. Let mergedFields be ? CalendarMergeFields(calendar, fields, inputFields).
auto* merged_fields = TRY(calendar_merge_fields(global_object, calendar, *fields, *input_fields));
// 10. Let mergedFieldNames be CalendarMergeFieldNames(receiverFieldNames, inputFieldNames).
auto merged_field_names = calendar_merge_field_names(receiver_field_names, input_field_names);
// 10. Let mergedFieldNames be MergeLists(receiverFieldNames, inputFieldNames).
auto merged_field_names = merge_lists(receiver_field_names, input_field_names);
// 11. Set mergedFields to ? PrepareTemporalFields(mergedFields, mergedFieldNames, «»).
merged_fields = TRY(prepare_temporal_fields(global_object, *merged_fields, merged_field_names, Vector<StringView> {}));