Skip to content

Commit 9842e3c

Browse files
committed
Update to the version of NormalizeOptionsObject in ECMA-402
This eventually landed as GetOptionsObject in the 2021 edition of ECMA-402 so update the name, and note in the amendments section that the operations are to be moved from ECMA-402 into ECMA-262. Closes: #1249
1 parent e1cc2cd commit 9842e3c

12 files changed

+59
-59
lines changed

lib/calendar.mjs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,19 @@ export class Calendar {
3838
dateFromFields(fields, options) {
3939
if (!ES.IsTemporalCalendar(this)) throw new TypeError('invalid receiver');
4040
if (ES.Type(fields) !== 'Object') throw new TypeError('invalid fields');
41-
options = ES.NormalizeOptionsObject(options);
41+
options = ES.GetOptionsObject(options);
4242
return impl[GetSlot(this, CALENDAR_ID)].dateFromFields(fields, options, this);
4343
}
4444
yearMonthFromFields(fields, options) {
4545
if (!ES.IsTemporalCalendar(this)) throw new TypeError('invalid receiver');
4646
if (ES.Type(fields) !== 'Object') throw new TypeError('invalid fields');
47-
options = ES.NormalizeOptionsObject(options);
47+
options = ES.GetOptionsObject(options);
4848
return impl[GetSlot(this, CALENDAR_ID)].yearMonthFromFields(fields, options, this);
4949
}
5050
monthDayFromFields(fields, options) {
5151
if (!ES.IsTemporalCalendar(this)) throw new TypeError('invalid receiver');
5252
if (ES.Type(fields) !== 'Object') throw new TypeError('invalid fields');
53-
options = ES.NormalizeOptionsObject(options);
53+
options = ES.GetOptionsObject(options);
5454
return impl[GetSlot(this, CALENDAR_ID)].monthDayFromFields(fields, options, this);
5555
}
5656
fields(fields) {
@@ -70,15 +70,15 @@ export class Calendar {
7070
if (!ES.IsTemporalCalendar(this)) throw new TypeError('invalid receiver');
7171
date = ES.ToTemporalDate(date);
7272
duration = ES.ToTemporalDuration(duration);
73-
options = ES.NormalizeOptionsObject(options);
73+
options = ES.GetOptionsObject(options);
7474
const overflow = ES.ToTemporalOverflow(options);
7575
return impl[GetSlot(this, CALENDAR_ID)].dateAdd(date, duration, overflow, this);
7676
}
7777
dateUntil(one, two, options) {
7878
if (!ES.IsTemporalCalendar(this)) throw new TypeError('invalid receiver');
7979
one = ES.ToTemporalDate(one);
8080
two = ES.ToTemporalDate(two);
81-
options = ES.NormalizeOptionsObject(options);
81+
options = ES.GetOptionsObject(options);
8282
const largestUnit = ES.ToLargestTemporalUnit(options, 'days', [
8383
'hours',
8484
'minutes',

lib/duration.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ export class Duration {
228228
microseconds,
229229
nanoseconds
230230
} = ES.ToLimitedTemporalDuration(other);
231-
options = ES.NormalizeOptionsObject(options);
231+
options = ES.GetOptionsObject(options);
232232
const relativeTo = ES.ToRelativeTemporalObject(options);
233233
({ years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds } = ES.AddDuration(
234234
GetSlot(this, YEARS),
@@ -269,7 +269,7 @@ export class Duration {
269269
microseconds,
270270
nanoseconds
271271
} = ES.ToLimitedTemporalDuration(other);
272-
options = ES.NormalizeOptionsObject(options);
272+
options = ES.GetOptionsObject(options);
273273
const relativeTo = ES.ToRelativeTemporalObject(options);
274274
({ years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds } = ES.AddDuration(
275275
GetSlot(this, YEARS),
@@ -322,7 +322,7 @@ export class Duration {
322322
microseconds,
323323
nanoseconds
324324
);
325-
options = ES.NormalizeOptionsObject(options);
325+
options = ES.GetOptionsObject(options);
326326
let smallestUnit = ES.ToSmallestTemporalDurationUnit(options, undefined);
327327
let smallestUnitPresent = true;
328328
if (!smallestUnit) {
@@ -450,7 +450,7 @@ export class Duration {
450450
let microseconds = GetSlot(this, MICROSECONDS);
451451
let nanoseconds = GetSlot(this, NANOSECONDS);
452452

453-
options = ES.NormalizeOptionsObject(options);
453+
options = ES.GetOptionsObject(options);
454454
const unit = ES.ToTemporalDurationTotalUnit(options, undefined);
455455
if (unit === undefined) throw new RangeError('unit option is required');
456456
const relativeTo = ES.ToRelativeTemporalObject(options);
@@ -494,7 +494,7 @@ export class Duration {
494494
}
495495
toString(options = undefined) {
496496
if (!ES.IsTemporalDuration(this)) throw new TypeError('invalid receiver');
497-
options = ES.NormalizeOptionsObject(options);
497+
options = ES.GetOptionsObject(options);
498498
const { precision, unit, increment } = ES.ToDurationSecondsStringPrecision(options);
499499
const roundingMode = ES.ToTemporalRoundingMode(options, 'trunc');
500500
return ES.TemporalDurationToString(this, precision, { unit, increment, roundingMode });
@@ -534,7 +534,7 @@ export class Duration {
534534
static compare(one, two, options = undefined) {
535535
one = ES.ToTemporalDuration(one);
536536
two = ES.ToTemporalDuration(two);
537-
options = ES.NormalizeOptionsObject(options);
537+
options = ES.GetOptionsObject(options);
538538
const relativeTo = ES.ToRelativeTemporalObject(options);
539539
const y1 = GetSlot(one, YEARS);
540540
const mon1 = GetSlot(one, MONTHS);

lib/ecmascript.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4312,7 +4312,7 @@ export const ES = ObjectAssign({}, ES2020, {
43124312
return new TemporalTimeZone(ES.TemporalTimeZoneFromString(fmt.resolvedOptions().timeZone));
43134313
},
43144314
ComparisonResult: (value) => (value < 0 ? -1 : value > 0 ? 1 : value),
4315-
NormalizeOptionsObject: (options) => {
4315+
GetOptionsObject: (options) => {
43164316
if (options === undefined) return ObjectCreate(null);
43174317
if (ES.Type(options) === 'Object') return options;
43184318
throw new TypeError(

lib/instant.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export class Instant {
9999
if (!ES.IsTemporalInstant(this)) throw new TypeError('invalid receiver');
100100
other = ES.ToTemporalInstant(other);
101101
const disallowedUnits = ['years', 'months', 'weeks', 'days'];
102-
options = ES.NormalizeOptionsObject(options);
102+
options = ES.GetOptionsObject(options);
103103
const smallestUnit = ES.ToSmallestTemporalDurationUnit(options, 'nanoseconds', disallowedUnits);
104104
const defaultLargestUnit = ES.LargerOfTwoTemporalDurationUnits('seconds', smallestUnit);
105105
const largestUnit = ES.ToLargestTemporalUnit(options, defaultLargestUnit, disallowedUnits);
@@ -141,7 +141,7 @@ export class Instant {
141141
if (!ES.IsTemporalInstant(this)) throw new TypeError('invalid receiver');
142142
other = ES.ToTemporalInstant(other);
143143
const disallowedUnits = ['years', 'months', 'weeks', 'days'];
144-
options = ES.NormalizeOptionsObject(options);
144+
options = ES.GetOptionsObject(options);
145145
const smallestUnit = ES.ToSmallestTemporalDurationUnit(options, 'nanoseconds', disallowedUnits);
146146
const defaultLargestUnit = ES.LargerOfTwoTemporalDurationUnits('seconds', smallestUnit);
147147
const largestUnit = ES.ToLargestTemporalUnit(options, defaultLargestUnit, disallowedUnits);
@@ -182,7 +182,7 @@ export class Instant {
182182
round(options) {
183183
if (!ES.IsTemporalInstant(this)) throw new TypeError('invalid receiver');
184184
if (options === undefined) throw new TypeError('options parameter is required');
185-
options = ES.NormalizeOptionsObject(options);
185+
options = ES.GetOptionsObject(options);
186186
const smallestUnit = ES.ToSmallestTemporalUnit(options, ['day']);
187187
const roundingMode = ES.ToTemporalRoundingMode(options, 'halfExpand');
188188
const maximumIncrements = {
@@ -207,7 +207,7 @@ export class Instant {
207207
}
208208
toString(options = undefined) {
209209
if (!ES.IsTemporalInstant(this)) throw new TypeError('invalid receiver');
210-
options = ES.NormalizeOptionsObject(options);
210+
options = ES.GetOptionsObject(options);
211211
let timeZone = options.timeZone;
212212
if (timeZone !== undefined) timeZone = ES.ToTemporalTimeZone(timeZone);
213213
const { precision, unit, increment } = ES.ToSecondsStringPrecision(options);

lib/plaindate.mjs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export class PlainDate {
119119
fields = ES.CalendarMergeFields(calendar, fields, props);
120120
fields = ES.ToTemporalDateFields(fields, fieldNames);
121121

122-
options = ES.NormalizeOptionsObject(options);
122+
options = ES.GetOptionsObject(options);
123123

124124
return ES.DateFromFields(calendar, fields, options);
125125
}
@@ -131,7 +131,7 @@ export class PlainDate {
131131
if (!ES.IsTemporalDate(this)) throw new TypeError('invalid receiver');
132132

133133
let duration = ES.ToLimitedTemporalDuration(temporalDurationLike);
134-
options = ES.NormalizeOptionsObject(options);
134+
options = ES.GetOptionsObject(options);
135135

136136
let { years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds } = duration;
137137
ES.RejectDurationSign(years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds);
@@ -143,7 +143,7 @@ export class PlainDate {
143143
if (!ES.IsTemporalDate(this)) throw new TypeError('invalid receiver');
144144

145145
let duration = ES.ToLimitedTemporalDuration(temporalDurationLike);
146-
options = ES.NormalizeOptionsObject(options);
146+
options = ES.GetOptionsObject(options);
147147

148148
let { years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds } = duration;
149149
ES.RejectDurationSign(years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds);
@@ -162,7 +162,7 @@ export class PlainDate {
162162
throw new RangeError(`cannot compute difference between dates of ${calendarId} and ${otherCalendarId} calendars`);
163163
}
164164

165-
options = ES.NormalizeOptionsObject(options);
165+
options = ES.GetOptionsObject(options);
166166
const disallowedUnits = ['hours', 'minutes', 'seconds', 'milliseconds', 'microseconds', 'nanoseconds'];
167167
const smallestUnit = ES.ToSmallestTemporalDurationUnit(options, 'days', disallowedUnits);
168168
const defaultLargestUnit = ES.LargerOfTwoTemporalDurationUnits('days', smallestUnit);
@@ -218,7 +218,7 @@ export class PlainDate {
218218
throw new RangeError(`cannot compute difference between dates of ${calendarId} and ${otherCalendarId} calendars`);
219219
}
220220

221-
options = ES.NormalizeOptionsObject(options);
221+
options = ES.GetOptionsObject(options);
222222
const disallowedUnits = ['hours', 'minutes', 'seconds', 'milliseconds', 'microseconds', 'nanoseconds'];
223223
const smallestUnit = ES.ToSmallestTemporalDurationUnit(options, 'days', disallowedUnits);
224224
const defaultLargestUnit = ES.LargerOfTwoTemporalDurationUnits('days', smallestUnit);
@@ -275,7 +275,7 @@ export class PlainDate {
275275
}
276276
toString(options = undefined) {
277277
if (!ES.IsTemporalDate(this)) throw new TypeError('invalid receiver');
278-
options = ES.NormalizeOptionsObject(options);
278+
options = ES.GetOptionsObject(options);
279279
const showCalendar = ES.ToShowCalendarOption(options);
280280
return ES.TemporalDateToString(this, showCalendar);
281281
}
@@ -396,7 +396,7 @@ export class PlainDate {
396396
};
397397
}
398398
static from(item, options = undefined) {
399-
options = ES.NormalizeOptionsObject(options);
399+
options = ES.GetOptionsObject(options);
400400
if (ES.IsTemporalDate(item)) {
401401
ES.ToTemporalOverflow(options); // validate and ignore
402402
return ES.CreateTemporalDate(

lib/plaindatetime.mjs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ export class PlainDateTime {
163163
throw new TypeError('with() does not support a timeZone property');
164164
}
165165

166-
options = ES.NormalizeOptionsObject(options);
166+
options = ES.GetOptionsObject(options);
167167
const calendar = GetSlot(this, CALENDAR);
168168
const fieldNames = ES.CalendarFields(calendar, [
169169
'day',
@@ -289,7 +289,7 @@ export class PlainDateTime {
289289
let duration = ES.ToLimitedTemporalDuration(temporalDurationLike);
290290
let { years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds } = duration;
291291
ES.RejectDurationSign(years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds);
292-
options = ES.NormalizeOptionsObject(options);
292+
options = ES.GetOptionsObject(options);
293293
const calendar = GetSlot(this, CALENDAR);
294294
const { year, month, day, hour, minute, second, millisecond, microsecond, nanosecond } = ES.AddDateTime(
295295
GetSlot(this, ISO_YEAR),
@@ -332,7 +332,7 @@ export class PlainDateTime {
332332
let duration = ES.ToLimitedTemporalDuration(temporalDurationLike);
333333
let { years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds } = duration;
334334
ES.RejectDurationSign(years, months, weeks, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds);
335-
options = ES.NormalizeOptionsObject(options);
335+
options = ES.GetOptionsObject(options);
336336
const calendar = GetSlot(this, CALENDAR);
337337
const { year, month, day, hour, minute, second, millisecond, microsecond, nanosecond } = ES.AddDateTime(
338338
GetSlot(this, ISO_YEAR),
@@ -380,7 +380,7 @@ export class PlainDateTime {
380380
if (calendarId !== otherCalendarId) {
381381
throw new RangeError(`cannot compute difference between dates of ${calendarId} and ${otherCalendarId} calendars`);
382382
}
383-
options = ES.NormalizeOptionsObject(options);
383+
options = ES.GetOptionsObject(options);
384384
const smallestUnit = ES.ToSmallestTemporalDurationUnit(options, 'nanoseconds');
385385
const defaultLargestUnit = ES.LargerOfTwoTemporalDurationUnits('days', smallestUnit);
386386
const largestUnit = ES.ToLargestTemporalUnit(options, defaultLargestUnit);
@@ -474,7 +474,7 @@ export class PlainDateTime {
474474
if (calendarId !== otherCalendarId) {
475475
throw new RangeError(`cannot compute difference between dates of ${calendarId} and ${otherCalendarId} calendars`);
476476
}
477-
options = ES.NormalizeOptionsObject(options);
477+
options = ES.GetOptionsObject(options);
478478
const smallestUnit = ES.ToSmallestTemporalDurationUnit(options, 'nanoseconds');
479479
const defaultLargestUnit = ES.LargerOfTwoTemporalDurationUnits('days', smallestUnit);
480480
const largestUnit = ES.ToLargestTemporalUnit(options, defaultLargestUnit);
@@ -572,7 +572,7 @@ export class PlainDateTime {
572572
round(options) {
573573
if (!ES.IsTemporalDateTime(this)) throw new TypeError('invalid receiver');
574574
if (options === undefined) throw new TypeError('options parameter is required');
575-
options = ES.NormalizeOptionsObject(options);
575+
options = ES.GetOptionsObject(options);
576576
const smallestUnit = ES.ToSmallestTemporalUnit(options);
577577
const roundingMode = ES.ToTemporalRoundingMode(options, 'halfExpand');
578578
const maximumIncrements = {
@@ -645,7 +645,7 @@ export class PlainDateTime {
645645
}
646646
toString(options = undefined) {
647647
if (!ES.IsTemporalDateTime(this)) throw new TypeError('invalid receiver');
648-
options = ES.NormalizeOptionsObject(options);
648+
options = ES.GetOptionsObject(options);
649649
const { precision, unit, increment } = ES.ToSecondsStringPrecision(options);
650650
const showCalendar = ES.ToShowCalendarOption(options);
651651
const roundingMode = ES.ToTemporalRoundingMode(options, 'trunc');
@@ -666,7 +666,7 @@ export class PlainDateTime {
666666
toZonedDateTime(temporalTimeZoneLike, options = undefined) {
667667
if (!ES.IsTemporalDateTime(this)) throw new TypeError('invalid receiver');
668668
const timeZone = ES.ToTemporalTimeZone(temporalTimeZoneLike);
669-
options = ES.NormalizeOptionsObject(options);
669+
options = ES.GetOptionsObject(options);
670670
const disambiguation = ES.ToTemporalDisambiguation(options);
671671
const instant = ES.BuiltinTimeZoneGetInstantFor(timeZone, this, disambiguation);
672672
return ES.CreateTemporalZonedDateTime(GetSlot(instant, EPOCHNANOSECONDS), timeZone, GetSlot(this, CALENDAR));
@@ -710,7 +710,7 @@ export class PlainDateTime {
710710
}
711711

712712
static from(item, options = undefined) {
713-
options = ES.NormalizeOptionsObject(options);
713+
options = ES.GetOptionsObject(options);
714714
if (ES.IsTemporalDateTime(item)) {
715715
ES.ToTemporalOverflow(options); // validate and ignore
716716
return ES.CreateTemporalDateTime(

lib/plainmonthday.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export class PlainMonthDay {
5858
fields = ES.CalendarMergeFields(calendar, fields, props);
5959
fields = ES.ToTemporalMonthDayFields(fields, fieldNames);
6060

61-
options = ES.NormalizeOptionsObject(options);
61+
options = ES.GetOptionsObject(options);
6262
return ES.MonthDayFromFields(calendar, fields, options);
6363
}
6464
equals(other) {
@@ -73,7 +73,7 @@ export class PlainMonthDay {
7373
}
7474
toString(options = undefined) {
7575
if (!ES.IsTemporalMonthDay(this)) throw new TypeError('invalid receiver');
76-
options = ES.NormalizeOptionsObject(options);
76+
options = ES.GetOptionsObject(options);
7777
const showCalendar = ES.ToShowCalendarOption(options);
7878
return ES.TemporalMonthDayToString(this, showCalendar);
7979
}
@@ -126,7 +126,7 @@ export class PlainMonthDay {
126126
};
127127
}
128128
static from(item, options = undefined) {
129-
options = ES.NormalizeOptionsObject(options);
129+
options = ES.GetOptionsObject(options);
130130
if (ES.IsTemporalMonthDay(item)) {
131131
ES.ToTemporalOverflow(options); // validate and ignore
132132
return ES.CreateTemporalMonthDay(

lib/plaintime.mjs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export class PlainTime {
127127
throw new TypeError('with() does not support a timeZone property');
128128
}
129129

130-
options = ES.NormalizeOptionsObject(options);
130+
options = ES.GetOptionsObject(options);
131131
const overflow = ES.ToTemporalOverflow(options);
132132

133133
const props = ES.ToPartialRecord(temporalTimeLike, [
@@ -229,7 +229,7 @@ export class PlainTime {
229229
until(other, options = undefined) {
230230
if (!ES.IsTemporalTime(this)) throw new TypeError('invalid receiver');
231231
other = ES.ToTemporalTime(other);
232-
options = ES.NormalizeOptionsObject(options);
232+
options = ES.GetOptionsObject(options);
233233
const largestUnit = ES.ToLargestTemporalUnit(options, 'hours', ['years', 'months', 'weeks', 'days']);
234234
const smallestUnit = ES.ToSmallestTemporalDurationUnit(options, 'nanoseconds');
235235
ES.ValidateTemporalUnitRange(largestUnit, smallestUnit);
@@ -288,7 +288,7 @@ export class PlainTime {
288288
since(other, options = undefined) {
289289
if (!ES.IsTemporalTime(this)) throw new TypeError('invalid receiver');
290290
other = ES.ToTemporalTime(other);
291-
options = ES.NormalizeOptionsObject(options);
291+
options = ES.GetOptionsObject(options);
292292
const largestUnit = ES.ToLargestTemporalUnit(options, 'hours', ['years', 'months', 'weeks', 'days']);
293293
const smallestUnit = ES.ToSmallestTemporalDurationUnit(options, 'nanoseconds');
294294
ES.ValidateTemporalUnitRange(largestUnit, smallestUnit);
@@ -353,7 +353,7 @@ export class PlainTime {
353353
round(options) {
354354
if (!ES.IsTemporalTime(this)) throw new TypeError('invalid receiver');
355355
if (options === undefined) throw new TypeError('options parameter is required');
356-
options = ES.NormalizeOptionsObject(options);
356+
options = ES.GetOptionsObject(options);
357357
const smallestUnit = ES.ToSmallestTemporalUnit(options, ['day']);
358358
const roundingMode = ES.ToTemporalRoundingMode(options, 'halfExpand');
359359
const maximumIncrements = {
@@ -399,7 +399,7 @@ export class PlainTime {
399399

400400
toString(options = undefined) {
401401
if (!ES.IsTemporalTime(this)) throw new TypeError('invalid receiver');
402-
options = ES.NormalizeOptionsObject(options);
402+
options = ES.GetOptionsObject(options);
403403
const { precision, unit, increment } = ES.ToSecondsStringPrecision(options);
404404
const roundingMode = ES.ToTemporalRoundingMode(options, 'trunc');
405405
return TemporalTimeToString(this, precision, { unit, increment, roundingMode });
@@ -494,7 +494,7 @@ export class PlainTime {
494494
}
495495

496496
static from(item, options = undefined) {
497-
options = ES.NormalizeOptionsObject(options);
497+
options = ES.GetOptionsObject(options);
498498
const overflow = ES.ToTemporalOverflow(options);
499499
if (ES.IsTemporalTime(item)) {
500500
return new PlainTime(

0 commit comments

Comments
 (0)