UNPKG

convert

Version:

The smallest & fastest library for really easy, totally type-safe unit conversions in TypeScript & JavaScript

39 lines (38 loc) 1.08 kB
import type { MeasureKind } from "../conversions/types.js"; import type { MeasureKindByUnit, Unit } from "../types/units.js"; /** * Get the {@link MeasureKind} associated with a unit. * * @example * ```ts * getMeasure('m'); // MeasureKind.Length * ``` * @example * ```ts * getMeasure('invalid'); // undefined * ``` * * @param unit - The unit you want to get the measure kind of * @returns The {@link MeasureKind} corresponding to this unit of measure, or `undefined` if the unit is invalid * * @public */ export declare function getMeasureKind<U extends Unit>(unit: U): MeasureKindByUnit<U>; /** * Get the {@link MeasureKind} associated with a unit. * * @example * ```ts * getMeasure('m'); // MeasureKind.Length * ``` * @example * ```ts * getMeasure('invalid'); // undefined * ``` * * @param unit - The unit you want to get the measure kind of * @returns The {@link MeasureKind} corresponding to this unit of measure, or `undefined` if the unit is invalid * * @public */ export declare function getMeasureKind(unit: string): MeasureKind | undefined;