UNPKG

@thi.ng/units

Version:

Extensible SI unit creation, conversions, quantities & calculations (incl. ~170 predefined units & constants)

24 lines (23 loc) 667 B
import { coherent, defUnit, mul, prefix } from "../unit.js"; const s = defUnit("s", "second", coherent(2)); const ms = defUnit("ms", "millisecond", prefix("m", s)); const \u00B5s = defUnit("\xB5s", "microsecond", prefix("\xB5", s)); const ns = defUnit("ns", "nanosecond", prefix("n", s)); const min = defUnit("min", "minute", mul(s, 60)); const h = defUnit("h", "hour", mul(min, 60)); const d = defUnit("day", "day", mul(h, 24)); const week = defUnit("week", "week", mul(d, 7)); const month = defUnit("month", "month", mul(d, 30)); const year = defUnit("year", "year", mul(d, 365.25)); export { d, h, min, month, ms, ns, s, week, year, \u00B5s };