@thi.ng/units
Version:
Extensible SI unit creation, conversions, quantities & calculations (incl. ~170 predefined units & constants)
53 lines (52 loc) • 1.49 kB
JavaScript
import { m2 } from "./area.js";
import { J } from "./energy.js";
import { h, s } from "./time.js";
import { coherent, defUnit, div, mul, prefix } from "../unit.js";
const A = defUnit("A", "ampere", coherent(3));
const mA = defUnit("mA", "milliampere", prefix("m", A));
const mAh = defUnit("mAh", "milliampere-hour", mul(mA, h));
const C = defUnit("C", "coulomb", mul(A, s, true));
const V = defUnit("V", "volt", div(J, C, true));
const mV = defUnit("mV", "millivolt", prefix("m", V));
const kV = defUnit("kV", "kilovolt", prefix("k", V));
const MV = defUnit("MV", "megavolt", prefix("M", V));
const F = defUnit("F", "farad", div(C, V, true));
const pF = defUnit("pF", "picofarad", prefix("p", F));
const \u00B5F = defUnit("\xB5F", "microfarad", prefix("\xB5", F));
const \u03A9 = defUnit("\u03A9", "ohm", div(V, A, true));
const k\u03A9 = defUnit("k\u03A9", "kiloohm", prefix("k", \u03A9));
const M\u03A9 = defUnit("M\u03A9", "megaohm", prefix("M", \u03A9));
const G\u03A9 = defUnit("G\u03A9", "gigaohm", prefix("G", \u03A9));
const ohm = \u03A9;
const kohm = k\u03A9;
const Mohm = M\u03A9;
const Gohm = G\u03A9;
const S = defUnit("S", "siemens", div(A, V, true));
const Wb = defUnit("Wb", "weber", mul(V, s, true));
const T = defUnit("T", "tesla", div(Wb, m2, true));
const H = defUnit("H", "henry", div(Wb, A, true));
export {
A,
C,
F,
Gohm,
G\u03A9,
H,
MV,
Mohm,
M\u03A9,
S,
T,
V,
Wb,
kV,
kohm,
k\u03A9,
mA,
mAh,
mV,
ohm,
pF,
\u00B5F,
\u03A9
};