units-converter-ts
Version:
A simple utility library for converting units
1 lines • 25.3 kB
JavaScript
(()=>{"use strict";var r={d:(e,a)=>{for(var n in a)r.o(a,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:a[n]})},o:(r,e)=>Object.prototype.hasOwnProperty.call(r,e),r:r=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})}},e={};r.r(e),r.d(e,{acceleration:()=>F,angle:()=>K,apparentPower:()=>O,area:()=>S,charge:()=>J,convert:()=>mr,current:()=>D,digital:()=>I,energy:()=>L,force:()=>Q,frequency:()=>X,illuminance:()=>Y,length:()=>Z,mass:()=>$,pace:()=>rr,power:()=>er,pressure:()=>ar,reactiveEnergy:()=>nr,reactivePower:()=>lr,speed:()=>ir,temperature:()=>tr,time:()=>ur,voltage:()=>sr,volume:()=>or,volumeFlowRate:()=>cr});var a={metric:{baseUnit:"m/s2",transform:function(r){return 1*r},units:{gal:{name:{singular:"gal",plural:"gals"},anchor:.01},"m/s2":{name:{singular:"metre per second squared",plural:"metres per second squared"},anchor:1},"g-force":{name:{singular:"g-force",plural:"g-forces"},anchor:9.80665}}}},n=10.7639,l={metric:{baseUnit:"m2",transform:function(r){return r*n},units:{mm2:{name:{singular:"square millimeter",plural:"square millimeters"},anchor:1e-6},cm2:{name:{singular:"square centimeter",plural:"square centimeters"},anchor:1e-4},m2:{name:{singular:"square meter",plural:"square meters"},anchor:1},are:{name:{singular:"are",plural:"ares"},anchor:100},ha:{name:{singular:"hectare",plural:"hectares"},anchor:1e4},km2:{name:{singular:"square kilometer",plural:"square kilometers"},anchor:1e6}}},imperial:{baseUnit:"ft2",transform:function(r){return 1*r/n},units:{"circ-mil":{name:{singular:"circular mil",plural:"circular mils"},anchor:5.454153912e-9},"circ-inch":{name:{singular:"circular inch",plural:"circular inches"},anchor:.0054541539},in2:{name:{singular:"square inch",plural:"square inches"},anchor:1/144},ft2:{name:{singular:"square foot",plural:"square feet"},anchor:1},yd2:{name:{singular:"square yard",plural:"square yards"},anchor:9},ro:{name:{singular:"rood",plural:"roods"},anchor:10890},ac:{name:{singular:"acre",plural:"acres"},anchor:43560},mi2:{name:{singular:"square mile",plural:"square miles"},anchor:27878400},twp:{name:{singular:"township",plural:"townships"},anchor:1003622400}}}},i={metric:{baseUnit:"deg",transform:function(r){return 1*r},units:{rev:{name:{singular:"revolution",plural:"revolutions"},anchor:360},deg:{name:{singular:"degree",plural:"degrees"},anchor:1},rad:{name:{singular:"radian",plural:"radians"},anchor:57.29577951308232},grad:{name:{singular:"gradian",plural:"gradians"},anchor:.9},arcmin:{name:{singular:"arcminute",plural:"arcminutes"},anchor:1/60},arcsec:{name:{singular:"arcsecond",plural:"arcseconds"},anchor:1/3600}}}},t={metric:{baseUnit:"VA",transform:function(r){return 1*r},units:{mVA:{name:{singular:"millivolt-ampere",plural:"millivolt-amperes"},anchor:.001},VA:{name:{singular:"volt-ampere",plural:"volt-amperes"},anchor:1},kVA:{name:{singular:"kilovolt-ampere",plural:"kilovolt-amperes"},anchor:1e3},MVA:{name:{singular:"megavolt-ampere",plural:"megavolt-amperes"},anchor:1e6},GVA:{name:{singular:"gigavolt-ampere",plural:"gigavolt-amperes"},anchor:1e9}}}},u={metric:{baseUnit:"c",transform:function(r){return 1*r},units:{abC:{name:{singular:"abcoulomb",plural:"abcoulombs"},anchor:10},c:{name:{singular:"coulomb",plural:"coulombs"},anchor:1},mC:{name:{singular:"millicoulomb",plural:"millicoulombs"},anchor:.001},uC:{name:{singular:"microcoulomb",plural:"microcoulombs"},anchor:1e-6},nC:{name:{singular:"nanocoulomb",plural:"nanocoulombs"},anchor:1e-9},stC:{name:{singular:"statcoulomb",plural:"statcoulombs"},anchor:3.335640951982e-10},pC:{name:{singular:"picocoulomb",plural:"picocoulombs"},anchor:1e-12},e:{name:{singular:"elementary charge",plural:"elementary charges"},anchor:160217733e-27}}}},s={metric:{baseUnit:"A",transform:function(r){return 1*r},units:{stA:{name:{singular:"statampere",plural:"statamperes"},anchor:3.335641e-10},mA:{name:{singular:"milliampere",plural:"milliamperes"},anchor:.001},A:{name:{singular:"ampere",plural:"amperes"},anchor:1},abA:{name:{singular:"abampere",plural:"abamperes"},anchor:10},kA:{name:{singular:"kiloampere",plural:"kiloamperes"},anchor:1e3}}}},o={bits:{baseUnit:"b",transform:function(r){return 1*r/8},units:{b:{name:{singular:"bit",plural:"bits"},anchor:1},Kb:{name:{singular:"kilobit",plural:"kilobits"},anchor:1024},Mb:{name:{singular:"megabit",plural:"megabits"},anchor:1048576},Gb:{name:{singular:"gigabit",plural:"gigabits"},anchor:1073741824},Tb:{name:{singular:"terabit",plural:"terabits"},anchor:1099511627776}}},bytes:{baseUnit:"B",transform:function(r){return 8*r},units:{B:{name:{singular:"byte",plural:"bytes"},anchor:1},KB:{name:{singular:"kilobyte",plural:"kilobytes"},anchor:1024},MB:{name:{singular:"megabyte",plural:"megabytes"},anchor:1048576},GB:{name:{singular:"gigabyte",plural:"gigabytes"},anchor:1073741824},TB:{name:{singular:"terabyte",plural:"terabytes"},anchor:1099511627776}}}},c=1055.0558526,m={metric:{baseUnit:"J",transform:function(r){return 1*r/c},units:{J:{name:{singular:"joule",plural:"joules"},anchor:1},kJ:{name:{singular:"kilojoule",plural:"kilojoules"},anchor:1e3},mWh:{name:{singular:"milliwatt-hour",plural:"milliwatt-hours"},anchor:3.6},Wh:{name:{singular:"watt-hour",plural:"watt-hours"},anchor:3600},kWh:{name:{singular:"kilowatt-hour",plural:"kilowatt-hours"},anchor:36e5},MWh:{name:{singular:"megawatt-hour",plural:"megawatt-hours"},anchor:36e8},GWh:{name:{singular:"gigawatt-hour",plural:"gigawatt-hours"},anchor:36e11}}},imperial:{baseUnit:"Btu-it",transform:function(r){return c*r},units:{"Btu-it":{name:{singular:"british thermal unit (international table)",plural:"british thermal units (international table)"},anchor:1}}}},p=4.44822,h={metric:{baseUnit:"N",transform:function(r){return 1*r/p},units:{N:{name:{singular:"newton",plural:"newtons"},anchor:1},kN:{name:{singular:"kilonewton",plural:"kilonewtons"},anchor:1e3}}},imperial:{baseUnit:"lbf",transform:function(r){return p*r},units:{lbf:{name:{singular:"pound-force",plural:"pound-forces"},anchor:1}}}},g={metric:{baseUnit:"Hz",transform:function(r){return 1*r},units:{mHz:{name:{singular:"millihertz",plural:"millihertz"},anchor:.001},Hz:{name:{singular:"hertz",plural:"hertz"},anchor:1},kHz:{name:{singular:"kilohertz",plural:"kilohertz"},anchor:1e3},MHz:{name:{singular:"megahertz",plural:"megahertz"},anchor:1e6},GHz:{name:{singular:"gigahertz",plural:"gigahertz"},anchor:1e9},THz:{name:{singular:"terahertz",plural:"terahertz"},anchor:1e12},rpm:{name:{singular:"rotation per minute",plural:"rotations per minute"},anchor:1/60},"deg/s":{name:{singular:"degree per second",plural:"degrees per second"},anchor:1/360},"rad/s":{name:{singular:"radian per second",plural:"radians per second"},anchor:.15915494309189535}}}},f=10.76391,d={metric:{baseUnit:"lx",transform:function(r){return 1*r/f},units:{lx:{name:{singular:"lux",plural:"lux"},anchor:1}}},imperial:{baseUnit:"ft-cd",transform:function(r){return f*r},units:{"ft-cd":{name:{singular:"foot-candle",plural:"foot-candles"},anchor:1}}}},b=3.28084,k={metric:{baseUnit:"m",transform:function(r){return r*b},units:{mm:{name:{singular:"millimeter",plural:"millimeters"},anchor:.001},cm:{name:{singular:"centimeter",plural:"centimeters"},anchor:.01},m:{name:{singular:"meter",plural:"meters"},anchor:1},km:{name:{singular:"kilometer",plural:"kilometers"},anchor:1e3}}},imperial:{baseUnit:"ft",transform:function(r){return 1*r/b},units:{in:{name:{singular:"inch",plural:"inches"},anchor:1/12},hand:{name:{singular:"hand",plural:"hands"},anchor:1/3},ft:{name:{singular:"foot",plural:"feet"},anchor:1},"ft-us":{name:{singular:"US survey foot",plural:"US survey feet"},anchor:1.000002},yd:{name:{singular:"yard",plural:"yards"},anchor:3},fath:{name:{singular:"fathom",plural:"fathoms"},anchor:6},fur:{name:{singular:"furlong",plural:"furlongs"},anchor:660},mi:{name:{singular:"mile",plural:"miles"},anchor:5280},nMi:{name:{singular:"international nautical mile",plural:"international nautical miles"},anchor:6076.12}}}},v=2.20462262,w={metric:{baseUnit:"kg",transform:function(r){return r*v},units:{mg:{name:{singular:"milligram",plural:"milligrams"},anchor:1e-6},g:{name:{singular:"gram",plural:"grams"},anchor:.001},kg:{name:{singular:"kilogram",plural:"kilograms"},anchor:1},t:{name:{singular:"ton",plural:"tons"},anchor:1e3},kt:{name:{singular:"kiloton",plural:"kilotons"},anchor:1e6},mt:{name:{singular:"megaton",plural:"megatons"},anchor:1e9}}},imperial:{baseUnit:"lb",transform:function(r){return 1*r/v},units:{gr:{name:{singular:"grain",plural:"grains"},anchor:1/7e3},dr:{name:{singular:"dram",plural:"drams"},anchor:1/256},oz:{name:{singular:"ounce",plural:"ounces"},anchor:1/16},lb:{name:{singular:"pound",plural:"pounds"},anchor:1},stone:{name:{singular:"stone",plural:"stones"},anchor:14},qr:{name:{singular:"quarter",plural:"quarters"},anchor:25},slug:{name:{singular:"slug",plural:"slugs"},anchor:32.1740486},tn:{name:{singular:"short ton",plural:"short tons"},anchor:2e3},"ton-uk":{name:{singular:"imperial ton",plural:"imperial tons"},anchor:2240}}}},y=.3048,U={metric:{baseUnit:"s/m",transform:function(r){return r*y},units:{"min/km":{name:{singular:"minute per kilometre",plural:"minutes per kilometre"},anchor:.06},"s/m":{name:{singular:"second per metre",plural:"seconds per metre"},anchor:1}}},imperial:{baseUnit:"s/ft",transform:function(r){return 1*r/y},units:{"min/mi":{name:{singular:"minute per mile",plural:"minutes per mile"},anchor:.0113636364},"s/ft":{name:{singular:"second per foot",plural:"seconds per foot"},anchor:1}}}},A={metric:{baseUnit:"W",transform:function(r){return 1*r},units:{mW:{name:{singular:"milliwatt",plural:"milliwatts"},anchor:.001},W:{name:{singular:"watt",plural:"watts"},anchor:1},kW:{name:{singular:"kilowatt",plural:"kilowatts"},anchor:1e3},MW:{name:{singular:"megawatt",plural:"megawatts"},anchor:1e6},GW:{name:{singular:"gigawatt",plural:"gigawatts"},anchor:1e9}}}},V=.00014503768078,q={metric:{baseUnit:"kPa",transform:function(r){return r*V},units:{Pa:{name:{singular:"pascal",plural:"pascals"},anchor:.001},hPa:{name:{singular:"hectopascal",plural:"hectopascals"},anchor:.1},kPa:{name:{singular:"kilopascal",plural:"kilopascals"},anchor:1},bar:{name:{singular:"bar",plural:"bars"},anchor:100},MPa:{name:{singular:"megapascal",plural:"megapascals"},anchor:1e3},torr:{name:{singular:"torr",plural:"torr"},anchor:101325/76e4}}},imperial:{baseUnit:"psi",transform:function(r){return 1*r/V},units:{psi:{name:{singular:"pound per square inch",plural:"pounds per square inch"},anchor:.001},ksi:{name:{singular:"kilopound per square inch",plural:"kilopound per square inch"},anchor:1}}}},z={metric:{baseUnit:"VARh",transform:function(r){return 1*r},units:{mVARh:{name:{singular:"millivolt-ampere reactive hour",plural:"millivolt-amperes reactive hour"},anchor:.001},VARh:{name:{singular:"volt-ampere reactive hour",plural:"volt-amperes reactive hour"},anchor:1},kVARh:{name:{singular:"kilovolt-ampere reactive hour",plural:"kilovolt-amperes reactive hour"},anchor:1e3},MVARh:{name:{singular:"megavolt-ampere reactive hour",plural:"megavolt-amperes reactive hour"},anchor:1e6},GVARh:{name:{singular:"gigavolt-ampere reactive hour",plural:"gigavolt-amperes reactive hour"},anchor:1e9}}}},M={metric:{baseUnit:"VAR",transform:function(r){return 1*r},units:{mVAR:{name:{singular:"millivolt-ampere reactive",plural:"millivolt-amperes reactive"},anchor:.001},VAR:{name:{singular:"volt-ampere reactive",plural:"volt-amperes reactive"},anchor:1},kVAR:{name:{singular:"kilovolt-ampere reactive",plural:"kilovolt-amperes reactive"},anchor:1e3},MVAR:{name:{singular:"megavolt-ampere reactive",plural:"megavolt-amperes reactive"},anchor:1e6},GVAR:{name:{singular:"gigavolt-ampere reactive",plural:"gigavolt-amperes reactive"},anchor:1e9}}}},R=1.609344,P={metric:{baseUnit:"km/h",transform:function(r){return 1*r/R},units:{"km/h":{name:{singular:"kilometre per hour",plural:"kilometres per hour"},anchor:1},"m/s":{name:{singular:"metre per second",plural:"metres per second"},anchor:3.6}}},imperial:{baseUnit:"mi/h",transform:function(r){return r*R},units:{"ft/s":{name:{singular:"foot per second",plural:"feet per second"},anchor:.681818},"mi/h":{name:{singular:"mile per hour",plural:"miles per hour"},anchor:1},knot:{name:{singular:"knot",plural:"knots"},anchor:1.150779}}}},W={metric:{baseUnit:"C",transform:function(r){return r/(5/9)+32},units:{C:{name:{singular:"degree celsius",plural:"degrees celsius"},anchor:1,anchor_shift:0},K:{name:{singular:"degree kelvin",plural:"degrees kelvin"},anchor:1,anchor_shift:273.15}}},imperial:{baseUnit:"F",transform:function(r){return 5/9*(r-32)},units:{F:{name:{singular:"degree fahrenheit",plural:"degrees fahrenheit"},anchor:1},R:{name:{singular:"degree rankine",plural:"degrees rankine"},anchor:1,anchor_shift:459.67}}}},G={metric:{baseUnit:"s",transform:function(r){return 1*r},units:{ns:{name:{singular:"nanosecond",plural:"nanoseconds"},anchor:1e-9},mu:{name:{singular:"microsecond",plural:"microseconds"},anchor:1e-6},ms:{name:{singular:"millisecond",plural:"milliseconds"},anchor:.001},s:{name:{singular:"second",plural:"seconds"},anchor:1},min:{name:{singular:"minute",plural:"minutes"},anchor:60},h:{name:{singular:"hour",plural:"hours"},anchor:3600},d:{name:{singular:"day",plural:"days"},anchor:86400},week:{name:{singular:"week",plural:"weeks"},anchor:604800},fortnight:{name:{singular:"fortnight",plural:"fortnights"},anchor:1209600},month:{name:{singular:"month",plural:"months"},anchor:2629800},year:{name:{singular:"year",plural:"years"},anchor:31557600}}}},E={metric:{baseUnit:"V",transform:function(r){return 1*r},units:{mV:{name:{singular:"millivolt",plural:"millivolts"},anchor:.001},V:{name:{singular:"volt",plural:"volts"},anchor:1},kV:{name:{singular:"kilovolt",plural:"kilovolts"},anchor:1e3}}}},C=33.8140226,B={metric:{baseUnit:"l",transform:function(r){return C*r},units:{mm3:{name:{singular:"cubic millimeter",plural:"cubic millimeters"},anchor:1e-6},cm3:{name:{singular:"cubic centimeter",plural:"cubic centimeters"},anchor:.001},ml:{name:{singular:"millilitre",plural:"millilitres"},anchor:.001},cl:{name:{singular:"centilitre",plural:"centilitres"},anchor:.01},dl:{name:{singular:"decilitre",plural:"decilitres"},anchor:.1},l:{name:{singular:"litre",plural:"litres"},anchor:1},kl:{name:{singular:"kilolitre",plural:"kilolitres"},anchor:1e3},m3:{name:{singular:"cubic meter",plural:"cubic meters"},anchor:1e3},km3:{name:{singular:"cubic kilometer",plural:"cubic kilometers"},anchor:1e12},krm:{name:{singular:"kryddmått",plural:"kryddmåtten"},anchor:.001},tsk:{name:{singular:"tesked",plural:"teskedar"},anchor:.005},msk:{name:{singular:"matsked",plural:"matskedar"},anchor:.015},kkp:{name:{singular:"kaffekopp",plural:"kaffekoppar"},anchor:.15},glas:{name:{singular:"glas",plural:"glas"},anchor:.2},kanna:{name:{singular:"kanna",plural:"kannor"},anchor:2.617}}},imperial:{baseUnit:"fl-oz",transform:function(r){return 1*r/C},units:{tsp:{name:{singular:"teaspoon",plural:"teaspoons"},anchor:1/6},Tbs:{name:{singular:"tablespoon",plural:"tablespoons"},anchor:.5},in3:{name:{singular:"cubic inch",plural:"cubic inches"},anchor:.55411},"fl-oz":{name:{singular:"fluid ounce",plural:"fluid ounces"},anchor:1},cup:{name:{singular:"cup",plural:"cups"},anchor:8},pnt:{name:{singular:"pint",plural:"pints"},anchor:16},qt:{name:{singular:"quart",plural:"quarts"},anchor:32},gal:{name:{singular:"gallon",plural:"gallons"},anchor:128},ft3:{name:{singular:"cubic foot",plural:"cubic feet"},anchor:957.506},yd3:{name:{singular:"cubic yard",plural:"cubic yards"},anchor:25852.7}}}},T=33.8140227,j={metric:{baseUnit:"l/s",transform:function(r){return r*T},units:{"mm3/s":{name:{singular:"cubic millimeter per second",plural:"cubic millimeters per second"},anchor:1e-6},"cm3/s":{name:{singular:"cubic centimeter per second",plural:"cubic centimeters per second"},anchor:.001},"ml/s":{name:{singular:"millilitre per second",plural:"millilitres per second"},anchor:.001},"cl/s":{name:{singular:"centilitre per second",plural:"centilitres per second"},anchor:.01},"dl/s":{name:{singular:"decilitre per second",plural:"decilitres per second"},anchor:.1},"l/s":{name:{singular:"litre per second",plural:"litres per second"},anchor:1},"l/min":{name:{singular:"litre per minute",plural:"litres per minute"},anchor:1/60},"l/h":{name:{singular:"litre per hour",plural:"litres per hour"},anchor:1/3600},"kl/s":{name:{singular:"kilolitre per second",plural:"kilolitres per second"},anchor:1e3},"kl/min":{name:{singular:"kilolitre per minute",plural:"kilolitres per minute"},anchor:50/3},"kl/h":{name:{singular:"kilolitre per hour",plural:"kilolitres per hour"},anchor:5/18},"m3/s":{name:{singular:"cubic meter per second",plural:"cubic meters per second"},anchor:1e3},"m3/min":{name:{singular:"cubic meter per minute",plural:"cubic meters per minute"},anchor:50/3},"m3/h":{name:{singular:"cubic meter per hour",plural:"cubic meters per hour"},anchor:5/18},"km3/s":{name:{singular:"cubic kilometer per second",plural:"cubic kilometers per second"},anchor:1e12}}},imperial:{baseUnit:"fl-oz/s",transform:function(r){return 1*r/T},units:{"tsp/s":{name:{singular:"teaspoon per second",plural:"teaspoons per second"},anchor:1/6},"Tbs/s":{name:{singular:"tablespoon per second",plural:"tablespoons per second"},anchor:.5},"in3/s":{name:{singular:"cubic inch per second",plural:"cubic inches per second"},anchor:.55411},"in3/min":{name:{singular:"cubic inch per minute",plural:"cubic inches per minute"},anchor:.55411/60},"in3/h":{name:{singular:"cubic inch per hour",plural:"cubic inches per hour"},anchor:.55411/3600},"fl-oz/s":{name:{singular:"fluid ounce per second",plural:"fluid ounces per second"},anchor:1},"fl-oz/min":{name:{singular:"fluid ounce per minute",plural:"fluid ounces per minute"},anchor:1/60},"fl-oz/h":{name:{singular:"fluid ounce per hour",plural:"fluid ounces per hour"},anchor:1/3600},"cup/s":{name:{singular:"cup per second",plural:"cups per second"},anchor:8},"pnt/s":{name:{singular:"pint per second",plural:"pints per second"},anchor:16},"pnt/min":{name:{singular:"pint per minute",plural:"pints per minute"},anchor:4/15},"pnt/h":{name:{singular:"pint per hour",plural:"pints per hour"},anchor:1/225},"qt/s":{name:{singular:"quart per second",plural:"quarts per second"},anchor:32},"gal/s":{name:{singular:"gallon per second",plural:"gallons per second"},anchor:128},"gal/min":{name:{singular:"gallon per minute",plural:"gallons per minute"},anchor:32/15},"gal/h":{name:{singular:"gallon per hour",plural:"gallons per hour"},anchor:8/225},"ft3/s":{name:{singular:"cubic foot per second",plural:"cubic feet per second"},anchor:957.506},"ft3/min":{name:{singular:"cubic foot per minute",plural:"cubic feet per minute"},anchor:957.506/60},"ft3/h":{name:{singular:"cubic foot per hour",plural:"cubic feet per hour"},anchor:957.506/3600},"yd3/s":{name:{singular:"cubic yard per second",plural:"cubic yards per second"},anchor:25852.7},"yd3/min":{name:{singular:"cubic yard per minute",plural:"cubic yards per minute"},anchor:25852.7/60},"yd3/h":{name:{singular:"cubic yard per hour",plural:"cubic yards per hour"},anchor:25852.7/3600}}}},H={acceleration:a,area:l,angle:i,apparentPower:t,charge:u,current:s,digital:o,energy:m,force:h,frequency:g,illuminance:d,length:k,mass:w,pace:U,power:A,pressure:q,reactiveEnergy:z,reactivePower:M,speed:P,temperature:W,time:G,voltage:E,volume:B,volumeFlowRate:j},N=["acceleration","area","angle","apparentPower","charge","current","digital","energy","force","frequency","illuminance","length","mass","pace","power","pressure","reactiveEnergy","reactivePower","speed","temperature","time","voltage","volume","volumeFlowRate"],_={acceleration:["gal","m/s2","g-force"],angle:["rev","deg","rad","grad","arcmin","arcsec"],apparentPower:["mVA","VA","kVA","MVA","GVA"],area:["mm2","cm2","m2","are","ha","km2","circ-mil","circ-inch","in2","ft2","yd2","ro","ac","mi2","twp"],charge:["abC","c","mC","uC","nC","stC","pC","e"],current:["stA","mA","A","abA","kA"],digital:["b","Kb","Mb","Gb","Tb","B","KB","MB","GB","TB"],energy:["J","kJ","mWh","Wh","kWh","MWh","GWh","Btu-it"],force:["N","kN","lbf"],frequency:["mHz","Hz","kHz","MHz","GHz","THz","rpm","deg/s","rad/s"],illuminance:["lx","ft-cd"],length:["mm","cm","m","km","in","hand","ft","ft-us","yd","fath","fur","mi","nMi"],mass:["mg","g","kg","t","kt","mt","gr","dr","oz","lb","stone","qr","slug","tn","ton-uk"],pace:["min/km","s/m","min/mi","s/ft"],power:["mW","W","kW","MW","GW"],pressure:["Pa","hPa","kPa","bar","MPa","torr","psi","ksi"],reactiveEnergy:["mVARh","VARh","kVARh","MVARh","GVARh"],reactivePower:["mVAR","VAR","kVAR","MVAR","GVAR"],speed:["km/h","m/s","ft/s","mi/h","knot"],temperature:["C","K","F","R"],time:["ns","mu","ms","s","min","h","d","week","fortnight","month","year"],voltage:["mV","V","kV"],volume:["mm3","cm3","ml","cl","dl","l","kl","m3","km3","krm","tsk","msk","kkp","glas","kanna","tsp","Tbs","in3","fl-oz","cup","pnt","qt","gal","ft3","yd3"],volumeFlowRate:["mm3/s","cm3/s","ml/s","cl/s","dl/s","l/s","l/min","l/h","kl/s","kl/min","kl/h","m3/s","m3/min","m3/h","km3/s","tsp/s","Tbs/s","in3/s","in3/min","in3/h","fl-oz/s","fl-oz/min","fl-oz/h","cup/s","pnt/s","pnt/min","pnt/h","qt/s","gal/s","gal/min","gal/h","ft3/s","ft3/min","ft3/h","yd3/s","yd3/min","yd3/h"]},x=function(){function r(r,e){this.measure=r,this.measureName=e}return r.throwUnsupportedUnitError=function(r,e){throw void 0===r&&(r=""),void 0===e&&(e=""),new Error("".concat(e," Unit '").concat(r,"' is not a valid or supported unit for this measure. Get list of units using {measure}.possibilities()"))},r.getMeasure=function(r){for(var e=0,a=N;e<a.length;e++){var n=a[e];if(_[n].includes(r))return{obj:H[n],name:n}}throw new Error("Cannot get measure. Unit '".concat(r,"' could not be found. Get list of units using convert.possibilities()"))},r.getUnit=function(r,e){var a=H[e];for(var n in a){var l=a[n].units;if(l[r])return{system:n,unit:l[r]}}this.throwUnsupportedUnitError(r,"Trying to retrieve unit from '".concat(e,"' measure."))},r.describeUnit=function(e,a){var n=r.getUnit(e,a);return{abbreviation:e,measure:a,system:n.system,singular:n.unit.name.singular,plural:n.unit.name.plural}},r.allPossibilities=function(){return console.warn("This method is deprecated, please use the new method: possibilities."),this.possibilities()},r.measures=function(){return N},r.possibilities=function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];if(0===r.length){var a=[];for(var n in _)a.push.apply(a,_[n]);return a}var l=[];return r.forEach((function(r){if(!N.includes(r))throw new Error("Measure '".concat(r,"' doesn't exist. Get list of measures using convert.measures()"));l.push.apply(l,_[r])})),l},r.describe=function(r){var e=this.getMeasure(r);return this.describeUnit(r,e.name)},r.list=function(){for(var r=this,e=[],a=0;a<arguments.length;a++)e[a]=arguments[a];if(0===e.length){var n=[],l=function(e){_[e].forEach((function(a){n.push(r.describeUnit(a,e))}))};for(var i in _)l(i);return n}var t=[];return e.forEach((function(e){if(!N.includes(e))throw new Error("Measure '".concat(e,"' doesn't exist. Get list of measures using convert.measures()"));_[e].forEach((function(a){t.push(r.describeUnit(a,e))}))})),t},r.convert=function(e,a,n){if(e===a)return n;var l=this.getMeasure(e),i=this.getMeasure(a);if(l.name!==i.name)throw new Error("Cannot convert between incompatible measures '".concat(l.name,"' and '").concat(i.name,"'"));return new r(l.obj,l.name).convert(e,a,n)},r.prototype.possibilities=function(){return _[this.measureName]},r.prototype.describe=function(e){return r.describeUnit(e,this.measureName)},r.prototype.list=function(){return r.list(this.measureName)},r.prototype.convert=function(e,a,n){if(e===a)return n;var l=0,i=r.getUnit(e,this.measureName),t=r.getUnit(a,this.measureName),u=i.unit.anchor,s=t.unit.anchor;if(!u)throw new Error("'".concat(e,"' unit's anchor value is invalid. check '").concat(this.measureName,"' object"));if(!s)throw new Error("'".concat(a,"' unit's anchor value is invalid. check '").concat(this.measureName,"' object."));return l=n*u,i.unit.anchor_shift&&(l-=i.unit.anchor_shift),t.system!==i.system&&(l=this.measure[i.system].transform(l)),void 0!==t.unit.anchor_shift&&(l+=t.unit.anchor_shift),l/s},r}(),F=new x(a,"acceleration"),S=new x(l,"area"),K=new x(i,"angle"),O=new x(t,"apparentPower"),J=new x(u,"charge"),D=new x(s,"current"),I=new x(o,"digital"),L=new x(m,"energy"),Q=new x(h,"force"),X=new x(g,"frequency"),Y=new x(d,"illuminance"),Z=new x(k,"length"),$=new x(w,"mass"),rr=new x(U,"pace"),er=new x(A,"power"),ar=new x(q,"pressure"),nr=new x(z,"reactiveEnergy"),lr=new x(M,"reactivePower"),ir=new x(P,"speed"),tr=new x(W,"temperature"),ur=new x(G,"time"),sr=new x(E,"voltage"),or=new x(B,"volume"),cr=new x(j,"volumeFlowRate"),mr={measures:function(){return x.measures()},possibilities:function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return x.possibilities.apply(x,r)},allPossibilities:function(){return x.allPossibilities()},convert:function(r,e,a){return x.convert(r,e,a)},describe:function(r){return x.describe(r)},list:function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return x.list.apply(x,r)}},pr=exports;for(var hr in e)pr[hr]=e[hr];e.__esModule&&Object.defineProperty(pr,"__esModule",{value:!0})})();