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.

26 lines (25 loc) • 947 B
// src/internal/rangeHooks.ts let installed; /** Stand-ins whose own `formatRange` already repairs the year. */ const handled = /* @__PURE__ */ new WeakSet(); /** Install the range repairs (called once, by `ensureRangeHooks` in `rangeRepairs.ts`). */ function registerRangeHooks(hooks) { installed = hooks; } /** The installed range repairs, or `undefined` in a bundle that formats no range. */ function rangeHooks() { return installed; } /** Record a stand-in whose `formatRange` is the installed `checked` already. */ function markRangeHandled(standIn) { handled.add(standIn); } /** Whether the stand-in repairs its own range. */ function isRangeHandled(formatter) { return handled.has(formatter); } /** Forget the range modules' caches, when any are installed. */ function forgetRanges() { for (const forget of installed?.forget ?? []) forget(); } export { forgetRanges, isRangeHandled, markRangeHandled, rangeHooks, registerRangeHooks };