@toreda/time
Version:
Simple, small footprint library for common time operations and converting between units of time.
23 lines (22 loc) • 676 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.timeUnitSupported = void 0;
const units_1 = require("../units");
/**
* Check if time unit is supported.
* @param unit String to validate as supported time unit.
* @returns true - Provided `unit` string is a supported time unit.
* false - Provided `unit` string is not a supported time unit.
*
* @category Time Units
*/
function timeUnitSupported(unit) {
if (!unit) {
return false;
}
if (!units_1.timeUnits.has(unit)) {
return false;
}
return typeof units_1.timeUnits.get(unit) === 'string';
}
exports.timeUnitSupported = timeUnitSupported;