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 • 782 B
import { TimeUnit } from "../../types/time-unit.js"; import "../../types/index.js"; /** * Return true when `unit` is a valid TimeUnit. * * - Valid units are: "hour", "minute", "second", "millisecond", "microsecond", "nanosecond". * - Accepts any input type and returns false for non-string values. * - Uses type assertion to narrow the type. * * @param unit candidate value of any type * @returns boolean indicating validity * * @example isValidTimeUnit("hour") // true * @example isValidTimeUnit("minute") // true * @example isValidTimeUnit("second") // true * @example isValidTimeUnit("invalid") // false * @example isValidTimeUnit(123) // false * @example isValidTimeUnit(null) // false */ export declare function isValidTimeUnit(unit: unknown): unit is TimeUnit;