Skip to content

Commit 6c6ef90

Browse files
committed
Remove unused ecmascript.ts functions
Now that #57 is merged, it's easy to find which functions aren't used. According to `npx ts-prune`, the following 5 functions aren't used: * `RegulateISODateTime` * `CastIfDefined` * `CalendarCompare` * `SubtractDate` * `AssertPositiveInteger` * `ToTemporalDurationOverflow` After those were deleted, `ConstrainISODateTime` was now unused because `RegulateISODateTime` (now deleted) was its only caller. So `ConstrainISODateTime` is also deleted in this commit. I verified via grep that these are indeed unused anywhere (including tests). Also, none of these show up in the spec.
1 parent 50b1c34 commit 6c6ef90

File tree

1 file changed

+0
-79
lines changed

1 file changed

+0
-79
lines changed

lib/ecmascript.ts

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -478,39 +478,6 @@ export function ParseTemporalInstant(isoString) {
478478
return epochNs.subtract(offsetNs);
479479
}
480480

481-
export function RegulateISODateTime(
482-
year,
483-
month,
484-
day,
485-
hour,
486-
minute,
487-
second,
488-
millisecond,
489-
microsecond,
490-
nanosecond,
491-
overflow
492-
) {
493-
switch (overflow) {
494-
case 'reject':
495-
RejectDateTime(year, month, day, hour, minute, second, millisecond, microsecond, nanosecond);
496-
break;
497-
case 'constrain':
498-
({ year, month, day, hour, minute, second, millisecond, microsecond, nanosecond } = ConstrainISODateTime(
499-
year,
500-
month,
501-
day,
502-
hour,
503-
minute,
504-
second,
505-
millisecond,
506-
microsecond,
507-
nanosecond
508-
));
509-
break;
510-
}
511-
return { year, month, day, hour, minute, second, millisecond, microsecond, nanosecond };
512-
}
513-
514481
export function RegulateISODate(year, month, day, overflow) {
515482
switch (overflow) {
516483
case 'reject':
@@ -657,10 +624,6 @@ export function ToLimitedTemporalDuration(item, disallowedProperties = []) {
657624
return record;
658625
}
659626

660-
export function ToTemporalDurationOverflow(options) {
661-
return GetOption(options, 'overflow', ['constrain', 'balance'], 'constrain');
662-
}
663-
664627
export function ToTemporalOverflow(options) {
665628
return GetOption(options, 'overflow', ['constrain', 'reject'], 'constrain');
666629
}
@@ -925,13 +888,6 @@ export function LargerOfTwoTemporalUnits(unit1, unit2) {
925888
return unit1;
926889
}
927890

928-
export function CastIfDefined(value, cast) {
929-
if (value !== undefined) {
930-
return cast(value);
931-
}
932-
return value;
933-
}
934-
935891
export function ToPartialRecord(bag, fields, callerCast?: (value: unknown) => unknown) {
936892
if (Type(bag) !== 'Object') return false;
937893
let any;
@@ -1773,12 +1729,6 @@ export function GetTemporalCalendarWithISODefault(item) {
17731729
return ToTemporalCalendar(calendar);
17741730
}
17751731

1776-
export function CalendarCompare(one, two) {
1777-
const cal1 = ToString(one);
1778-
const cal2 = ToString(two);
1779-
return cal1 < cal2 ? -1 : cal1 > cal2 ? 1 : 0;
1780-
}
1781-
17821732
export function CalendarEquals(one, two) {
17831733
if (one === two) return true;
17841734
const cal1 = ToString(one);
@@ -3066,19 +3016,6 @@ export function ConstrainTime(hour, minute, second, millisecond, microsecond, na
30663016
return { hour, minute, second, millisecond, microsecond, nanosecond };
30673017
}
30683018

3069-
export function ConstrainISODateTime(year, month, day, hour, minute, second, millisecond, microsecond, nanosecond) {
3070-
({ year, month, day } = ConstrainISODate(year, month, day));
3071-
({ hour, minute, second, millisecond, microsecond, nanosecond } = ConstrainTime(
3072-
hour,
3073-
minute,
3074-
second,
3075-
millisecond,
3076-
microsecond,
3077-
nanosecond
3078-
));
3079-
return { year, month, day, hour, minute, second, millisecond, microsecond, nanosecond };
3080-
}
3081-
30823019
export function RejectToRange(value, min, max) {
30833020
if (value < min || value > max) throw new RangeError(`value out of range: ${min} <= ${value} <= ${max}`);
30843021
}
@@ -3480,17 +3417,6 @@ export function AddTime(
34803417
return { deltaDays, hour, minute, second, millisecond, microsecond, nanosecond };
34813418
}
34823419

3483-
export function SubtractDate(year, month, day, years, months, weeks, days, overflow) {
3484-
days += 7 * weeks;
3485-
day -= days;
3486-
({ year, month, day } = BalanceISODate(year, month, day));
3487-
month -= months;
3488-
year -= years;
3489-
({ year, month } = BalanceISOYearMonth(year, month));
3490-
({ year, month, day } = RegulateISODate(year, month, day, overflow));
3491-
return { year, month, day };
3492-
}
3493-
34943420
export function AddDuration(
34953421
y1,
34963422
mon1,
@@ -4297,11 +4223,6 @@ export function CompareISODate(y1, m1, d1, y2, m2, d2) {
42974223
return 0;
42984224
}
42994225

4300-
export function AssertPositiveInteger(num) {
4301-
if (!NumberIsFinite(num) || MathAbs(num) !== num) throw new RangeError(`invalid positive integer: ${num}`);
4302-
return num;
4303-
}
4304-
43054226
export function NonNegativeModulo(x, y) {
43064227
let result = x % y;
43074228
if (ObjectIs(result, -0)) return 0;

0 commit comments

Comments
 (0)