/*! https://davidwalsh.name/essential-javascript-functions */
export const getAbsoluteUrl = (function(){
	var a;

	return function(url) {
		if(!a) a = document.createElement('a');
		a.href = url;

		return a.href;
	};
})();

/*! https://davidwalsh.name/essential-javascript-functions */
export function once(context) {
  let result;

	return function() { 
		if(fn) {
			result = fn.apply(context || this, arguments);
			fn = null;
		}

		return result;
	};
}

/*! https://davidwalsh.name/essential-javascript-functions */
export function poll(fn, callback, errback, timeout, interval) {
  var endTime = Number(new Date()) + (timeout || 2000);
  interval = interval || 100;

  (function p() {
    if(fn()) {
        callback();
    } else if (Number(new Date()) < endTime) {
        setTimeout(p, interval);
    } else {
        errback(new Error('timed out for ' + fn + ': ' + arguments));
    }
  })();
}

/*! http://stackoverflow.com/questions/24004791/can-someone-explain-the-debounce-function-in-javascript */
export function debounce(func, wait, immediate) {
  let timeout;           

  return function() {
      const context = this; 
      const args = arguments;

      const call_now = immediate && !timeout;

      clearTimeout(timeout);   

      timeout = setTimeout(function(){
           timeout = null;

           if (!immediate) {
             func.apply(context, args);
           }
      }, wait);

      if (call_now) func.apply(context, args);  
   };
}
@@ -308,26 +308,25 @@
 (context) %7B%0A
-  
+%09
 let result;%0A
@@ -350,14 +350,14 @@
 () %7B
- 
 %0A%09%09if
+ 
 (fn)
@@ -699,24 +699,19 @@
 fn()) %7B%0A
-        
+%09%09%09
 callback
@@ -761,24 +761,19 @@
 Time) %7B%0A
-        
+%09%09%09
 setTimeo
@@ -802,24 +802,19 @@
  else %7B%0A
-        
+%09%09%09
 errback(
@@ -1055,27 +1055,16 @@
 timeout;
-           
 %0A%0A  retu
@@ -1079,26 +1079,24 @@
 ion() %7B%0A    
-  
 const contex
@@ -1108,16 +1108,13 @@
 his;
- %0A 
+%0A
     
- 
 cons
@@ -1133,19 +1133,16 @@
 uments;%0A
-%0A  
     cons
@@ -1182,18 +1182,16 @@
 t;%0A%0A    
-  
 clearTim
@@ -1208,15 +1208,10 @@
 ut);
-   %0A%0A  
+%0A%0A
     
@@ -1243,27 +1243,19 @@
 tion()%7B%0A
-           
+%09%09%09
 timeout 
@@ -1269,21 +1269,16 @@
 %0A%0A      
-  
-   
 if (!imm
@@ -1293,23 +1293,17 @@
 %7B%0A      
- 
-      
+%09
 func.app
@@ -1331,17 +1331,10 @@
     
-  
-   %7D%0A  
+%7D%0A
     
@@ -1344,26 +1344,24 @@
 wait);%0A%0A    
-  
 if (call_now
@@ -1362,16 +1362,21 @@
 ll_now) 
+%7B%0A%09%09%09
 func.app
@@ -1397,14 +1397,16 @@
 gs);
-  
+%0A%09%09%7D
 %0A   %7D;%0A%7D
@@ -1401,12 +1401,13 @@
 %0A%09%09%7D%0A   %7D;%0A%7D
+%0A

fix spacing