Skip to content

Commit ca103d6

Browse files
committed
CalendarEqualsOrThrow => ThrowIfCalendarsNotEqual
Currently `CalendarEqualsOrThrow`, returns `true`, returns `undefined`, or throws. This variation in return values doesn't break anything as the return value is not used by any callers. To prevent future problems this commit renames it to `ThrowIfCalendarsNotEqual` and always returns `undefined`.
1 parent 3b2baa7 commit ca103d6

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

polyfill/lib/ecmascript.mjs

+7-7
Original file line numberDiff line numberDiff line change
@@ -2014,13 +2014,13 @@ export function CalendarEquals(one, two) {
20142014
const cal2 = ToTemporalCalendarIdentifier(two);
20152015
return cal1 === cal2;
20162016
}
2017+
20172018
// This operation is not in the spec, it implements the following:
20182019
// "If ? CalendarEquals(one, two) is false, throw a RangeError exception."
20192020
// This is so that we can build an informative error message without
20202021
// re-getting the .id properties.
2021-
2022-
export function CalendarEqualsOrThrow(one, two, errorMessageAction) {
2023-
if (one === two) return true;
2022+
export function ThrowIfCalendarsNotEqual(one, two, errorMessageAction) {
2023+
if (one === two) return;
20242024
const cal1 = ToTemporalCalendarIdentifier(one);
20252025
const cal2 = ToTemporalCalendarIdentifier(two);
20262026
if (cal1 !== cal2) {
@@ -3985,7 +3985,7 @@ export function DifferenceTemporalPlainDate(operation, plainDate, other, options
39853985
other = ToTemporalDate(other);
39863986
const calendar = GetSlot(plainDate, CALENDAR);
39873987
const otherCalendar = GetSlot(other, CALENDAR);
3988-
CalendarEqualsOrThrow(calendar, otherCalendar, 'compute difference between dates');
3988+
ThrowIfCalendarsNotEqual(calendar, otherCalendar, 'compute difference between dates');
39893989

39903990
const resolvedOptions = ObjectCreate(null);
39913991
CopyDataProperties(resolvedOptions, GetOptionsObject(options), []);
@@ -4022,7 +4022,7 @@ export function DifferenceTemporalPlainDateTime(operation, plainDateTime, other,
40224022
other = ToTemporalDateTime(other);
40234023
const calendar = GetSlot(plainDateTime, CALENDAR);
40244024
const otherCalendar = GetSlot(other, CALENDAR);
4025-
CalendarEqualsOrThrow(calendar, otherCalendar, 'compute difference between dates');
4025+
ThrowIfCalendarsNotEqual(calendar, otherCalendar, 'compute difference between dates');
40264026

40274027
const resolvedOptions = ObjectCreate(null);
40284028
CopyDataProperties(resolvedOptions, GetOptionsObject(options), []);
@@ -4163,7 +4163,7 @@ export function DifferenceTemporalPlainYearMonth(operation, yearMonth, other, op
41634163
other = ToTemporalYearMonth(other);
41644164
const calendar = GetSlot(yearMonth, CALENDAR);
41654165
const otherCalendar = GetSlot(other, CALENDAR);
4166-
CalendarEqualsOrThrow(calendar, otherCalendar, 'compute difference between months');
4166+
ThrowIfCalendarsNotEqual(calendar, otherCalendar, 'compute difference between months');
41674167

41684168
const resolvedOptions = ObjectCreate(null);
41694169
CopyDataProperties(resolvedOptions, GetOptionsObject(options), []);
@@ -4208,7 +4208,7 @@ export function DifferenceTemporalZonedDateTime(operation, zonedDateTime, other,
42084208
other = ToTemporalZonedDateTime(other);
42094209
const calendar = GetSlot(zonedDateTime, CALENDAR);
42104210
const otherCalendar = GetSlot(other, CALENDAR);
4211-
CalendarEqualsOrThrow(calendar, otherCalendar, 'compute difference between dates');
4211+
ThrowIfCalendarsNotEqual(calendar, otherCalendar, 'compute difference between dates');
42124212

42134213
const resolvedOptions = ObjectCreate(null);
42144214
CopyDataProperties(resolvedOptions, GetOptionsObject(options), []);

0 commit comments

Comments
 (0)