UNPKG

@toreda/time

Version:

Simple, small footprint library for common time operations and converting between units of time.

22 lines (21 loc) 708 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.timeUnitSupported = timeUnitSupported; const units_1 = require("../units"); /** * Type guard: returns `true` only when `unit` is a canonical `TimeUnit`. * Aliases (e.g. `'day'`, `'sec'`) are rejected — use `timeUnitFromAlias` * to resolve aliases to canonical values first. * * @param unit Value to validate as a canonical time unit. * @returns true - `unit` is a canonical `TimeUnit`. * false - `unit` is not a canonical `TimeUnit`. * * @category Time Units */ function timeUnitSupported(unit) { if (typeof unit !== 'string') { return false; } return units_1.timeUnits.has(unit); }