UNPKG

@northguild/gmt

Version:

Date and time library for JavaScript and TypeScript, built on TC39 Temporal: time zones, DST, business days, ISO 8601 strings in and out. Never throws.

20 lines (19 loc) • 835 B
// src/internal/resolveOverflow.ts /** * Resolve an optional overflow value to its default ("constrain") when unset. * * - Only an *omitted* member takes the default. Temporal's GetOption reads any other value, * `null` included, through ToString, so `{ overflow: null }` is the string "null" and a * RangeError — never "constrain" (Chromium 153: "Value null out of range for * Temporal.PlainDate.prototype.add options property overflow"). Passing it through is what * lets the caller's `catch` return its sentinel. * * @param overflow optional overflow value * @example resolveOverflow(undefined) // "constrain" * @example resolveOverflow("reject") // "reject" * @returns the resolved overflow value */ function resolveOverflow(overflow) { return overflow === void 0 ? "constrain" : overflow; } export { resolveOverflow };