diff --git a/Userland/Libraries/LibJS/Runtime/AbstractOperations.h b/Userland/Libraries/LibJS/Runtime/AbstractOperations.h index 07a45fc051..7c0a9cac83 100644 --- a/Userland/Libraries/LibJS/Runtime/AbstractOperations.h +++ b/Userland/Libraries/LibJS/Runtime/AbstractOperations.h @@ -136,6 +136,35 @@ ThrowCompletionOr ordinary_create_from_constructor(GlobalObject& global_obje return global_object.heap().allocate(global_object, forward(args)..., *prototype); } +// 14.1 MergeLists ( a, b ), https://tc39.es/proposal-temporal/#sec-temporal-mergelists +template +Vector merge_lists(Vector const& a, Vector const& b) +{ + // 1. Let merged be a new empty List. + Vector merged; + + // 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 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); + } + } + + // 4. Return merged. + return merged; +} + // x modulo y, https://tc39.es/ecma262/#eqn-modulo template auto modulo(T x, U y) requires(IsArithmetic, IsArithmetic) diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp index 24baa84d9d..dbd0dc6c62 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.cpp @@ -997,32 +997,4 @@ ThrowCompletionOr default_merge_calendar_fields(GlobalObject& global_ob return merged; } -// 12.2.41 MergeLists ( a, b ), https://tc39.es/proposal-temporal/#sec-temporal-mergelists -Vector merge_lists(Vector const& a, Vector const& b) -{ - // 1. Let merged be a new empty List. - Vector merged; - - // 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 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); - } - } - - // 4. Return merged. - return merged; -} - } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.h b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.h index 040a6a7e75..bada3ded72 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.h +++ b/Userland/Libraries/LibJS/Runtime/Temporal/Calendar.h @@ -74,6 +74,5 @@ u8 iso_month(Object& temporal_object); String iso_month_code(Object& temporal_object); u8 iso_day(Object& temporal_object); ThrowCompletionOr default_merge_calendar_fields(GlobalObject&, Object const& fields, Object const& additional_fields); -Vector merge_lists(Vector const& a, Vector const& b); } diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp index 4413ce794b..8f274343d0 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainMonthDayPrototype.cpp @@ -5,6 +5,7 @@ */ #include +#include #include #include #include diff --git a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp index 68bea0ea69..cf2abb4d57 100644 --- a/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp +++ b/Userland/Libraries/LibJS/Runtime/Temporal/PlainYearMonthPrototype.cpp @@ -5,6 +5,7 @@ */ #include +#include #include #include #include