-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconversion.min.js
1 lines (1 loc) · 1.51 KB
/
conversion.min.js
1
!function(){"use strict";function a(a){f.extend(this,a)}var b,c="undefined"!=typeof module&&module.exports,d=[],e={precision:4},f={};d.push({celsius:1,fahrenheit:-17.7778,kelvin:-273.15}),d.push({kilometer:1e3,meter:1,centimeter:.01,millimeter:.001,mile:1609.34,yard:.9144,inch:.0254,foot:.3048,feet:.3048,"nautical-mile":1852}),d.push({"metric-ton":1e3,kilogram:1,gram:.001,milligram:1e-6,mcg:1e-9,"long-ton":1016.05,"short-ton":907.185,stone:6.35029,pound:.453592,ounce:.0283495}),d.push({mph:.44704,fps:.3048,mps:1,kph:.277778,knot:.514444});var g=function(){h()};b=function(b,c,d){var g={};return g.value=b,g.suffix=f.normalize(c),f.extend(g,e),d&&f.extend(g,d),new a(g)};var h=function(){for(var b,c=0;c<d.length;c++)for(var e in d[c]){b=3===c?!0:!1;var g=f.makeMethodName(e,b);a.prototype[g]=function(){var a=e,b=c;return function(){return Number((this.value*d[b][this.suffix]/d[b][a]).toFixed(this.precision))}}()}};f.normalize=function(a){return a.length<4?a.toLowerCase():a.toLowerCase().replace(/s$/i,"")},f.handleUnique=function(a){return"foot"===a?"toFeet":!1},f.extend=function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return b.hasOwnProperty("toString")&&(a.toString=b.toString),b.hasOwnProperty("valueOf")&&(a.valueOf=b.valueOf),a},f.makeMethodName=function(a,b){var c=a.split("-"),d="to",e=[["s","x"],["ch","sh"]],g=f.handleUnique(a);return g?g:(c.forEach(function(a){d+=a[0].toUpperCase()+a.substring(1)}),b?d:d+=~e[0].indexOf(d.slice(-1))||~e[1].indexOf(d.slice(-2))?"es":"s")},g(),c?module.exports=b:window.convert=b}();