cbi-units-converter
Version:
Forked from units-converter. A simple utility library to measure and convert between units
2,020 lines (1,916 loc) • 40.4 kB
JavaScript
'use strict';
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var utils = _interopDefault(require('../utils.js'));
const acceleration = {
metric: {
baseUnit: 'g-force',
transform: (val) => { return val * 1 },
'g-force': {
name: {
singular: 'g-force',
plural: 'g-forces'
},
to_anchor: 9.80665
},
'm/s2': {
name: {
singular: 'Metre per second squared',
plural: 'Metres per second squared'
},
to_anchor: 1
}
}
};
var acceleration$1 = utils(acceleration);
const RATIO = 1;
const PI = 3.141592653589793;
const angle = {
metric: {
baseUnit: 'g-force',
transform: (val) => { return val * RATIO },
rad: {
name: {
singular: 'radian',
plural: 'radians'
},
to_anchor: 180 / PI
},
deg: {
name: {
singular: 'degree',
plural: 'degrees'
},
to_anchor: 1
},
grad: {
name: {
singular: 'gradian',
plural: 'gradians'
},
to_anchor: 9 / 10
},
arcmin: {
name: {
singular: 'arcminute',
plural: 'arcminutes'
},
to_anchor: 1 / 60
},
arcsec: {
name: {
singular: 'arcsecond',
plural: 'arcseconds'
},
to_anchor: 1 / 3600
}
}
};
var angle$1 = utils(angle);
const apparentPower = {
metric: {
baseUnit: 'VA',
transform: (val) => { return val * 1 },
VA: {
name: {
singular: 'Volt-Ampere',
plural: 'Volt-Amperes'
},
to_anchor: 1
},
mVA: {
name: {
singular: 'Millivolt-Ampere',
plural: 'Millivolt-Amperes'
},
to_anchor: 0.001
},
kVA: {
name: {
singular: 'Kilovolt-Ampere',
plural: 'Kilovolt-Amperes'
},
to_anchor: 1000
},
MVA: {
name: {
singular: 'Megavolt-Ampere',
plural: 'Megavolt-Amperes'
},
to_anchor: 1000000
},
GVA: {
name: {
singular: 'Gigavolt-Ampere',
plural: 'Gigavolt-Amperes'
},
to_anchor: 1000000000
}
}
};
var apparentPower$1 = utils(apparentPower);
const RATIO$1 = 10.7639;
const area = {
metric: {
baseUnit: 'm2',
transform: (val) => { return val * RATIO$1 },
mm2: {
name: {
singular: 'Square Millimeter',
plural: 'Square Millimeters'
},
to_anchor: 1 / 1000000
},
cm2: {
name: {
singular: 'Square Centimeter',
plural: 'Square Centimeters'
},
to_anchor: 1 / 10000
},
m2: {
name: {
singular: 'Square Meter',
plural: 'Square Meters'
},
to_anchor: 1
},
ha: {
name: {
singular: 'Hectare',
plural: 'Hectares'
},
to_anchor: 10000
},
km2: {
name: {
singular: 'Square Kilometer',
plural: 'Square Kilometers'
},
to_anchor: 1000000
}
},
imperial: {
baseUnit: 'ft2',
transform: (val) => { return val * 1 / RATIO$1 },
'in2': {
name: {
singular: 'Square Inch',
plural: 'Square Inches'
},
to_anchor: 1 / 144
},
yd2: {
name: {
singular: 'Square Yard',
plural: 'Square Yards'
},
to_anchor: 9
},
ft2: {
name: {
singular: 'Square Foot',
plural: 'Square Feet'
},
to_anchor: 1
},
ac: {
name: {
singular: 'Acre',
plural: 'Acres'
},
to_anchor: 43560
},
mi2: {
name: {
singular: 'Square Mile',
plural: 'Square Miles'
},
to_anchor: 27878400
}
}
};
var area$1 = utils(area);
const RATIO$2 = 1;
const charge = {
metric: {
baseUnit: 'c',
transform: (val) => { return RATIO$2 * val },
c: {
name: {
singular: 'Coulomb',
plural: 'Coulombs'
},
to_anchor: 1
},
mC: {
name: {
singular: 'Millicoulomb',
plural: 'Millicoulombs'
},
to_anchor: 1 / 1000
},
μC: {
name: {
singular: 'Microcoulomb',
plural: 'Microcoulombs'
},
to_anchor: 1 / 1000000
},
nC: {
name: {
singular: 'Nanocoulomb',
plural: 'Nanocoulombs'
},
to_anchor: 1e-9
},
pC: {
name: {
singular: 'Picocoulomb',
plural: 'Picocoulombs'
},
to_anchor: 1e-12
}
}
};
var charge$1 = utils(charge);
const RATIO$3 = 1;
const current = {
metric: {
baseUnit: 'a',
transform: (val) => { return RATIO$3 * val },
A: {
name: {
singular: 'Ampere',
plural: 'Amperes'
},
to_anchor: 1
},
mA: {
name: {
singular: 'Milliampere',
plural: 'Milliamperes'
},
to_anchor: 0.001
},
kA: {
name: {
singular: 'Kiloampere',
plural: 'Kiloamperes'
},
to_anchor: 1000
}
}
};
var current$1 = utils(current);
const RATIO$4 = 8;
const digitals = {
bits: {
baseUnit: 'b',
transform: (val) => { return val * 1 / RATIO$4 },
b: {
name: {
singular: 'Bit',
plural: 'Bits'
},
to_anchor: 1
},
Kb: {
name: {
singular: 'Kilobit',
plural: 'Kilobits'
},
to_anchor: 1024
},
Mb: {
name: {
singular: 'Megabit',
plural: 'Megabits'
},
to_anchor: 1048576
},
Gb: {
name: {
singular: 'Gigabit',
plural: 'Gigabits'
},
to_anchor: 1073741824
},
Tb: {
name: {
singular: 'Terabit',
plural: 'Terabits'
},
to_anchor: 1099511627776
}
},
bytes: {
baseUnit: 'B',
transform: (val) => { return val * RATIO$4 },
B: {
name: {
singular: 'Byte',
plural: 'Bytes'
},
to_anchor: 1
},
KB: {
name: {
singular: 'Kilobyte',
plural: 'Kilobytes'
},
to_anchor: 1024
},
MB: {
name: {
singular: 'Megabyte',
plural: 'Megabytes'
},
to_anchor: 1048576
},
GB: {
name: {
singular: 'Gigabyte',
plural: 'Gigabytes'
},
to_anchor: 1073741824
},
TB: {
name: {
singular: 'Terabyte',
plural: 'Terabytes'
},
to_anchor: 1099511627776
}
}
};
var digital = utils(digitals);
const RATIO$5 = 1;
const each = {
metric: {
baseUnit: 'ea',
transform: (val) => { return RATIO$5 * val },
ea: {
name: {
singular: 'Each',
plural: 'Each'
},
to_anchor: 1
},
dz: {
name: {
singular: 'Dozen',
plural: 'Dozens'
},
to_anchor: 12
}
}
};
var each$1 = utils(each);
const RATIO$6 = 1;
const energy = {
metric: {
baseUnit: 'J',
transform: (val) => { return RATIO$6 * val },
Wh: {
name: {
singular: 'Watt-hour',
plural: 'Watt-hours'
},
to_anchor: 3600
},
mWh: {
name: {
singular: 'Milliwatt-hour',
plural: 'Milliwatt-hours'
},
to_anchor: 3.6
},
kWh: {
name: {
singular: 'Kilowatt-hour',
plural: 'Kilowatt-hours'
},
to_anchor: 3600000
},
MWh: {
name: {
singular: 'Megawatt-hour',
plural: 'Megawatt-hours'
},
to_anchor: 3600000000
},
GWh: {
name: {
singular: 'Gigawatt-hour',
plural: 'Gigawatt-hours'
},
to_anchor: 3600000000000
},
J: {
name: {
singular: 'Joule',
plural: 'Joules'
},
to_anchor: 1
},
kJ: {
name: {
singular: 'Kilojoule',
plural: 'Kilojoules'
},
to_anchor: 1000
}
}
};
var energy$1 = utils(energy);
const RATIO$7 = 4.44822;
const force = {
metric: {
baseUnit: 'N',
transform: (val) => { return val * 1 / RATIO$7 },
N: {
name: {
singular: 'Newton',
plural: 'Newtons'
},
to_anchor: 1
},
kN: {
name: {
singular: 'Kilonewton',
plural: 'Kilonewtons'
},
to_anchor: 1000
}
},
imperial: {
baseUnit: 'lbf',
transform: (val) => { return RATIO$7 * val },
lbf: {
name: {
singular: 'Pound-force',
plural: 'Pound-forces'
},
to_anchor: 1
}
}
};
var force$1 = utils(force);
const RATIO$8 = 1;
const PI$1 = 3.141592653589793;
const frequency = {
metric: {
baseUnit: 'Hz',
transform: (val) => { return RATIO$8 * val },
mHz: {
name: {
singular: 'millihertz',
plural: 'millihertz'
},
to_anchor: 1 / 1000
},
Hz: {
name: {
singular: 'hertz',
plural: 'hertz'
},
to_anchor: 1
},
kHz: {
name: {
singular: 'kilohertz',
plural: 'kilohertz'
},
to_anchor: 1000
},
MHz: {
name: {
singular: 'megahertz',
plural: 'megahertz'
},
to_anchor: 1000 * 1000
},
GHz: {
name: {
singular: 'gigahertz',
plural: 'gigahertz'
},
to_anchor: 1000 * 1000 * 1000
},
THz: {
name: {
singular: 'terahertz',
plural: 'terahertz'
},
to_anchor: 1000 * 1000 * 1000 * 1000
},
rpm: {
name: {
singular: 'rotation per minute',
plural: 'rotations per minute'
},
to_anchor: 1 / 60
},
'deg/s': {
name: {
singular: 'degree per second',
plural: 'degrees per second'
},
to_anchor: 1 / 360
},
'rad/s': {
name: {
singular: 'radian per second',
plural: 'radians per second'
},
to_anchor: 1 / (PI$1 * 2)
}
}
};
var frequency$1 = utils(frequency);
const RATIO$9 = 10.76391;
const illuminance = {
metric: {
baseUnit: 'lx',
transform: (val) => { return val * 1 / RATIO$9 },
'lx': {
name: {
singular: 'Lux',
plural: 'Lux'
},
to_anchor: 1
}
},
imperial: {
baseUnit: 'ft-cd',
transform: (val) => { return RATIO$9 * val },
'ft-cd': {
name: {
singular: 'Foot-candle',
plural: 'Foot-candles'
},
to_anchor: 1
}
}
};
var illuminance$1 = utils(illuminance);
const RATIO$a = 3.28084;
const length = {
metric: {
baseUnit: 'm',
transform: (val) => { return val * RATIO$a },
mm: {
name: {
singular: 'Millimeter',
plural: 'Millimeters'
},
to_anchor: 1 / 1000
},
cm: {
name: {
singular: 'Centimeter',
plural: 'Centimeters'
},
to_anchor: 1 / 100
},
m: {
name: {
singular: 'Meter',
plural: 'Meters'
},
to_anchor: 1
},
km: {
name: {
singular: 'Kilometer',
plural: 'Kilometers'
},
to_anchor: 1000
},
'.1 mm': {
name: {
singular: '.1 mm',
plural: '.1 mm'
},
to_anchor: 1 / 10000
}
},
imperial: {
baseUnit: 'ft',
transform: (val) => { return val * 1 / RATIO$a },
'in': {
name: {
singular: 'Inch',
plural: 'Inches'
},
to_anchor: 1 / 12
},
yd: {
name: {
singular: 'Yard',
plural: 'Yards'
},
to_anchor: 3
},
'ft-us': {
name: {
singular: 'US Survey Foot',
plural: 'US Survey Feet'
},
to_anchor: 1.000002
},
ft: {
name: {
singular: 'Foot',
plural: 'Feet'
},
to_anchor: 1
},
fathom: {
name: {
singular: 'Fathom',
plural: 'Fathoms'
},
to_anchor: 6
},
mi: {
name: {
singular: 'Mile',
plural: 'Miles'
},
to_anchor: 5280
},
nMi: {
name: {
singular: 'Nautical Mile',
plural: 'Nautical Miles'
},
to_anchor: 6076.12
}
}
};
var length$1 = utils(length);
const RATIO$b = 1;
const light = {
metric: {
baseUnit: 'ntu',
transform: (val) => { return val * RATIO$b },
ntu: {
name: {
singular: 'Nephelometric Turbidity Ratio Unit (NTRU)',
plural: 'Nephelometric Turbidity Ratio Unit (NTRU)'
},
to_anchor: 1
},
'.1 ntu': {
name: {
singular: '.1 ntu',
plural: '.1 ntu'
},
to_anchor: 1 / 10
}
}
};
var light$1 = utils(light);
const RATIO$c = 453.592;
const mass = {
metric: {
baseUnit: 'g',
transform: (val) => { return val * 1 / RATIO$c },
mcg: {
name: {
singular: 'Microgram',
plural: 'Micrograms'
},
to_anchor: 1 / 1000000
},
mg: {
name: {
singular: 'Milligram',
plural: 'Milligrams'
},
to_anchor: 1 / 1000
},
g: {
name: {
singular: 'Gram',
plural: 'Grams'
},
to_anchor: 1
},
kg: {
name: {
singular: 'Kilogram',
plural: 'Kilograms'
},
to_anchor: 1000
},
mt: {
name: {
singular: 'Metric Tonne',
plural: 'Metric Tonnes'
},
to_anchor: 1000000
}
},
imperial: {
baseUnit: 'lb',
transform: (val) => { return val * RATIO$c },
oz: {
name: {
singular: 'Ounce',
plural: 'Ounces'
},
to_anchor: 1 / 16
},
lb: {
name: {
singular: 'Pound',
plural: 'Pounds'
},
to_anchor: 1
},
t: {
name: {
singular: 'Ton',
plural: 'Tons'
},
to_anchor: 2000
}
}
};
var mass$1 = utils(mass);
const RATIO$d = 0.3048;
const pace = {
metric: {
baseUnit: 's/m',
transform: (val) => { return val * RATIO$d },
'min/km': {
name: {
singular: 'Minute per kilometre',
plural: 'Minutes per kilometre'
},
to_anchor: 0.06
},
's/m': {
name: {
singular: 'Second per metre',
plural: 'Seconds per metre'
},
to_anchor: 1
}
},
imperial: {
baseUnit: 's/ft',
transform: (val) => { return val * 1 / RATIO$d },
'min/mi': {
name: {
singular: 'Minute per mile',
plural: 'Minutes per mile'
},
to_anchor: 0.0113636
},
's/ft': {
name: {
singular: 'Second per foot',
plural: 'Seconds per foot'
},
to_anchor: 1
}
}
};
var pace$1 = utils(pace);
const RATIO$e = 0.000001;
const partsPer = {
metric: {
baseUnit: 'ppm',
transform: (val) => { return val * RATIO$e },
ppm: {
name: {
singular: 'Part-per Million',
plural: 'Parts-per Million'
},
to_anchor: 1
},
ppb: {
name: {
singular: 'Part-per Billion',
plural: 'Parts-per Billion'
},
to_anchor: 0.001
},
ppt: {
name: {
singular: 'Part-per Trillion',
plural: 'Parts-per Trillion'
},
to_anchor: 0.000001
},
ppq: {
name: {
singular: 'Part-per Quadrillion',
plural: 'Parts-per Quadrillion'
},
to_anchor: 0.000000001
}
}
};
var partsPer$1 = utils(partsPer);
const RATIO$f = 1;
const power = {
metric: {
baseUnit: 'W',
transform: (val) => { return val * RATIO$f },
W: {
name: {
singular: 'Watt',
plural: 'Watts'
},
to_anchor: 1
},
mW: {
name: {
singular: 'Milliwatt',
plural: 'Milliwatts'
},
to_anchor: 0.001
},
kW: {
name: {
singular: 'Kilowatt',
plural: 'Kilowatts'
},
to_anchor: 1000
},
MW: {
name: {
singular: 'Megawatt',
plural: 'Megawatts'
},
to_anchor: 1000000
},
GW: {
name: {
singular: 'Gigawatt',
plural: 'Gigawatts'
},
to_anchor: 1000000000
}
}
};
var power$1 = utils(power);
const RATIO$g = 0.00014503768078;
const pressure = {
metric: {
baseUnit: 'kPa',
transform: (val) => { return val * RATIO$g },
Pa: {
name: {
singular: 'pascal',
plural: 'pascals'
},
to_anchor: 1 / 1000
},
kPa: {
name: {
singular: 'kilopascal',
plural: 'kilopascals'
},
to_anchor: 1
},
MPa: {
name: {
singular: 'megapascal',
plural: 'megapascals'
},
to_anchor: 1000
},
hPa: {
name: {
singular: 'hectopascal',
plural: 'hectopascals'
},
to_anchor: 1 / 10
},
'.1 millibars': {
name: {
singular: '.1 millibar',
plural: '.1 millibars'
},
to_anchor: 1 / 100
},
mbar: {
name: {
singular: 'millibar',
plural: 'millibars'
},
to_anchor: 1 / 10
},
bar: {
name: {
singular: 'bar',
plural: 'bar'
},
to_anchor: 100
},
mmHg: {
name: {
singular: 'mm Hg',
plural: 'mm Hg'
},
to_anchor: 0.13332239
},
torr: {
name: {
singular: 'torr',
plural: 'torr'
},
to_anchor: 101325 / 760000
},
inHg: {
name: {
singular: 'inch Hg',
plural: 'inches Hg'
},
to_anchor: 3.38639
}
},
imperial: {
baseUnit: 'psi',
transform: (val) => { return val * 1 / RATIO$g },
psi: {
name: {
singular: 'pound per square inch',
plural: 'pounds per square inch'
},
to_anchor: 1 / 1000
},
ksi: {
name: {
singular: 'kilopound per square inch',
plural: 'kilopound per square inch'
},
to_anchor: 1
}
}
};
var pressure$1 = utils(pressure);
const RATIO$h = 1;
const reactiveEnergy = {
metric: {
baseUnit: 'VARh',
transform: (val) => { return val * RATIO$h },
VARh: {
name: {
singular: 'Volt-Ampere Reactive Hour',
plural: 'Volt-Amperes Reactive Hour'
},
to_anchor: 1
},
mVARh: {
name: {
singular: 'Millivolt-Ampere Reactive Hour',
plural: 'Millivolt-Amperes Reactive Hour'
},
to_anchor: 0.001
},
kVARh: {
name: {
singular: 'Kilovolt-Ampere Reactive Hour',
plural: 'Kilovolt-Amperes Reactive Hour'
},
to_anchor: 1000
},
MVARh: {
name: {
singular: 'Megavolt-Ampere Reactive Hour',
plural: 'Megavolt-Amperes Reactive Hour'
},
to_anchor: 1000000
},
GVARh: {
name: {
singular: 'Gigavolt-Ampere Reactive Hour',
plural: 'Gigavolt-Amperes Reactive Hour'
},
to_anchor: 1000000000
}
}
};
var reactiveEnergy$1 = utils(reactiveEnergy);
const RATIO$i = 1;
const reactivePower = {
metric: {
baseUnit: 'VAR',
transform: (val) => { return val * RATIO$i },
VAR: {
name: {
singular: 'Volt-Ampere Reactive',
plural: 'Volt-Amperes Reactive'
},
to_anchor: 1
},
mVAR: {
name: {
singular: 'Millivolt-Ampere Reactive',
plural: 'Millivolt-Amperes Reactive'
},
to_anchor: 0.001
},
kVAR: {
name: {
singular: 'Kilovolt-Ampere Reactive',
plural: 'Kilovolt-Amperes Reactive'
},
to_anchor: 1000
},
MVAR: {
name: {
singular: 'Megavolt-Ampere Reactive',
plural: 'Megavolt-Amperes Reactive'
},
to_anchor: 1000000
},
GVAR: {
name: {
singular: 'Gigavolt-Ampere Reactive',
plural: 'Gigavolt-Amperes Reactive'
},
to_anchor: 1000000000
}
}
};
var reactivePower$1 = utils(reactivePower);
// Measurements: https://www.dpi.nsw.gov.au/agriculture/soils/salinity/general-information/measuring
const RATIO$j = 1;
const salinity = {
metric: {
baseUnit: 'dS',
transform: (val) => { return val * RATIO$j },
dS: {
name: {
singular: 'deciSiemens per metre',
plural: 'deciSiemens per metres',
abbreviation: 'dS/m'
},
to_anchor: 1
},
mS: {
name: {
singular: 'milliSiemens per centimetre',
plural: 'milliSiemens per centimetres',
abbreviation: 'mS/cm'
},
to_anchor: 1
},
uS: {
name: {
singular: 'microSiemen/cm',
plural: 'microSiemens/cm',
abbreviation: 'uS/cm'
},
to_anchor: 1 / 1000
},
EC: {
name: {
singular: 'electrical conductivity',
plural: 'electrical conductivity',
abbreviation: 'EC'
},
to_anchor: 1 / 1000
},
ppm: {
name: {
singular: 'parts per million',
plural: 'parts per million',
abbreviation: 'ppm'
},
to_anchor: 1 / 640
},
ppt: {
name: {
singular: 'parts per thousand',
plural: 'parts per thousand',
abbreviation: 'ppt'
},
to_anchor: 1000 / 640
},
// psu and ppt are about the same
psu: {
name: {
singular: 'practical salinity unit',
plural: 'practical salinity units',
abbreviation: 'psu'
},
to_anchor: 1000 / 640
},
'.1 psu': {
name: {
singular: '.1 practical salinity unit',
plural: '.1 practical salinity units',
abbreviation: '.1 psu'
},
to_anchor: (1000 / 640) / 10
},
'10 microSiemen/cm': {
name: {
singular: '10 microSiemen/cm',
plural: '10 microSiemen/cm',
abbreviation: '10 uS/cm'
},
to_anchor: 1 / 10000 // microSiemen anchor / 10
}
}
};
var salinity$1 = utils(salinity);
const RATIO$k = 1.609344;
const speed = {
metric: {
baseUnit: 'N',
transform: (val) => { return val * 1 / RATIO$k },
'mm/s': {
name: {
singular: 'Millimetre per second',
plural: 'Millimeters per second'
},
to_anchor: 0.0036
},
'.1 m/s': {
name: {
singular: '.1 Metre per second',
plural: '.1 Metres per second'
},
to_anchor: 0.36
},
'm/s': {
name: {
singular: 'Metre per second',
plural: 'Metres per second'
},
to_anchor: 3.6
},
'km/h': {
name: {
singular: 'Kilometre per hour',
plural: 'Kilometres per hour'
},
to_anchor: 1
}
},
imperial: {
baseUnit: 'm/h',
transform: (val) => { return val * RATIO$k },
'm/h': {
name: {
singular: 'Mile per hour',
plural: 'Miles per hour'
},
to_anchor: 1
},
knot: {
name: {
singular: 'Knot',
plural: 'Knots'
},
to_anchor: 1.150779
},
'ft/s': {
name: {
singular: 'Foot per second',
plural: 'Feet per second'
},
to_anchor: 0.681818
}
}
};
var speed$1 = utils(speed);
const RATIO$l = 1;
const sound = {
metric: {
baseUnit: 'db',
transform: (val) => { return val * RATIO$l },
dB: {
name: {
singular: 'Decibel',
plural: 'Decibels'
},
to_anchor: 1
},
B: {
name: {
singular: 'Bel',
plural: 'Bels'
},
to_anchor: 10
},
'.43 decibel': {
name: {
singular: '.43 decibel',
plural: '.43 decibels'
},
to_anchor: 0.43
}
}
};
var sound$1 = utils(sound);
const temperature = {
metric: {
baseUnit: 'C',
transform: (val) => { return val / (5 / 9) + 32 },
C: {
name: {
singular: 'degree Celsius',
plural: 'degrees Celsius'
},
to_anchor: 1,
anchor_shift: 0
},
K: {
name: {
singular: 'degree Kelvin',
plural: 'degrees Kelvin'
},
to_anchor: 1,
anchor_shift: 273.15
},
'.1 degC': {
name: {
singular: '.1 degC',
plural: '.1 degCs'
},
to_anchor: 0.1,
anchor_shift: 0
}
},
imperial: {
baseUnit: 'F',
transform: (val) => { return (val - 32) * (5 / 9) },
F: {
name: {
singular: 'degree Fahrenheit',
plural: 'degrees Fahrenheit'
},
to_anchor: 1
},
R: {
name: {
singular: 'degree Rankine',
plural: 'degrees Rankine'
},
to_anchor: 1,
anchor_shift: 459.67
}
}
};
var temperature$1 = utils(temperature);
const RATIO$m = 1;
const daysInYear = 365.25;
const time = {
metric: {
baseUnit: 's',
transform: (val) => { return val * RATIO$m },
ns: {
name: {
singular: 'Nanosecond',
plural: 'Nanoseconds'
},
to_anchor: 1 / 1000000000
},
mu: {
name: {
singular: 'Microsecond',
plural: 'Microseconds'
},
to_anchor: 1 / 1000000
},
ms: {
name: {
singular: 'Millisecond',
plural: 'Milliseconds'
},
to_anchor: 1 / 1000
},
s: {
name: {
singular: 'Second',
plural: 'Seconds'
},
to_anchor: 1
},
min: {
name: {
singular: 'Minute',
plural: 'Minutes'
},
to_anchor: 60
},
h: {
name: {
singular: 'Hour',
plural: 'Hours'
},
to_anchor: 60 * 60
},
d: {
name: {
singular: 'Day',
plural: 'Days'
},
to_anchor: 60 * 60 * 24
},
week: {
name: {
singular: 'Week',
plural: 'Weeks'
},
to_anchor: 60 * 60 * 24 * 7
},
month: {
name: {
singular: 'Month',
plural: 'Months'
},
to_anchor: 60 * 60 * 24 * daysInYear / 12
},
year: {
name: {
singular: 'Year',
plural: 'Years'
},
to_anchor: 60 * 60 * 24 * daysInYear
},
'.1 sec': {
name: {
singular: '.1 sec',
plural: '.1 secs'
},
to_anchor: 1 / 10
}
}
};
var time$1 = utils(time);
const RATIO$n = 1;
const voltage = {
metric: {
baseUnit: 'V',
transform: (val) => { return val * RATIO$n },
V: {
name: {
singular: 'Volt',
plural: 'Volts'
},
to_anchor: 1
},
mV: {
name: {
singular: 'Millivolt',
plural: 'Millivolts'
},
to_anchor: 0.001
},
kV: {
name: {
singular: 'Kilovolt',
plural: 'Kilovolts'
},
to_anchor: 1000
},
'.1 volts': {
name: {
singular: '.1 volt',
plural: '.1 volts'
},
to_anchor: 0.1
},
'1 millivolt': {
name: {
singular: '1 millivolt',
plural: '1 millivolts'
},
to_anchor: 0.001
}
}
};
var voltage$1 = utils(voltage);
const RATIO$o = 33.8140226;
const volume = {
metric: {
baseUnit: 'l',
transform: (val) => { return RATIO$o * val },
mm3: {
name: {
singular: 'Cubic Millimeter',
plural: 'Cubic Millimeters'
},
to_anchor: 1 / 1000000
},
cm3: {
name: {
singular: 'Cubic Centimeter',
plural: 'Cubic Centimeters'
},
to_anchor: 1 / 1000
},
ml: {
name: {
singular: 'Millilitre',
plural: 'Millilitres'
},
to_anchor: 1 / 1000
},
cl: {
name: {
singular: 'Centilitre',
plural: 'Centilitres'
},
to_anchor: 1 / 100
},
dl: {
name: {
singular: 'Decilitre',
plural: 'Decilitres'
},
to_anchor: 1 / 10
},
l: {
name: {
singular: 'Litre',
plural: 'Litres'
},
to_anchor: 1
},
kl: {
name: {
singular: 'Kilolitre',
plural: 'Kilolitres'
},
to_anchor: 1000
},
m3: {
name: {
singular: 'Cubic meter',
plural: 'Cubic meters'
},
to_anchor: 1000
},
km3: {
name: {
singular: 'Cubic kilometer',
plural: 'Cubic kilometers'
},
to_anchor: 1000000000000
},
// Swedish units
krm: {
name: {
singular: 'Matsked',
plural: 'Matskedar'
},
to_anchor: 1 / 1000
},
tsk: {
name: {
singular: 'Tesked',
plural: 'Teskedar'
},
to_anchor: 5 / 1000
},
msk: {
name: {
singular: 'Matsked',
plural: 'Matskedar'
},
to_anchor: 15 / 1000
},
kkp: {
name: {
singular: 'Kaffekopp',
plural: 'Kaffekoppar'
},
to_anchor: 150 / 1000
},
glas: {
name: {
singular: 'Glas',
plural: 'Glas'
},
to_anchor: 200 / 1000
},
kanna: {
name: {
singular: 'Kanna',
plural: 'Kannor'
},
to_anchor: 2.617
}
},
imperial: {
baseUnit: 'fl-oz',
transform: (val) => { return val * 1 / RATIO$o },
tsp: {
name: {
singular: 'Teaspoon',
plural: 'Teaspoons'
},
to_anchor: 1 / 6
},
Tbs: {
name: {
singular: 'Tablespoon',
plural: 'Tablespoons'
},
to_anchor: 1 / 2
},
in3: {
name: {
singular: 'Cubic inch',
plural: 'Cubic inches'
},
to_anchor: 0.55411
},
'fl-oz': {
name: {
singular: 'Fluid Ounce',
plural: 'Fluid Ounces'
},
to_anchor: 1
},
cup: {
name: {
singular: 'Cup',
plural: 'Cups'
},
to_anchor: 8
},
pnt: {
name: {
singular: 'Pint',
plural: 'Pints'
},
to_anchor: 16
},
qt: {
name: {
singular: 'Quart',
plural: 'Quarts'
},
to_anchor: 32
},
gal: {
name: {
singular: 'Gallon',
plural: 'Gallons'
},
to_anchor: 128
},
ft3: {
name: {
singular: 'Cubic foot',
plural: 'Cubic feet'
},
to_anchor: 957.506
},
yd3: {
name: {
singular: 'Cubic yard',
plural: 'Cubic yards'
},
to_anchor: 25852.7
}
}
};
var volume$1 = utils(volume);
const RATIO$p = 33.8140227;
const volumeFlowRate = {
metric: {
baseUnit: 'l/s',
transform: (val) => { return val * RATIO$p },
'mm3/s': {
name: {
singular: 'Cubic Millimeter per second',
plural: 'Cubic Millimeters per second'
},
to_anchor: 1 / 1000000
},
'cm3/s': {
name: {
singular: 'Cubic Centimeter per second',
plural: 'Cubic Centimeters per second'
},
to_anchor: 1 / 1000
},
'ml/s': {
name: {
singular: 'Millilitre per second',
plural: 'Millilitres per second'
},
to_anchor: 1 / 1000
},
'cl/s': {
name: {
singular: 'Centilitre per second',
plural: 'Centilitres per second'
},
to_anchor: 1 / 100
},
'dl/s': {
name: {
singular: 'Decilitre per second',
plural: 'Decilitres per second'
},
to_anchor: 1 / 10
},
'l/s': {
name: {
singular: 'Litre per second',
plural: 'Litres per second'
},
to_anchor: 1
},
'l/min': {
name: {
singular: 'Litre per minute',
plural: 'Litres per minute'
},
to_anchor: 1 / 60
},
'l/h': {
name: {
singular: 'Litre per hour',
plural: 'Litres per hour'
},
to_anchor: 1 / 3600
},
'kl/s': {
name: {
singular: 'Kilolitre per second',
plural: 'Kilolitres per second'
},
to_anchor: 1000
},
'kl/min': {
name: {
singular: 'Kilolitre per minute',
plural: 'Kilolitres per minute'
},
to_anchor: 50 / 3
},
'kl/h': {
name: {
singular: 'Kilolitre per hour',
plural: 'Kilolitres per hour'
},
to_anchor: 5 / 18
},
'm3/s': {
name: {
singular: 'Cubic meter per second',
plural: 'Cubic meters per second'
},
to_anchor: 1000
},
'm3/min': {
name: {
singular: 'Cubic meter per minute',
plural: 'Cubic meters per minute'
},
to_anchor: 50 / 3
},
'm3/h': {
name: {
singular: 'Cubic meter per hour',
plural: 'Cubic meters per hour'
},
to_anchor: 5 / 18
},
'km3/s': {
name: {
singular: 'Cubic kilometer per second',
plural: 'Cubic kilometers per second'
},
to_anchor: 1000000000000
}
},
imperial: {
baseUnit: 'fl-oz/s',
transform: (val) => { return val * 1 / RATIO$p },
'tsp/s': {
name: {
singular: 'Teaspoon per second',
plural: 'Teaspoons per second'
},
to_anchor: 1 / 6
},
'Tbs/s': {
name: {
singular: 'Tablespoon per second',
plural: 'Tablespoons per second'
},
to_anchor: 1 / 2
},
'in3/s': {
name: {
singular: 'Cubic inch per second',
plural: 'Cubic inches per second'
},
to_anchor: 0.55411
},
'in3/min': {
name: {
singular: 'Cubic inch per minute',
plural: 'Cubic inches per minute'
},
to_anchor: 0.55411 / 60
},
'in3/h': {
name: {
singular: 'Cubic inch per hour',
plural: 'Cubic inches per hour'
},
to_anchor: 0.55411 / 3600
},
'fl-oz/s': {
name: {
singular: 'Fluid Ounce per second',
plural: 'Fluid Ounces per second'
},
to_anchor: 1
},
'fl-oz/min': {
name: {
singular: 'Fluid Ounce per minute',
plural: 'Fluid Ounces per minute'
},
to_anchor: 1 / 60
},
'fl-oz/h': {
name: {
singular: 'Fluid Ounce per hour',
plural: 'Fluid Ounces per hour'
},
to_anchor: 1 / 3600
},
'cup/s': {
name: {
singular: 'Cup per second',
plural: 'Cups per second'
},
to_anchor: 8
},
'pnt/s': {
name: {
singular: 'Pint per second',
plural: 'Pints per second'
},
to_anchor: 16
},
'pnt/min': {
name: {
singular: 'Pint per minute',
plural: 'Pints per minute'
},
to_anchor: 4 / 15
},
'pnt/h': {
name: {
singular: 'Pint per hour',
plural: 'Pints per hour'
},
to_anchor: 1 / 225
},
'qt/s': {
name: {
singular: 'Quart per second',
plural: 'Quarts per second'
},
to_anchor: 32
},
'gal/s': {
name: {
singular: 'Gallon per second',
plural: 'Gallons per second'
},
to_anchor: 128
},
'gal/min': {
name: {
singular: 'Gallon per minute',
plural: 'Gallons per minute'
},
to_anchor: 32 / 15
},
'gal/h': {
name: {
singular: 'Gallon per hour',
plural: 'Gallons per hour'
},
to_anchor: 8 / 225
},
'ft3/s': {
name: {
singular: 'Cubic foot per second',
plural: 'Cubic feet per second'
},
to_anchor: 957.506
},
'ft3/min': {
name: {
singular: 'Cubic foot per minute',
plural: 'Cubic feet per minute'
},
to_anchor: 957.506 / 60
},
'ft3/h': {
name: {
singular: 'Cubic foot per hour',
plural: 'Cubic feet per hour'
},
to_anchor: 957.506 / 3600
},
'yd3/s': {
name: {
singular: 'Cubic yard per second',
plural: 'Cubic yards per second'
},
to_anchor: 25852.7
},
'yd3/min': {
name: {
singular: 'Cubic yard per minute',
plural: 'Cubic yards per minute'
},
to_anchor: 25852.7 / 60
},
'yd3/h': {
name: {
singular: 'Cubic yard per hour',
plural: 'Cubic yards per hour'
},
to_anchor: 25852.7 / 3600
}
}
};
var volumeFlowRate$1 = utils(volumeFlowRate);
const allUnits = {
units: [acceleration$1, angle$1, apparentPower$1, area$1, charge$1, current$1, digital, each$1,
energy$1, force$1, frequency$1, illuminance$1, length$1, light$1, mass$1, pace$1, partsPer$1, power$1,
pressure$1, reactiveEnergy$1, reactivePower$1, salinity$1, sound$1, speed$1, temperature$1, time$1,
voltage$1, volume$1, volumeFlowRate$1],
/**
* Convert: used to convert a value without knowing which library is associated with the value.
*
* @param {number} value value to convert
* @param {string} from in, mm, m, dB, etc (case sensitive)
* @param {string} to in, mm, m, dB, etc (case sensitive)
* @param {number} [precision=null] if you want a fixed decimal place, provide this
*/
convert: (value, from, to, precision = null) => {
const unitObj = allUnits.units.find((unit) => {
return unit().getUnit(to) && unit().getUnit(from)
});
if (!unitObj) {
throw new Error(`Cannot find unit object that has to: ${to} and from: ${from}`)
}
return unitObj(value).from(from).to(to, precision)
},
/**
* Gets the possibilities from unit library
*
* @param {string} [from=null] in, ft, mm, kg, etc
*/
findPossibilities: (from) => {
const unitObj = allUnits.units.find((unit) => {
return unit().getUnit(from)
});
if (!unitObj) {
throw new Error(`Cannot find unit object with from: ${from}`)
}
return unitObj().from(from).possibilities()
},
/**
* Gets a unit library based on from and/or to
*
* @param {string} [from=null] in, ft, mm, kg, etc
* @param {string} [to=null] in, ft, mm, kg, etc
*/
getLibrary: (from = null, to = null) => {
if (!from && !to) {
throw new Error(`One arguement must be defined, from: ${from}, to: ${to}`)
}
const unitLibrary = allUnits.units.find((unit) => {
let conditions = [];
if (unit().getUnit(from)) {
conditions.push(true);
}
if (unit().getUnit(to)) {
conditions.push(true);
}
return conditions.length > 0
});
if (!unitLibrary) {
throw new Error(`Cannot find unit object that has to: ${to} and from: ${from}`)
}
return unitLibrary
}
};
module.exports = allUnits;