made with requirebin
Created
November 29, 2017 12:17
-
-
Save maltegrosse/1c98c8d43baa496cfce07f0366395622 to your computer and use it in GitHub Desktop.
requirebin sketch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var convert = require('convert-units'); | |
console.log(convert(1).from('l').to('ml')); | |
console.log(window.location.href); | |
var url_string = window.location.href; | |
var url = new URL(url_string); | |
var input = url.searchParams.get("in"); | |
var output = url.searchParams.get("out"); | |
console.log(input); | |
console.log(output); | |
document.write(). | |
convert(1).from(input).to(output); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setTimeout(function(){require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){var apparentPower;apparentPower={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}};module.exports={metric:apparentPower,_anchors:{metric:{unit:"VA",ratio:1}}}},{}],2:[function(require,module,exports){var metric,imperial;metric={mm2:{name:{singular:"Square Millimeter",plural:"Square Millimeters"},to_anchor:1/1e6},cm2:{name:{singular:"Centimeter",plural:"Centimeters"},to_anchor:1/1e4},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={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}};module.exports={metric:metric,imperial:imperial,_anchors:{metric:{unit:"m2",ratio:10.7639},imperial:{unit:"ft2",ratio:1/10.7639}}}},{}],3:[function(require,module,exports){var current;current={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}};module.exports={metric:current,_anchors:{metric:{unit:"A",ratio:1}}}},{}],4:[function(require,module,exports){var bits,bytes;bits={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={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}};module.exports={bits:bits,bytes:bytes,_anchors:{bits:{unit:"b",ratio:1/8},bytes:{unit:"B",ratio:8}}}},{}],5:[function(require,module,exports){var metric,imperial;metric={ea:{name:{singular:"Each",plural:"Each"},to_anchor:1}};module.exports={metric:metric,imperial:{},_anchors:{metric:{unit:"ea",ratio:1}}}},{}],6:[function(require,module,exports){var energy;energy={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}};module.exports={metric:energy,_anchors:{metric:{unit:"J",ratio:1}}}},{}],7:[function(require,module,exports){var metric,imperial;metric={mm:{name:{singular:"Millimeter",plural:"Millimeters"},to_anchor:1/1e3},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:1e3}};imperial={"in":{name:{singular:"Inch",plural:"Inches"},to_anchor:1/12},yd:{name:{singular:"Yard",plural:"Yards"},to_anchor:3},ft:{name:{singular:"Foot",plural:"Feet"},to_anchor:1},mi:{name:{singular:"Mile",plural:"Miles"},to_anchor:5280}};module.exports={metric:metric,imperial:imperial,_anchors:{metric:{unit:"m",ratio:3.281},imperial:{unit:"ft",ratio:1/3.281}}}},{}],8:[function(require,module,exports){var metric,imperial;metric={mcg:{name:{singular:"Microgram",plural:"Micrograms"},to_anchor:1/1e6},mg:{name:{singular:"Milligram",plural:"Milligrams"},to_anchor:1/1e3},g:{name:{singular:"Gram",plural:"Grams"},to_anchor:1},kg:{name:{singular:"Kilogram",plural:"Kilograms"},to_anchor:1e3}};imperial={oz:{name:{singular:"Ounce",plural:"Ounces"},to_anchor:1/16},lb:{name:{singular:"Pound",plural:"Pounds"},to_anchor:1}};module.exports={metric:metric,imperial:imperial,_anchors:{metric:{unit:"g",ratio:1/453.592},imperial:{unit:"lb",ratio:453.592}}}},{}],9:[function(require,module,exports){var metric,imperial;metric={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}};module.exports={metric:metric,imperial:{},_anchors:{metric:{unit:"ppm",ratio:1e-6}}}},{}],10:[function(require,module,exports){var power;power={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}};module.exports={metric:power,_anchors:{metric:{unit:"W",ratio:1}}}},{}],11:[function(require,module,exports){var metric,imperial;metric={Pa:{name:{singular:"pascal",plural:"pascals"},to_anchor:1/1e3},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/10},bar:{name:{singular:"bar",plural:"bar"},to_anchor:100},torr:{name:{singular:"torr",plural:"torr"},to_anchor:101325/76e4}};imperial={psi:{name:{singular:"pound per square inch",plural:"pounds per square inch"},to_anchor:1/1e3},ksi:{name:{singular:"kilopound per square inch",plural:"kilopound per square inch"},to_anchor:1}};module.exports={metric:metric,imperial:imperial,_anchors:{metric:{unit:"kPa",ratio:.00014503768078},imperial:{unit:"psi",ratio:1/.00014503768078}}}},{}],12:[function(require,module,exports){var reactiveEnergy;reactiveEnergy={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}};module.exports={metric:reactiveEnergy,_anchors:{metric:{unit:"VARh",ratio:1}}}},{}],13:[function(require,module,exports){var reactivePower;reactivePower={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}};module.exports={metric:reactivePower,_anchors:{metric:{unit:"VAR",ratio:1}}}},{}],14:[function(require,module,exports){var metric,imperial;metric={"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={"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}};module.exports={metric:metric,imperial:imperial,_anchors:{metric:{unit:"km/h",ratio:1/1.609344},imperial:{unit:"m/h",ratio:1.609344}}}},{}],15:[function(require,module,exports){var metric,imperial;metric={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}};imperial={F:{name:{singular:"degree Fahrenheit",plural:"degrees Fahrenheit"},to_anchor:1}};module.exports={metric:metric,imperial:imperial,_anchors:{metric:{unit:"C",transform:function(C){return C/(5/9)+32}},imperial:{unit:"F",transform:function(F){return(F-32)*(5/9)}}}}},{}],16:[function(require,module,exports){var time;var daysInYear=365.25;time={ns:{name:{singular:"Nanosecond",plural:"Nanoseconds"},to_anchor:1/1e9},mu:{name:{singular:"Microsecond",plural:"Microseconds"},to_anchor:1/1e6},ms:{name:{singular:"Millisecond",plural:"Milliseconds"},to_anchor:1/1e3},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}};module.exports={metric:time,_anchors:{metric:{unit:"s",ratio:1}}}},{}],17:[function(require,module,exports){var voltage;voltage={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}};module.exports={metric:voltage,_anchors:{metric:{unit:"V",ratio:1}}}},{}],18:[function(require,module,exports){var metric,imperial;metric={mm3:{name:{singular:"Cubic Millimeter",plural:"Cubic Millimeters"},to_anchor:1/1e6},cm3:{name:{singular:"Cubic Centimeter",plural:"Cubic Centimeters"},to_anchor:1/1e3},ml:{name:{singular:"Millilitre",plural:"Millilitres"},to_anchor:1/1e3},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: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:1/1e3},tsk:{name:{singular:"Tesked",plural:"Teskedar"},to_anchor:5/1e3},msk:{name:{singular:"Matsked",plural:"Matskedar"},to_anchor:15/1e3},kkp:{name:{singular:"Kaffekopp",plural:"Kaffekoppar"},to_anchor:150/1e3},glas:{name:{singular:"Glas",plural:"Glas"},to_anchor:200/1e3},kanna:{name:{singular:"Kanna",plural:"Kannor"},to_anchor:2.617}};imperial={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:.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}};module.exports={metric:metric,imperial:imperial,_anchors:{metric:{unit:"l",ratio:33.8140226},imperial:{unit:"fl-oz",ratio:1/33.8140226}}}},{}],19:[function(require,module,exports){var metric,imperial;metric={"mm3/s":{name:{singular:"Cubic Millimeter per second",plural:"Cubic Millimeters per second"},to_anchor:1/1e6},"cm3/s":{name:{singular:"Cubic Centimeter per second",plural:"Cubic Centimeters per second"},to_anchor:1/1e3},"ml/s":{name:{singular:"Millilitre per second",plural:"Millilitres per second"},to_anchor:1/1e3},"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: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={"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:.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}};module.exports={metric:metric,imperial:imperial,_anchors:{metric:{unit:"l/s",ratio:33.8140227},imperial:{unit:"fl-oz/s",ratio:1/33.8140227}}}},{}],20:[function(require,module,exports){var baseCreateCallback=require("lodash._basecreatecallback"),forOwn=require("lodash.forown");function forEach(collection,callback,thisArg){var index=-1,length=collection?collection.length:0;callback=callback&&typeof thisArg=="undefined"?callback:baseCreateCallback(callback,thisArg,3);if(typeof length=="number"){while(++index<length){if(callback(collection[index],index,collection)===false){break}}}else{forOwn(collection,callback)}return collection}module.exports=forEach},{"lodash._basecreatecallback":21,"lodash.forown":43}],21:[function(require,module,exports){var bind=require("lodash.bind"),identity=require("lodash.identity"),setBindData=require("lodash._setbinddata"),support=require("lodash.support");var reFuncName=/^\s*function[ \n\r\t]+\w/;var reThis=/\bthis\b/;var fnToString=Function.prototype.toString;function baseCreateCallback(func,thisArg,argCount){if(typeof func!="function"){return identity}if(typeof thisArg=="undefined"||!("prototype"in func)){return func}var bindData=func.__bindData__;if(typeof bindData=="undefined"){if(support.funcNames){bindData=!func.name}bindData=bindData||!support.funcDecomp;if(!bindData){var source=fnToString.call(func);if(!support.funcNames){bindData=!reFuncName.test(source)}if(!bindData){bindData=reThis.test(source);setBindData(func,bindData)}}}if(bindData===false||bindData!==true&&bindData[1]&1){return func}switch(argCount){case 1:return function(value){return func.call(thisArg,value)};case 2:return function(a,b){return func.call(thisArg,a,b)};case 3:return function(value,index,collection){return func.call(thisArg,value,index,collection)};case 4:return function(accumulator,value,index,collection){return func.call(thisArg,accumulator,value,index,collection)}}return bind(func,thisArg)}module.exports=baseCreateCallback},{"lodash._setbinddata":22,"lodash.bind":25,"lodash.identity":40,"lodash.support":41}],22:[function(require,module,exports){var noop=require("lodash.noop"),reNative=require("lodash._renative");var descriptor={configurable:false,enumerable:false,value:null,writable:false};var defineProperty=function(){try{var o={},func=reNative.test(func=Object.defineProperty)&&func,result=func(o,o,o)&&func}catch(e){}return result}();var setBindData=!defineProperty?noop:function(func,value){descriptor.value=value;defineProperty(func,"__bindData__",descriptor)};module.exports=setBindData},{"lodash._renative":23,"lodash.noop":24}],23:[function(require,module,exports){var objectProto=Object.prototype;var toString=objectProto.toString;var reNative=RegExp("^"+String(toString).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$");module.exports=reNative},{}],24:[function(require,module,exports){function noop(){}module.exports=noop},{}],25:[function(require,module,exports){var createWrapper=require("lodash._createwrapper"),reNative=require("lodash._renative"),slice=require("lodash._slice");function bind(func,thisArg){return arguments.length>2?createWrapper(func,17,slice(arguments,2),null,thisArg):createWrapper(func,1,null,null,thisArg)}module.exports=bind},{"lodash._createwrapper":26,"lodash._renative":38,"lodash._slice":39}],26:[function(require,module,exports){var baseBind=require("lodash._basebind"),baseCreateWrapper=require("lodash._basecreatewrapper"),isFunction=require("lodash.isfunction");var arrayRef=[];var push=arrayRef.push;function createWrapper(func,bitmask,partialArgs,partialRightArgs,thisArg,arity){var isBind=bitmask&1,isBindKey=bitmask&2,isCurry=bitmask&4,isCurryBound=bitmask&8,isPartial=bitmask&16,isPartialRight=bitmask&32;if(!isBindKey&&!isFunction(func)){throw new TypeError}if(isPartial&&!partialArgs.length){bitmask&=~16;isPartial=partialArgs=false}if(isPartialRight&&!partialRightArgs.length){bitmask&=~32;isPartialRight=partialRightArgs=false}var bindData=func&&func.__bindData__;if(bindData&&bindData!==true){bindData=bindData.slice();if(isBind&&!(bindData[1]&1)){bindData[4]=thisArg}if(!isBind&&bindData[1]&1){bitmask|=8}if(isCurry&&!(bindData[1]&4)){bindData[5]=arity}if(isPartial){push.apply(bindData[2]||(bindData[2]=[]),partialArgs)}if(isPartialRight){push.apply(bindData[3]||(bindData[3]=[]),partialRightArgs)}bindData[1]|=bitmask;return createWrapper.apply(null,bindData)}var creater=bitmask==1||bitmask===17?baseBind:baseCreateWrapper;return creater([func,bitmask,partialArgs,partialRightArgs,thisArg,arity])}module.exports=createWrapper},{"lodash._basebind":27,"lodash._basecreatewrapper":32,"lodash.isfunction":37}],27:[function(require,module,exports){var baseCreate=require("lodash._basecreate"),isObject=require("lodash.isobject"),setBindData=require("lodash._setbinddata");var arrayRef=[];var push=arrayRef.push;function baseBind(bindData){var func=bindData[0],partialArgs=bindData[2],thisArg=bindData[4];function bound(){if(partialArgs){var args=partialArgs.slice();push.apply(args,arguments)}if(this instanceof bound){var thisBinding=baseCreate(func.prototype),result=func.apply(thisBinding,args||arguments);return isObject(result)?result:thisBinding}return func.apply(thisArg,args||arguments)}setBindData(bound,bindData);return bound}module.exports=baseBind},{"lodash._basecreate":28,"lodash._setbinddata":22,"lodash.isobject":30}],28:[function(require,module,exports){(function(global){var isObject=require("lodash.isobject"),noop=require("lodash.noop"),reNative=require("lodash._renative");var nativeCreate=reNative.test(nativeCreate=Object.create)&&nativeCreate;function baseCreate(prototype,properties){return isObject(prototype)?nativeCreate(prototype):{}}if(!nativeCreate){baseCreate=function(){function Object(){}return function(prototype){if(isObject(prototype)){Object.prototype=prototype;var result=new Object;Object.prototype=null}return result||global.Object()}}()}module.exports=baseCreate}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"lodash._renative":38,"lodash.isobject":30,"lodash.noop":29}],29:[function(require,module,exports){arguments[4][24][0].apply(exports,arguments)},{dup:24}],30:[function(require,module,exports){var objectTypes=require("lodash._objecttypes");function isObject(value){return!!(value&&objectTypes[typeof value])}module.exports=isObject},{"lodash._objecttypes":31}],31:[function(require,module,exports){var objectTypes={"boolean":false,"function":true,object:true,number:false,string:false,undefined:false};module.exports=objectTypes},{}],32:[function(require,module,exports){var baseCreate=require("lodash._basecreate"),isObject=require("lodash.isobject"),setBindData=require("lodash._setbinddata"),slice=require("lodash._slice");var arrayRef=[];var push=arrayRef.push;function baseCreateWrapper(bindData){var func=bindData[0],bitmask=bindData[1],partialArgs=bindData[2],partialRightArgs=bindData[3],thisArg=bindData[4],arity=bindData[5];var isBind=bitmask&1,isBindKey=bitmask&2,isCurry=bitmask&4,isCurryBound=bitmask&8,key=func;function bound(){var thisBinding=isBind?thisArg:this;if(partialArgs){var args=partialArgs.slice();push.apply(args,arguments)}if(partialRightArgs||isCurry){args||(args=slice(arguments));if(partialRightArgs){push.apply(args,partialRightArgs)}if(isCurry&&args.length<arity){bitmask|=16&~32;return baseCreateWrapper([func,isCurryBound?bitmask:bitmask&~3,args,null,thisArg,arity])}}args||(args=arguments);if(isBindKey){func=thisBinding[key]}if(this instanceof bound){thisBinding=baseCreate(func.prototype);var result=func.apply(thisBinding,args);return isObject(result)?result:thisBinding}return func.apply(thisBinding,args)}setBindData(bound,bindData);return bound}module.exports=baseCreateWrapper},{"lodash._basecreate":33,"lodash._setbinddata":22,"lodash._slice":39,"lodash.isobject":35}],33:[function(require,module,exports){(function(global){var isObject=require("lodash.isobject"),noop=require("lodash.noop"),reNative=require("lodash._renative");var nativeCreate=reNative.test(nativeCreate=Object.create)&&nativeCreate;function baseCreate(prototype,properties){return isObject(prototype)?nativeCreate(prototype):{}}if(!nativeCreate){baseCreate=function(){function Object(){}return function(prototype){if(isObject(prototype)){Object.prototype=prototype;var result=new Object;Object.prototype=null}return result||global.Object()}}()}module.exports=baseCreate}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"lodash._renative":38,"lodash.isobject":35,"lodash.noop":34}],34:[function(require,module,exports){arguments[4][24][0].apply(exports,arguments)},{dup:24}],35:[function(require,module,exports){arguments[4][30][0].apply(exports,arguments)},{dup:30,"lodash._objecttypes":36}],36:[function(require,module,exports){arguments[4][31][0].apply(exports,arguments)},{dup:31}],37:[function(require,module,exports){function isFunction(value){return typeof value=="function"}module.exports=isFunction},{}],38:[function(require,module,exports){arguments[4][23][0].apply(exports,arguments)},{dup:23}],39:[function(require,module,exports){function slice(array,start,end){start||(start=0);if(typeof end=="undefined"){end=array?array.length:0}var index=-1,length=end-start||0,result=Array(length<0?0:length);while(++index<length){result[index]=array[start+index]}return result}module.exports=slice},{}],40:[function(require,module,exports){function identity(value){return value}module.exports=identity},{}],41:[function(require,module,exports){(function(global){var reNative=require("lodash._renative");var reThis=/\bthis\b/;var support={};support.funcDecomp=!reNative.test(global.WinRTError)&&reThis.test(function(){return this});support.funcNames=typeof Function.name=="string";module.exports=support}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"lodash._renative":42}],42:[function(require,module,exports){arguments[4][23][0].apply(exports,arguments)},{dup:23}],43:[function(require,module,exports){var baseCreateCallback=require("lodash._basecreatecallback"),keys=require("lodash.keys"),objectTypes=require("lodash._objecttypes");var forOwn=function(collection,callback,thisArg){var index,iterable=collection,result=iterable;if(!iterable)return result;if(!objectTypes[typeof iterable])return result;callback=callback&&typeof thisArg=="undefined"?callback:baseCreateCallback(callback,thisArg,3);var ownIndex=-1,ownProps=objectTypes[typeof iterable]&&keys(iterable),length=ownProps?ownProps.length:0;while(++ownIndex<length){index=ownProps[ownIndex];if(callback(iterable[index],index,collection)===false)return result}return result};module.exports=forOwn},{"lodash._basecreatecallback":21,"lodash._objecttypes":44,"lodash.keys":45}],44:[function(require,module,exports){arguments[4][31][0].apply(exports,arguments)},{dup:31}],45:[function(require,module,exports){var isObject=require("lodash.isobject"),reNative=require("lodash._renative"),shimKeys=require("lodash._shimkeys");var nativeKeys=reNative.test(nativeKeys=Object.keys)&&nativeKeys;var keys=!nativeKeys?shimKeys:function(object){if(!isObject(object)){return[]}return nativeKeys(object)};module.exports=keys},{"lodash._renative":46,"lodash._shimkeys":47,"lodash.isobject":49}],46:[function(require,module,exports){arguments[4][23][0].apply(exports,arguments)},{dup:23}],47:[function(require,module,exports){var objectTypes=require("lodash._objecttypes");var objectProto=Object.prototype;var hasOwnProperty=objectProto.hasOwnProperty;var shimKeys=function(object){var index,iterable=object,result=[];if(!iterable)return result;if(!objectTypes[typeof object])return result;for(index in iterable){if(hasOwnProperty.call(iterable,index)){result.push(index)}}return result};module.exports=shimKeys},{"lodash._objecttypes":48}],48:[function(require,module,exports){arguments[4][31][0].apply(exports,arguments)},{dup:31}],49:[function(require,module,exports){arguments[4][30][0].apply(exports,arguments)},{dup:30,"lodash._objecttypes":50}],50:[function(require,module,exports){arguments[4][31][0].apply(exports,arguments)},{dup:31}],"convert-units":[function(require,module,exports){var convert,keys=require("lodash.keys"),each=require("lodash.foreach"),measures={length:require("./definitions/length"),area:require("./definitions/area"),mass:require("./definitions/mass"),volume:require("./definitions/volume"),each:require("./definitions/each"),temperature:require("./definitions/temperature"),time:require("./definitions/time"),digital:require("./definitions/digital"),partsPer:require("./definitions/partsPer"),speed:require("./definitions/speed"),pressure:require("./definitions/pressure"),current:require("./definitions/current"),voltage:require("./definitions/voltage"),power:require("./definitions/power"),reactivePower:require("./definitions/reactivePower"),apparentPower:require("./definitions/apparentPower"),energy:require("./definitions/energy"),reactiveEnergy:require("./definitions/reactiveEnergy"),volumeFlowRate:require("./definitions/volumeFlowRate")},Converter;Converter=function(numerator,denominator){if(denominator)this.val=numerator/denominator;else this.val=numerator};Converter.prototype.from=function(from){if(this.destination)throw new Error(".from must be called before .to");this.origin=this.getUnit(from);if(!this.origin){this.throwUnsupportedUnitError(from)}return this};Converter.prototype.to=function(to){if(!this.origin)throw new Error(".to must be called after .from");this.destination=this.getUnit(to);var result,transform;if(!this.destination){this.throwUnsupportedUnitError(to)}if(this.origin.abbr===this.destination.abbr){return this.val}if(this.destination.measure!=this.origin.measure){throw new Error("Cannot convert incompatible measures of "+this.destination.measure+" and "+this.origin.measure)}result=this.val*this.origin.unit.to_anchor;if(this.destination.unit.anchor_shift){result+=this.destination.unit.anchor_shift}if(this.origin.unit.anchor_shift){result-=this.origin.unit.anchor_shift}if(this.origin.system!=this.destination.system){transform=measures[this.origin.measure]._anchors[this.origin.system].transform;if(typeof transform==="function"){return result=transform(result)}result*=measures[this.origin.measure]._anchors[this.origin.system].ratio}return result/this.destination.unit.to_anchor};Converter.prototype.toBest=function(options){if(!this.origin)throw new Error(".toBest must be called after .from");if(options==null){options={exclude:[]}}var best;each(this.possibilities(),function(possibility){var unit=this.describe(possibility);var isIncluded=options.exclude.indexOf(possibility)===-1;if(isIncluded&&unit.system===this.origin.system){var result=this.to(possibility);if(!best||result>=1&&result<best.val){best={val:result,unit:possibility,singular:unit.singular,plural:unit.plural}}}}.bind(this));return best};Converter.prototype.getUnit=function(abbr){var found;each(measures,function(systems,measure){each(systems,function(units,system){if(system=="_anchors")return false;each(units,function(unit,testAbbr){if(testAbbr==abbr){found={abbr:abbr,measure:measure,system:system,unit:unit};return false}});if(found)return false});if(found)return false});return found};var describe=function(resp){return{abbr:resp.abbr,measure:resp.measure,system:resp.system,singular:resp.unit.name.singular,plural:resp.unit.name.plural}};Converter.prototype.describe=function(abbr){var resp=Converter.prototype.getUnit(abbr);var desc=null;try{desc=describe(resp)}catch(err){this.throwUnsupportedUnitError(abbr)}return desc};Converter.prototype.list=function(measure){var list=[];each(measures,function(systems,testMeasure){if(measure&&measure!==testMeasure)return;each(systems,function(units,system){if(system=="_anchors")return false;each(units,function(unit,abbr){ | |
list=list.concat(describe({abbr:abbr,measure:testMeasure,system:system,unit:unit}))})})});return list};Converter.prototype.throwUnsupportedUnitError=function(what){var validUnits=[];each(measures,function(systems,measure){each(systems,function(units,system){if(system=="_anchors")return false;validUnits=validUnits.concat(keys(units))})});throw new Error("Unsupported unit "+what+", use one of: "+validUnits.join(", "))};Converter.prototype.possibilities=function(measure){var possibilities=[];if(!this.origin&&!measure){each(keys(measures),function(measure){each(measures[measure],function(units,system){if(system=="_anchors")return false;possibilities=possibilities.concat(keys(units))})})}else{measure=measure||this.origin.measure;each(measures[measure],function(units,system){if(system=="_anchors")return false;possibilities=possibilities.concat(keys(units))})}return possibilities};Converter.prototype.measures=function(){return keys(measures)};convert=function(value){return new Converter(value)};module.exports=convert},{"./definitions/apparentPower":1,"./definitions/area":2,"./definitions/current":3,"./definitions/digital":4,"./definitions/each":5,"./definitions/energy":6,"./definitions/length":7,"./definitions/mass":8,"./definitions/partsPer":9,"./definitions/power":10,"./definitions/pressure":11,"./definitions/reactiveEnergy":12,"./definitions/reactivePower":13,"./definitions/speed":14,"./definitions/temperature":15,"./definitions/time":16,"./definitions/voltage":17,"./definitions/volume":18,"./definitions/volumeFlowRate":19,"lodash.foreach":20,"lodash.keys":45}]},{},[]);var convert=require("convert-units");console.log(convert(1).from("l").to("ml"));console.log(window.location.href);var url_string=window.location.href;var url=new URL(url_string);var input=url.searchParams.get("in");var output=url.searchParams.get("out");console.log(input);console.log(output);document.write().convert(1).from(input).to(output)},0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "convert-units", | |
"version": "2.3.1", | |
"description": "Convert between quantities in different units", | |
"main": "lib", | |
"dependencies": { | |
"convert-units": "2.2.0" | |
}, | |
"devDependencies": { | |
"assert-diff": "^1.1.0", | |
"jake": "8.0.12" | |
}, | |
"scripts": { | |
"test": "jake test --trace" | |
}, | |
"repository": { | |
"type": "git", | |
"url": "git://github.com/ben-ng/convert-units.git" | |
}, | |
"keywords": [ | |
"metric", | |
"imperial", | |
"convert", | |
"ratio", | |
"fraction" | |
], | |
"author": "Ben Ng <me@benng.me> (http://benng.me)", | |
"license": "MIT" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- contents of this file will be placed inside the <body> --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- contents of this file will be placed inside the <head> --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment