UNPKG

vremel

Version:

JavaScript date utility library for Temporal API

14 lines 495 B
import { isPlainMonthDay } from "../type-utils.js"; import { compare } from "./_compare.js"; /** * Returns the latest of the given datetime objects. * @param dateTimes array of datetime objects * @returns the latest of the datetime objects */ export function latest(dateTimes) { if (dateTimes.some(isPlainMonthDay)) { throw new Error("Can't compare PlainMonthDay"); } return dateTimes.reduce((a, b) => (compare(a, b) === -1 ? b : a)); } //# sourceMappingURL=latest.js.map