Type aliases
Add
Add<A, B>: A extends 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 ? B extends 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 ? XADD[A][B] : XSUB[Negate<B>][A] : B extends 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 ? XSUB[Negate<A>][B] : Negate<XADD[Negate<A>][Negate<B>]>
Type parameters
CompleteTerms
CompleteTerms<A>: {}
Type parameters
Divide
Divide<A, B>: A extends Unit<infer TA> ? B extends Unit<infer TB> ? Unit<DivideTerms<TA, TB>> : never : never
Type parameters
DivideTerms
DivideTerms<A, B>: {}
Type parameters
Exponent
Exponent: -9 | -8 | -7 | -6 | -5 | -4 | -3 | -2 | -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
InvertTerms
InvertTerms<A>: {}
Type parameters
M
M<K, V>: {}
Type parameters
Multiply
Multiply<A, B>: A extends IUnitBase<infer TA> ? B extends IUnitBase<infer TB> ? Unit<MultiplyTerms<TA, TB>> : never : never
Type parameters
MultiplyTerms
MultiplyTerms<A, B>: {}
Type parameters
Negate
Negate<A>: XNEGATE[A]
Type parameters
OrZero
OrZero<A>: A extends number ? A : 0
Type parameters
PUnitTerms
PUnitTerms: {}
PrefixExponent
PrefixExponent: 24 | 21 | 18 | 15 | 12 | 9 | 6 | 3 | 2 | 1 | -1 | -2 | -3 | -6 | -9 | -12 | -15 | -18 | -21 | -24
PrefixName
PrefixName: "yotta" | "zetta" | "exa" | "peta" | "tera" | "giga" | "mega" | "kilo" | "hecto" | "deka" | "deci" | "centi" | "milli" | "micro" | "nano" | "pico" | "fempto" | "atto" | "zepto" | "yocto"
PrefixSymbol
PrefixSymbol: "Y" | "Z" | "E" | "P" | "T" | "G" | "M" | "k" | "h" | "da" | "d" | "c" | "m" | "μ" | "u" | "n" | "p" | "f" | "a" | "z" | "y"
PrimitiveMap
PrimitiveMap: {}
Sub
Sub<A, B>: A extends 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 ? B extends 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 ? XSUB[B][A] : XADD[Negate<B>][A] : B extends 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 ? Negate<XADD[Negate<A>][B]> : Negate<XSUB[Negate<B>][Negate<A>]>
Type parameters
TermsOfUnit
TermsOfUnit<U>: U extends Unit<infer T> ? CompleteTerms<T> : never
Type parameters
TermsOfUnitBase
TermsOfUnitBase<U>: U extends IUnitBase<infer T> ? T : never
Type parameters
XADD
XADD: [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9, 9], [2, 3, 4, 5, 6, 7, 8, 9, 9, 9], [3, 4, 5, 6, 7, 8, 9, 9, 9, 9], [4, 5, 6, 7, 8, 9, 9, 9, 9, 9], [5, 6, 7, 8, 9, 9, 9, 9, 9, 9], [6, 7, 8, 9, 9, 9, 9, 9, 9, 9], [7, 8, 9, 9, 9, 9, 9, 9, 9, 9], [8, 9, 9, 9, 9, 9, 9, 9, 9, 9], [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]]
XNEGATE
XNEGATE
: [0, -1, -2, -3, -4, -5, -6, -7, -8, -9] & M<-1, 1> & M<-2, 2> & M<-3, 3> & M<-4, 4> & M<-5, 5> & M<-6, 6> & M<-7, 7> & M<-8, 8> & M<-9, 9>
XSUB
XSUB: [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9], [-1, 0, 1, 2, 3, 4, 5, 6, 7, 8 | 9], [-2, -1, 0, 1, 2, 3, 4, 5, 6, 7 | 8 | 9], [-3, -2, -1, 0, 1, 2, 3, 4, 5, 6 | 7 | 8 | 9], [-4, -3, -2, -1, 0, 1, 2, 3, 4, 5 | 6 | 7 | 8 | 9], [-5, -4, -3, -2, -1, 0, 1, 2, 3, 4 | 5 | 6 | 7 | 8 | 9], [-6, -5, -4, -3, -2, -1, 0, 1, 2, 3 | 4 | 5 | 6 | 7 | 8 | 9], [-7, -6, -5, -4, -3, -2, -1, 0, 1, 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9], [-8, -7, -6, -5, -4, -3, -2, -1, 0, 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9], [-9, -8 | -9, -7 | -8 | -9, -6 | -7 | -8 | -9, -5 | -6 | -7 | -8 | -9, -4 | -5 | -6 | -7 | -8 | -9, -3 | -4 | -5 | -6 | -7 | -8 | -9, -2 | -3 | -4 | -5 | -6 | -7 | -8 | -9, -1 | -2 | -3 | -4 | -5 | -6 | -7 | -8 | -9, 0 | -1 | -2 | -3 | -4 | -5 | -6 | -7 | -8 | -9]]
Variables
Const ALIASES
ALIASES: {}
Type declaration
-
[k: string]: Unit & Alias
Const NAMED_UNITS
NAMED_UNITS: {}
Const ORDER
ORDER: {} = (i => {return {mass: i++,length: i++,angle: i++,solidAngle: i++,cycles: i++,amount: i++,current: i++,temperature: i++,time: i++,candela: i++};})(0)
Const PREFIXES
PREFIXES: {} = ((t: {[K in PrefixSymbol]: [PrefixExponent, PrefixName, string?]} = {Y: [24, 'yotta'],Z: [21, 'zetta'],E: [18, 'exa'],P: [15, 'peta'],T: [12, 'tera'],G: [9, 'giga'],M: [6, 'mega'],k: [3, 'kilo'],h: [2, 'hecto'],da: [1, 'deka'],d: [-1, 'deci'],c: [-2, 'centi'],m: [-3, 'milli'],μ: [-6, 'micro', TeX`\mu`],u: [-6, 'micro', TeX`\mu`], // Alternative for typing-impaired.n: [-9, 'nano'],p: [-12, 'pico'],f: [-15, 'fempto'],a: [-18, 'atto'],z: [-21, 'zepto'],y: [-24, 'yocto']}) => {const pt: any = {};Object.keys(t).forEach(k => {const kk = k === 'u' ? 'μ' : k;const a = t[kk as PrefixSymbol] as [PrefixExponent, PrefixName, string?];const p = new Prefix(kk as PrefixSymbol, ...a)pt[k] = p;pt[p.exponent] = p;pt[p.name] = p;});return pt as {[K in PrefixSymbol|PrefixName|PrefixExponent]: Prefix};})()
Const PRIMITIVE_MAP
PRIMITIVE_
MAP: Readonly<PrimitiveMap> = (() => {const val: PrimitiveMap = {} as PrimitiveMap;const defPrimitive = (u: Primitive, name: string, symbol: string, varName?: string,attributes: UnitAttributes = {}) => {const primitive = new PrimitiveUnit(u, name, symbol, varName, attributes);(val as any)[u] = primitive;return primitive;}defPrimitive(Primitive.time, 'second', 's', 't', {si_base: true});defPrimitive(Primitive.mass, 'kilogram', 'kg', 'm',{si_base: true, scale: 1000});defPrimitive(Primitive.length, 'meter', 'm', 'l', {si_base: true});defPrimitive(Primitive.amount, 'mole', 'mol', 'n', {si_base: true});defPrimitive(Primitive.cycles, 'cycle', 'cycle', 'c');defPrimitive(Primitive.angle, 'radian', 'rad', '𝜃');defPrimitive(Primitive.solidAngle, 'steridian', 'sr', undefined);defPrimitive(Primitive.current, 'ampere', 'A', 'A', {si_base: true});defPrimitive(Primitive.temperature, 'kelvin', 'K', 'T',{absolute: true, si_base: true});defPrimitive(Primitive.candela, 'candela', 'cd', 'c', {si_base: true})return val as PrimitiveMap;})()
Const RE_identifier
RE_identifier: RegExp = /[\p{L}\p{Pc}\p{Pd}\p{S}][\p{L}\p{Pc}\p{Pd}\p{S}\p{N}]*/u
Const RE_name
RE_name: RegExp = new RegExp(`(${RE_prefix_name.source})?(${RE_identifier.source})`, 'u')
Const RE_prefix_name
RE_prefix_name: RegExp = /yotta|zetta|exa|peta|tera|giga|mega|kilo|hecto|deka|deci|centi|milli|micro|nano|pico|fempto|atto|zepto|yocto/
Const RE_prefix_name_concat
RE_prefix_name_concat: RegExp = new RegExp(`(${RE_prefix_name.source})${RE_whitespace_sep.source}(${RE_identifier.source})`, 'ug')
Const RE_prefix_symbol
RE_prefix_symbol: RegExp = /Y|Z|E|P|T|G|M|k|h|da|d|c|m|μ|u|n|p|f|a|z|y/
Const RE_symbol
RE_symbol: RegExp = new RegExp(`(${RE_prefix_symbol.source})?(${RE_identifier.source})`, 'u')
Const RE_whitespace
RE_whitespace: RegExp = /[\p{Z}\p{C}\p{M}]+/u
Const RE_whitespace_sep
RE_whitespace_sep: RegExp = /[\p{Z}\p{C}\p{M}\p{Pd}]+/u
Const SYMBOL_ALIASES
SYMBOL_ALIASES: {}
Type declaration
-
[k: string]: Unit & Alias
Const SYMBOL_UNITS
SYMBOL_UNITS: {}
Const TeX
TeX: raw = String.raw
Const primitiveKeys
primitive
Keys: Primitive[] = Object.keys(Primitive) as Primitive[]
Representation and manipulation of physical units.
These are based on SI, and in particular the (Guide for the Use of the International System of Units (SI))https://physics.nist.gov/cuu/pdf/sp811.pdf(https://physics.nist.gov/cuu/pdf/sp811.pdf]) However, this does not try to be complete, and extends the set of base units somewhat to aid clarity (for example, 'cycles/revolutions') while preserving semantics and standardized presentation. Having units that map to SI '1' is not very helpful sometimes.
See the Units.Units namespace for definitions of individual units.