@thi.ng/units
Version:
Extensible SI unit creation, conversions, quantities & calculations (incl. ~170 predefined units & constants)
22 lines (21 loc) • 620 B
JavaScript
import { J } from "./energy.js";
import { h, s } from "./time.js";
import { defUnit, div, mul, prefix } from "../unit.js";
const W = defUnit("W", "watt", div(J, s, true));
const mW = defUnit("mW", "milliwatt", prefix("m", W));
const kW = defUnit("kW", "kilowatt", prefix("k", W));
const MW = defUnit("MW", "megawatt", prefix("M", W));
const GW = defUnit("GW", "gigawatt", prefix("G", W));
const TW = defUnit("TW", "terawatt", prefix("T", W));
const Wh = defUnit("Wh", "watt-hour", mul(W, h, true));
const kWh = defUnit("kWh", "kilowatt-hour", prefix("k", Wh));
export {
GW,
MW,
TW,
W,
Wh,
kW,
kWh,
mW
};