UNPKG

vremel

Version:

JavaScript date utility library for Temporal API

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