Skip to content

Commit c18b254

Browse files
committed
feat: assert all intermediate values are valid
1 parent 1b05f29 commit c18b254

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/util/luxon-utils.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,14 @@ export function assertValidDateTimeFormat(
6060
* @returns An equivalent minimal set of Intervals without any intersections.
6161
*/
6262
export function mergeIntersecting(input: Interval<true>[]): Interval<true>[] {
63+
input.forEach((interval) => assertValidLuxonValue(interval));
6364
const sortedOutput: Interval<true>[] = [];
6465
for (const sortedNext of sortBy(input, ["start", "end"])) {
6566
const prevIndex = sortedOutput.length - 1;
6667
if (prevIndex >= 0 && sortedOutput[prevIndex].intersection(sortedNext)) {
67-
sortedOutput[prevIndex] = sortedOutput[prevIndex].union(sortedNext) as Interval<true>;
68+
const union = sortedOutput[prevIndex].union(sortedNext);
69+
assertValidLuxonValue(union);
70+
sortedOutput[prevIndex] = union;
6871
} else {
6972
sortedOutput.push(sortedNext);
7073
}

0 commit comments

Comments
 (0)