measure-x
Version:
A lightweight and efficient **conversion utility** that supports various **number system conversions**, unit conversions, and more. 🚀
13 lines (11 loc) • 438 B
text/typescript
import { Converter } from "../../utils/converters";
import { TIME_CONVERSION } from "./constants";
import { TimeUnit } from "./types";
export const timeConverter: Converter = {
category: "time",
units: Object.keys(TIME_CONVERSION) as TimeUnit[],
convert: (value: number, from: string, to: string) => {
const baseValue = value * TIME_CONVERSION[from as TimeUnit];
return baseValue / TIME_CONVERSION[to as TimeUnit];
},
};