@thi.ng/units
Version:
Extensible SI unit creation, conversions, quantities & calculations (incl. ~170 predefined units & constants)
23 lines (22 loc) • 691 B
JavaScript
import { cm, ft, inch, km, m, mi, mm } from "./length.js";
import { defUnit, mul, pow } from "../unit.js";
const m2 = defUnit("m2", "square meter", pow(m, 2));
const mm2 = defUnit("mm2", "square millimeter", pow(mm, 2));
const cm2 = defUnit("cm2", "square centimeter", pow(cm, 2));
const km2 = defUnit("km2", "square kilometer", pow(km, 2));
const ha = defUnit("ha", "hectar", mul(m2, 1e4));
const ac = defUnit("ac", "acre", mul(m2, 4046.86));
const sqin = defUnit("sqin", "square inch", pow(inch, 2));
const sqft = defUnit("sqft", "square foot", pow(ft, 2));
const sqmi = defUnit("sqmi", "square mile", pow(mi, 2));
export {
ac,
cm2,
ha,
km2,
m2,
mm2,
sqft,
sqin,
sqmi
};