UNPKG

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
import { AREA_CONVERSION } from "./constants"; import { AreaUnit } from "./types"; import { Converter } from "../../utils/converters"; export const areaConverter: Converter = { category: "area", units: Object.keys(AREA_CONVERSION) as AreaUnit[], convert: (value: number, from: string, to: string) => { const baseValue = value * AREA_CONVERSION[from as AreaUnit]; return baseValue / AREA_CONVERSION[to as AreaUnit]; }, };