UNPKG

cbi-units-converter

Version:

Forked from units-converter. A simple utility library to measure and convert between units

1 lines 25 kB
"use strict";const r=function(r,a){this.definitions=a,this.val=r};function a(a){return e=>new r(e,a)}r.prototype.from=function(r){if(this.destination)throw new Error(".from must be called before .to");return this.origin=this.getUnit(r),this.origin||this.throwUnsupportedUnitError(r),this},r.prototype.to=function(r,a=null){if(!this.origin)throw new Error(".to must be called after .from");let e;return this.destination=this.getUnit(r),this.destination||this.throwUnsupportedUnitError(r),this.origin.abbr===this.destination.abbr?Object.assign({value:this.val},this.describe(this.destination.abbr)):(e=this.val*this.origin.unit.to_anchor,this.origin.unit.anchor_shift&&(e-=this.origin.unit.anchor_shift),this.origin.system!==this.destination.system&&(e=this.definitions[this.origin.system].transform(e)),void 0!==this.destination.unit.anchor_shift&&(e+=this.destination.unit.anchor_shift),e/=this.destination.unit.to_anchor,a&&(e=+e.toFixed(a)),Object.assign({value:e},this.describe(this.destination.abbr)))},r.prototype.toBestAllSystems=function(r){if(!this.origin)throw new Error(".toBestAllSystems must be called after .from");r=Object.assign({exclude:[],cutOffNumber:1,percision:null,system:null},r);const a=this.getSystems(),e={};return a.forEach(a=>{r.system=a,e[a]=this.toBest(r)}),e},r.prototype.toBest=function(r){if(!this.origin)throw new Error(".toBest must be called after .from");r=Object.assign({exclude:[],cutOffNumber:1,percision:null,system:null},r);const a=this.list().filter(a=>r.system?!r.exclude.includes(a.unit)&&r.system===this.describe(a.unit).system:!r.exclude.includes(a.unit)&&this.describe(a.unit).system===this.origin.system).reduce((a,e)=>{const n=this.to(e.unit);return!a||n.value>=r.cutOffNumber&&n.value<a.value?n:a},void 0);return r.precision&&(a.value=+a.value.toFixed(r.precision)),a},r.prototype.getUnit=function(r){const a=Object.keys(this.definitions).map(a=>{if(this.definitions[a][r])return{abbr:r,system:a,unit:this.definitions[a][r]}}).filter(r=>void 0!==r);return Array.isArray(a)?a[0]:void 0},r.prototype.list=function(){return this.possibilities().map(r=>this.describe(r))},r.prototype.throwUnsupportedUnitError=function(r){throw new Error("Unsupported unit "+r)},r.prototype.describe=function(r){if(!r)throw new Error("You must select a unit");const a=this.getUnit(r);return{unit:a.abbr,system:a.system,singular:a.unit.name.singular,plural:a.unit.name.plural}},r.prototype.possibilities=function(){return Array.prototype.concat(...Object.keys(this.definitions).map(r=>Object.keys(this.definitions[r]).splice(2)))},r.prototype.getSystems=function(){return Object.keys(this.definitions)};var e=a({metric:{baseUnit:"g-force",transform:r=>1*r,"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 n=a({metric:{baseUnit:"g-force",transform:r=>1*r,rad:{name:{singular:"radian",plural:"radians"},to_anchor:57.29577951308232},deg:{name:{singular:"degree",plural:"degrees"},to_anchor:1},grad:{name:{singular:"gradian",plural:"gradians"},to_anchor:.9},arcmin:{name:{singular:"arcminute",plural:"arcminutes"},to_anchor:1/60},arcsec:{name:{singular:"arcsecond",plural:"arcseconds"},to_anchor:1/3600}}});var l=a({metric:{baseUnit:"VA",transform:r=>1*r,VA:{name:{singular:"Volt-Ampere",plural:"Volt-Amperes"},to_anchor:1},mVA:{name:{singular:"Millivolt-Ampere",plural:"Millivolt-Amperes"},to_anchor:.001},kVA:{name:{singular:"Kilovolt-Ampere",plural:"Kilovolt-Amperes"},to_anchor:1e3},MVA:{name:{singular:"Megavolt-Ampere",plural:"Megavolt-Amperes"},to_anchor:1e6},GVA:{name:{singular:"Gigavolt-Ampere",plural:"Gigavolt-Amperes"},to_anchor:1e9}}});var o=a({metric:{baseUnit:"m2",transform:r=>10.7639*r,mm2:{name:{singular:"Square Millimeter",plural:"Square Millimeters"},to_anchor:1e-6},cm2:{name:{singular:"Square Centimeter",plural:"Square Centimeters"},to_anchor:1e-4},m2:{name:{singular:"Square Meter",plural:"Square Meters"},to_anchor:1},ha:{name:{singular:"Hectare",plural:"Hectares"},to_anchor:1e4},km2:{name:{singular:"Square Kilometer",plural:"Square Kilometers"},to_anchor:1e6}},imperial:{baseUnit:"ft2",transform:r=>1*r/10.7639,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 t=a({metric:{baseUnit:"c",transform:r=>1*r,c:{name:{singular:"Coulomb",plural:"Coulombs"},to_anchor:1},mC:{name:{singular:"Millicoulomb",plural:"Millicoulombs"},to_anchor:.001},"μC":{name:{singular:"Microcoulomb",plural:"Microcoulombs"},to_anchor:1e-6},nC:{name:{singular:"Nanocoulomb",plural:"Nanocoulombs"},to_anchor:1e-9},pC:{name:{singular:"Picocoulomb",plural:"Picocoulombs"},to_anchor:1e-12}}});var i=a({metric:{baseUnit:"a",transform:r=>1*r,A:{name:{singular:"Ampere",plural:"Amperes"},to_anchor:1},mA:{name:{singular:"Milliampere",plural:"Milliamperes"},to_anchor:.001},kA:{name:{singular:"Kiloampere",plural:"Kiloamperes"},to_anchor:1e3}}});var s=a({bits:{baseUnit:"b",transform:r=>1*r/8,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:r=>8*r,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 u=a({metric:{baseUnit:"ea",transform:r=>1*r,ea:{name:{singular:"Each",plural:"Each"},to_anchor:1},dz:{name:{singular:"Dozen",plural:"Dozens"},to_anchor:12}}});var m=a({metric:{baseUnit:"J",transform:r=>1*r,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:36e5},MWh:{name:{singular:"Megawatt-hour",plural:"Megawatt-hours"},to_anchor:36e8},GWh:{name:{singular:"Gigawatt-hour",plural:"Gigawatt-hours"},to_anchor:36e11},J:{name:{singular:"Joule",plural:"Joules"},to_anchor:1},kJ:{name:{singular:"Kilojoule",plural:"Kilojoules"},to_anchor:1e3}}});var c=a({metric:{baseUnit:"N",transform:r=>1*r/4.44822,N:{name:{singular:"Newton",plural:"Newtons"},to_anchor:1},kN:{name:{singular:"Kilonewton",plural:"Kilonewtons"},to_anchor:1e3}},imperial:{baseUnit:"lbf",transform:r=>4.44822*r,lbf:{name:{singular:"Pound-force",plural:"Pound-forces"},to_anchor:1}}});var p=a({metric:{baseUnit:"Hz",transform:r=>1*r,mHz:{name:{singular:"millihertz",plural:"millihertz"},to_anchor:.001},Hz:{name:{singular:"hertz",plural:"hertz"},to_anchor:1},kHz:{name:{singular:"kilohertz",plural:"kilohertz"},to_anchor:1e3},MHz:{name:{singular:"megahertz",plural:"megahertz"},to_anchor:1e6},GHz:{name:{singular:"gigahertz",plural:"gigahertz"},to_anchor:1e9},THz:{name:{singular:"terahertz",plural:"terahertz"},to_anchor:1e12},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:.15915494309189535}}});var h=a({metric:{baseUnit:"lx",transform:r=>1*r/10.76391,lx:{name:{singular:"Lux",plural:"Lux"},to_anchor:1}},imperial:{baseUnit:"ft-cd",transform:r=>10.76391*r,"ft-cd":{name:{singular:"Foot-candle",plural:"Foot-candles"},to_anchor:1}}});var g=a({metric:{baseUnit:"m",transform:r=>3.28084*r,mm:{name:{singular:"Millimeter",plural:"Millimeters"},to_anchor:.001},cm:{name:{singular:"Centimeter",plural:"Centimeters"},to_anchor:.01},m:{name:{singular:"Meter",plural:"Meters"},to_anchor:1},km:{name:{singular:"Kilometer",plural:"Kilometers"},to_anchor:1e3},".1 mm":{name:{singular:".1 mm",plural:".1 mm"},to_anchor:1e-4}},imperial:{baseUnit:"ft",transform:r=>1*r/3.28084,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 _=a({metric:{baseUnit:"ntu",transform:r=>1*r,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}}});var d=a({metric:{baseUnit:"g",transform:r=>1*r/453.592,mcg:{name:{singular:"Microgram",plural:"Micrograms"},to_anchor:1e-6},mg:{name:{singular:"Milligram",plural:"Milligrams"},to_anchor:.001},g:{name:{singular:"Gram",plural:"Grams"},to_anchor:1},kg:{name:{singular:"Kilogram",plural:"Kilograms"},to_anchor:1e3},mt:{name:{singular:"Metric Tonne",plural:"Metric Tonnes"},to_anchor:1e6}},imperial:{baseUnit:"lb",transform:r=>453.592*r,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:2e3}}});var b=a({metric:{baseUnit:"s/m",transform:r=>.3048*r,"min/km":{name:{singular:"Minute per kilometre",plural:"Minutes per kilometre"},to_anchor:.06},"s/m":{name:{singular:"Second per metre",plural:"Seconds per metre"},to_anchor:1}},imperial:{baseUnit:"s/ft",transform:r=>1*r/.3048,"min/mi":{name:{singular:"Minute per mile",plural:"Minutes per mile"},to_anchor:.0113636},"s/ft":{name:{singular:"Second per foot",plural:"Seconds per foot"},to_anchor:1}}});var f=a({metric:{baseUnit:"ppm",transform:r=>1e-6*r,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:.001},ppt:{name:{singular:"Part-per Trillion",plural:"Parts-per Trillion"},to_anchor:1e-6},ppq:{name:{singular:"Part-per Quadrillion",plural:"Parts-per Quadrillion"},to_anchor:1e-9}}});var v=a({metric:{baseUnit:"W",transform:r=>1*r,W:{name:{singular:"Watt",plural:"Watts"},to_anchor:1},mW:{name:{singular:"Milliwatt",plural:"Milliwatts"},to_anchor:.001},kW:{name:{singular:"Kilowatt",plural:"Kilowatts"},to_anchor:1e3},MW:{name:{singular:"Megawatt",plural:"Megawatts"},to_anchor:1e6},GW:{name:{singular:"Gigawatt",plural:"Gigawatts"},to_anchor:1e9}}});var M=a({metric:{baseUnit:"kPa",transform:r=>.00014503768078*r,Pa:{name:{singular:"pascal",plural:"pascals"},to_anchor:.001},kPa:{name:{singular:"kilopascal",plural:"kilopascals"},to_anchor:1},MPa:{name:{singular:"megapascal",plural:"megapascals"},to_anchor:1e3},hPa:{name:{singular:"hectopascal",plural:"hectopascals"},to_anchor:.1},".1 millibars":{name:{singular:".1 millibar",plural:".1 millibars"},to_anchor:.01},mbar:{name:{singular:"millibar",plural:"millibars"},to_anchor:.1},bar:{name:{singular:"bar",plural:"bar"},to_anchor:100},mmHg:{name:{singular:"mm Hg",plural:"mm Hg"},to_anchor:.13332239},torr:{name:{singular:"torr",plural:"torr"},to_anchor:101325/76e4},inHg:{name:{singular:"inch Hg",plural:"inches Hg"},to_anchor:3.38639}},imperial:{baseUnit:"psi",transform:r=>1*r/.00014503768078,psi:{name:{singular:"pound per square inch",plural:"pounds per square inch"},to_anchor:.001},ksi:{name:{singular:"kilopound per square inch",plural:"kilopound per square inch"},to_anchor:1}}});var C=a({metric:{baseUnit:"VARh",transform:r=>1*r,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:.001},kVARh:{name:{singular:"Kilovolt-Ampere Reactive Hour",plural:"Kilovolt-Amperes Reactive Hour"},to_anchor:1e3},MVARh:{name:{singular:"Megavolt-Ampere Reactive Hour",plural:"Megavolt-Amperes Reactive Hour"},to_anchor:1e6},GVARh:{name:{singular:"Gigavolt-Ampere Reactive Hour",plural:"Gigavolt-Amperes Reactive Hour"},to_anchor:1e9}}});var y=a({metric:{baseUnit:"VAR",transform:r=>1*r,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:.001},kVAR:{name:{singular:"Kilovolt-Ampere Reactive",plural:"Kilovolt-Amperes Reactive"},to_anchor:1e3},MVAR:{name:{singular:"Megavolt-Ampere Reactive",plural:"Megavolt-Amperes Reactive"},to_anchor:1e6},GVAR:{name:{singular:"Gigavolt-Ampere Reactive",plural:"Gigavolt-Amperes Reactive"},to_anchor:1e9}}});var U=a({metric:{baseUnit:"dS",transform:r=>1*r,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:.001},EC:{name:{singular:"electrical conductivity",plural:"electrical conductivity",abbreviation:"EC"},to_anchor:.001},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:1.5625},psu:{name:{singular:"practical salinity unit",plural:"practical salinity units",abbreviation:"psu"},to_anchor:1.5625},".1 psu":{name:{singular:".1 practical salinity unit",plural:".1 practical salinity units",abbreviation:".1 psu"},to_anchor:.15625},"10 microSiemen/cm":{name:{singular:"10 microSiemen/cm",plural:"10 microSiemen/cm",abbreviation:"10 uS/cm"},to_anchor:1e-4}}});var k=a({metric:{baseUnit:"N",transform:r=>1*r/1.609344,"mm/s":{name:{singular:"Millimetre per second",plural:"Millimeters per second"},to_anchor:.0036},".1 m/s":{name:{singular:".1 Metre per second",plural:".1 Metres per second"},to_anchor:.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:r=>1.609344*r,"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:.681818}}});var A=a({metric:{baseUnit:"db",transform:r=>1*r,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:.43}}});var w=a({metric:{baseUnit:"C",transform:r=>r/(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:.1,anchor_shift:0}},imperial:{baseUnit:"F",transform:r=>5/9*(r-32),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 S=a({metric:{baseUnit:"s",transform:r=>1*r,ns:{name:{singular:"Nanosecond",plural:"Nanoseconds"},to_anchor:1e-9},mu:{name:{singular:"Microsecond",plural:"Microseconds"},to_anchor:1e-6},ms:{name:{singular:"Millisecond",plural:"Milliseconds"},to_anchor:.001},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:3600},d:{name:{singular:"Day",plural:"Days"},to_anchor:86400},week:{name:{singular:"Week",plural:"Weeks"},to_anchor:604800},month:{name:{singular:"Month",plural:"Months"},to_anchor:2629800},year:{name:{singular:"Year",plural:"Years"},to_anchor:31557600},".1 sec":{name:{singular:".1 sec",plural:".1 secs"},to_anchor:.1}}});var K=a({metric:{baseUnit:"V",transform:r=>1*r,V:{name:{singular:"Volt",plural:"Volts"},to_anchor:1},mV:{name:{singular:"Millivolt",plural:"Millivolts"},to_anchor:.001},kV:{name:{singular:"Kilovolt",plural:"Kilovolts"},to_anchor:1e3},".1 volts":{name:{singular:".1 volt",plural:".1 volts"},to_anchor:.1},"1 millivolt":{name:{singular:"1 millivolt",plural:"1 millivolts"},to_anchor:.001}}});var x=a({metric:{baseUnit:"l",transform:r=>33.8140226*r,mm3:{name:{singular:"Cubic Millimeter",plural:"Cubic Millimeters"},to_anchor:1e-6},cm3:{name:{singular:"Cubic Centimeter",plural:"Cubic Centimeters"},to_anchor:.001},ml:{name:{singular:"Millilitre",plural:"Millilitres"},to_anchor:.001},cl:{name:{singular:"Centilitre",plural:"Centilitres"},to_anchor:.01},dl:{name:{singular:"Decilitre",plural:"Decilitres"},to_anchor:.1},l:{name:{singular:"Litre",plural:"Litres"},to_anchor:1},kl:{name:{singular:"Kilolitre",plural:"Kilolitres"},to_anchor:1e3},m3:{name:{singular:"Cubic meter",plural:"Cubic meters"},to_anchor:1e3},km3:{name:{singular:"Cubic kilometer",plural:"Cubic kilometers"},to_anchor:1e12},krm:{name:{singular:"Matsked",plural:"Matskedar"},to_anchor:.001},tsk:{name:{singular:"Tesked",plural:"Teskedar"},to_anchor:.005},msk:{name:{singular:"Matsked",plural:"Matskedar"},to_anchor:.015},kkp:{name:{singular:"Kaffekopp",plural:"Kaffekoppar"},to_anchor:.15},glas:{name:{singular:"Glas",plural:"Glas"},to_anchor:.2},kanna:{name:{singular:"Kanna",plural:"Kannor"},to_anchor:2.617}},imperial:{baseUnit:"fl-oz",transform:r=>1*r/33.8140226,tsp:{name:{singular:"Teaspoon",plural:"Teaspoons"},to_anchor:1/6},Tbs:{name:{singular:"Tablespoon",plural:"Tablespoons"},to_anchor:.5},in3:{name:{singular:"Cubic inch",plural:"Cubic inches"},to_anchor:.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 R=a({metric:{baseUnit:"l/s",transform:r=>33.8140227*r,"mm3/s":{name:{singular:"Cubic Millimeter per second",plural:"Cubic Millimeters per second"},to_anchor:1e-6},"cm3/s":{name:{singular:"Cubic Centimeter per second",plural:"Cubic Centimeters per second"},to_anchor:.001},"ml/s":{name:{singular:"Millilitre per second",plural:"Millilitres per second"},to_anchor:.001},"cl/s":{name:{singular:"Centilitre per second",plural:"Centilitres per second"},to_anchor:.01},"dl/s":{name:{singular:"Decilitre per second",plural:"Decilitres per second"},to_anchor:.1},"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:1e3},"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:1e3},"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:1e12}},imperial:{baseUnit:"fl-oz/s",transform:r=>1*r/33.8140227,"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:.5},"in3/s":{name:{singular:"Cubic inch per second",plural:"Cubic inches per second"},to_anchor:.55411},"in3/min":{name:{singular:"Cubic inch per minute",plural:"Cubic inches per minute"},to_anchor:.55411/60},"in3/h":{name:{singular:"Cubic inch per hour",plural:"Cubic inches per hour"},to_anchor:.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}}});const G={units:[e,n,l,o,t,i,s,u,m,c,p,h,g,_,d,b,f,v,M,C,y,U,A,k,w,S,K,x,R],convert:(r,a,e,n=null)=>{const l=G.units.find(r=>r().getUnit(e)&&r().getUnit(a));if(!l)throw new Error(`Cannot find unit object that has to: ${e} and from: ${a}`);return l(r).from(a).to(e,n)},findPossibilities:r=>{const a=G.units.find(a=>a().getUnit(r));if(!a)throw new Error("Cannot find unit object with from: "+r);return a().from(r).possibilities()},getLibrary:(r=null,a=null)=>{if(!r&&!a)throw new Error(`One arguement must be defined, from: ${r}, to: ${a}`);const e=G.units.find(e=>{let n=[];return e().getUnit(r)&&n.push(!0),e().getUnit(a)&&n.push(!0),n.length>0});if(!e)throw new Error(`Cannot find unit object that has to: ${a} and from: ${r}`);return e}};var V=a({metric:{baseUnit:"Original",transform:r=>1*r,Original:{name:{singular:"Original Value",plural:"Original Values"},to_anchor:1},psu:{name:{singular:".00001 psu",plural:".00001 psu"},to_anchor:1e-5},MV:{name:{singular:"1 millivolt",plural:"1 millivolts"},to_anchor:.001},cal:{name:{singular:".001 cal/cm^2",plural:".001 cal/cm^2"},to_anchor:.001},calM:{name:{singular:".001 cal/cm^2/min",plural:".001 cal/cm^2/min"},to_anchor:.001},mcg:{name:{singular:".01 mcg/L",plural:".01 mcg/L"},to_anchor:.01},percent:{name:{singular:".1 %",plural:".1 %"},to_anchor:.1},degC:{name:{singular:".1 degC",plural:".1 degC"},to_anchor:.1},ms:{name:{singular:".1 m/s",plural:".1 m/s"},to_anchor:.1},mb:{name:{singular:".1 millibar",plural:".1 millibars"},to_anchor:.1},mm:{name:{singular:".1 mm",plural:".1 mm"},to_anchor:.1},ntu:{name:{singular:".1 ntu",plural:".1 ntu"},to_anchor:.1},sec:{name:{singular:".1 sec",plural:".1 sec"},to_anchor:.1},v:{name:{singular:".1 volt",plural:".1 volts"},to_anchor:.1},dB:{name:{singular:".43 dB",plural:".43 dB"},to_anchor:.43},cells:{name:{singular:"10 cells/mL",plural:"10 cells/mL"},to_anchor:10},cfs:{name:{singular:"10 cfs",plural:"10 cfs"},to_anchor:10},microhos:{name:{singular:"10 micromhos/cm",plural:"10 micromhos/cm"},to_anchor:10},microSiemen:{name:{singular:"10 microSiemen/cm",plural:"10 microSiemen/cm"},to_anchor:10},degfromN:{name:{singular:"degfromN",plural:"degfromN"},to_anchor:1},degrees:{name:{singular:"degrees",plural:"degrees"},to_anchor:1}}});exports.acceleration=e,exports.allUnits=G,exports.angle=n,exports.apparentPower=l,exports.area=o,exports.charge=t,exports.current=i,exports.digital=s,exports.each=u,exports.energy=m,exports.force=c,exports.frequency=p,exports.illuminance=h,exports.length=g,exports.light=_,exports.mass=d,exports.pace=b,exports.partsPer=f,exports.pharos=V,exports.power=v,exports.pressure=M,exports.reactiveEnergy=C,exports.reactivePower=y,exports.salinity=U,exports.sound=A,exports.speed=k,exports.temperature=w,exports.time=S,exports.voltage=K,exports.volume=x,exports.volumeFlowRate=R;