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
/** | |
* @license Copyright 2015 - Chris West - MIT Licensed | |
* Gets the substring after the specified target. | |
* @param {string|RegExp} target | |
* Specifies the substring to key off in order to pull the substring that | |
* follows it. | |
* @param {number=} opt_occurrence | |
* Optional. The number of the occurrence to key off of. Defaults to 1. | |
* @return {string|null} | |
* If the target is found, the substring that follows will be returned. |
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
(function(RGX, STR, undefined) { | |
/** | |
* Surrounds the string with the specified string(s). | |
* @param {string} wrap1 | |
* The string to precede this string. | |
* @param {string=} opt_wrap2 | |
* The string to follow this string. Defaults to the value of `wrap1` if | |
* not given. | |
* @param {string=} opt_wrap1rep | |
* The string to replace all occurrences of `wrap1` within this string. |
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
String.prototype.insert = function(strToInsert, num_rgx_str, opt_after) { | |
return ({}).toString.call(num_rgx_str) == '[object Number]' | |
? this.slice(0, num_rgx_str + strToInsert + this.slice(num_rgx_str) | |
: this.replace(num_rgx_str, function(match) { | |
return opt_after ? match + strToInsert : (strToInsert + match); | |
}); | |
}; |
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
(function(a,b,c){function d(a){a.style&&(a.style.cssText='');for(var b,c=0;b=a.childNodes[c++];)d(b)}a=document.styleSheets;for(c=a.length;b=a[--c];)b.disabled=!0;d(document.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
/** | |
* Evaluate a string of JavaScript code in the global namespace. | |
* NOTE: This differs from eval() in that it doesn't return a value. | |
* @param {string} code The JavaScript code to be executed in the global namespace. | |
*/ | |
function globalEval(code) { | |
var script = document.createElement('script'); | |
script.src = 'data:application/javascript;charset=utf-8,' + encodeURIComponent(code); | |
(document.getElementsByTagName('head')[0] || document.body).appendChild(script); | |
} |
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
/** | |
* Copies a function and rate limits it so it will only execute once within the | |
* given amount of milliseconds. | |
* @param {!Function} fn The function to be rate limited. | |
* @param {number} threshold The minimum amount of milliseconds between | |
* subsequent function executions. | |
* @param {boolean=} opt_waitAfter Optional parameter defaulting to false. | |
* If set to true the delay doesn't start until after the function | |
* executes. | |
* @return {!Function} The rate limited version of the function passed in. |
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
function getCall(fn) { | |
return function() { | |
return fn.call.apply(fn, arguments); | |
}; | |
} |
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
function getApply(fn) { | |
return function(context, args) { | |
return fn.apply(context, args); | |
}; | |
} |
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
function call() { | |
return call.call.apply(call.call, arguments); | |
} |
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
function apply(fn, context, args) { | |
return fn.apply(context, args); | |
} |