diff --git a/packages/units/src/data.ts b/packages/units/src/data.ts index 5ffa05b173..64e97ee880 100644 --- a/packages/units/src/data.ts +++ b/packages/units/src/data.ts @@ -6,8 +6,6 @@ export const Mbit = defUnit("Mbit", "megabit", prefix("M", bit)); export const Gbit = defUnit("Gbit", "gigabit", prefix("G", bit)); export const Tbit = defUnit("Tbit", "terabit", prefix("T", bit)); -// https://en.wikipedia.org/wiki/Byte#Multiple-byte_units - export const B = defUnit("B", "byte", mul(bit, 8, true)); export const kB = defUnit("kB", "kilobyte", prefix("k", B)); export const MB = defUnit("MB", "megabyte", prefix("M", B)); @@ -16,6 +14,15 @@ export const TB = defUnit("TB", "terabyte", prefix("T", B)); export const PB = defUnit("PB", "petabyte", prefix("P", B)); export const EB = defUnit("EB", "exabyte", prefix("E", B)); +// https://en.wikipedia.org/wiki/Byte#Multiple-byte_units + +export const Kibit = defUnit("Kibit", "kibibit", mul(bit, 1024)); +export const Mibit = defUnit("Mibit", "mebibit", mul(Kibit, 1024)); +export const Gibit = defUnit("Gibit", "gibibit", mul(Mibit, 1024)); +export const Tibit = defUnit("Tibit", "tebibit", mul(Gibit, 1024)); +export const Pibit = defUnit("Pibit", "pebibit", mul(Tibit, 1024)); +export const Eibit = defUnit("Eibit", "exbibit", mul(Pibit, 1024)); + export const KiB = defUnit("KiB", "kibibyte", mul(B, 1024)); export const MiB = defUnit("MiB", "mebibyte", mul(KiB, 1024)); export const GiB = defUnit("GiB", "gibibyte", mul(MiB, 1024)); diff --git a/packages/units/src/electric.ts b/packages/units/src/electric.ts index a4d0043716..0689c61c0b 100644 --- a/packages/units/src/electric.ts +++ b/packages/units/src/electric.ts @@ -23,6 +23,12 @@ export const kΩ = defUnit("kΩ", "kiloohm", prefix("k", Ω)); export const MΩ = defUnit("MΩ", "megaohm", prefix("M", Ω)); export const GΩ = defUnit("GΩ", "gigaohm", prefix("G", Ω)); +// latin aliases +export const ohm = Ω; +export const kohm = kΩ; +export const Mohm = MΩ; +export const Gohm = GΩ; + export const S = defUnit("S", "siemens", div(A, V, true)); export const Wb = defUnit("Wb", "weber", mul(V, s, true)); export const T = defUnit("T", "tesla", div(Wb, m2, true)); diff --git a/packages/units/src/frequency.ts b/packages/units/src/frequency.ts index b35c869864..eb93bd4a2d 100644 --- a/packages/units/src/frequency.ts +++ b/packages/units/src/frequency.ts @@ -9,3 +9,4 @@ export const THz = defUnit("THz", "terahertz", prefix("T", Hz)); export const rpm = defUnit("rpm", "rotation per minute", mul(Hz, 1 / 60)); export const ω = defUnit("ω", "radian per second", div(Hz, 2 * Math.PI)); +export const omega = ω; diff --git a/packages/units/src/index.ts b/packages/units/src/index.ts index 8163e41792..934504f6fc 100644 --- a/packages/units/src/index.ts +++ b/packages/units/src/index.ts @@ -12,6 +12,7 @@ export * from "./frequency.js"; export * from "./length.js"; export * from "./luminous.js"; export * from "./mass.js"; +export * from "./parts.js"; export * from "./power.js"; export * from "./pressure.js"; export * from "./speed.js"; diff --git a/packages/units/src/length.ts b/packages/units/src/length.ts index 48a92eccc7..7979275741 100644 --- a/packages/units/src/length.ts +++ b/packages/units/src/length.ts @@ -1,14 +1,21 @@ import { coherent, defUnit, mul, prefix } from "./unit.js"; export const m = defUnit("m", "meter", coherent(1)); +export const km = defUnit("km", "kilometer", prefix("k", m)); export const cm = defUnit("cm", "centimeter", prefix("c", m)); export const mm = defUnit("mm", "millimeter", prefix("m", m)); export const µm = defUnit("µm", "micrometer", prefix("µ", m)); export const nm = defUnit("nm", "nanometer", prefix("n", m)); -export const km = defUnit("km", "kilometer", prefix("k", m)); +export const angstrom = defUnit("Å", "angstrom", mul(m, 1e-10)); + export const au = defUnit("au", "astronomical unit", mul(m, 149597870700)); +export const ly = defUnit("ly", "light year", mul(m, 9.4607304725808e15)); +export const pc = defUnit("pc", "parsec", mul(au, (180 * 60 * 60) / Math.PI)); export const inch = defUnit("in", "inch", mul(m, 0.0254)); +export const mil = defUnit("mil", "mil", mul(inch, 1e-3)); +export const thou = mil; + export const ft = defUnit("ft", "foot", mul(inch, 12)); export const yd = defUnit("yd", "yard", mul(ft, 3)); export const mi = defUnit("mi", "mile", mul(yd, 1760)); diff --git a/packages/units/src/parts.ts b/packages/units/src/parts.ts new file mode 100644 index 0000000000..5baf0d452c --- /dev/null +++ b/packages/units/src/parts.ts @@ -0,0 +1,9 @@ +import { defUnit, dimensionless } from "./unit.js"; + +export const percent = defUnit("%", "percent", dimensionless(1e-2)); +export const permille = defUnit("‰", "permille", dimensionless(1e-3)); +export const permyriad = defUnit("‱", "permyriad", dimensionless(1e-4)); +export const pcm = defUnit("pcm", "part per cent mille", dimensionless(1e-5)); +export const ppm = defUnit("ppm", "part per million", dimensionless(1e-6)); +export const ppb = defUnit("ppb", "part per billion", dimensionless(1e-9)); +export const ppt = defUnit("ppt", "part per trillion", dimensionless(1e-12));