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 int(str) { | |
return parseInt(str, 10); | |
} |
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 removeSpecialChars (str) { | |
return str.replace(/[^a-zA-Z ]/g, ""); | |
} |
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 isArray = (function() { | |
if (!isFunction(Array.isArray)) { | |
return function(value) { | |
return toString.call(value) === '[object Array]'; | |
}; | |
} | |
return Array.isArray; | |
})(); |
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
/* | |
* @param {Object|Array|Date|string|number} obj Input to be serialized into JSON. | |
* @param {boolean=} pretty If set to true, the JSON output will contain newlines and whitespace. | |
* @returns {string|undefined} JSON-ified string representing `obj`. | |
*/ | |
function toJson(obj, pretty) { | |
if (typeof obj === 'undefined') return undefined; | |
return JSON.stringify(obj, toJsonReplacer, pretty ? ' ' : null); | |
} |
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 getTimeStamp() { | |
var now = new Date(); | |
return ((now.getMonth() + 1) + '/' + | |
(now.getDate()) + '/' + | |
now.getFullYear() + " " + | |
now.getHours() + ':' + | |
((now.getMinutes() < 10) | |
? ("0" + now.getMinutes()) | |
: (now.getMinutes())) + ':' + | |
((now.getSeconds() < 10) |
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 toJson(obj) { | |
return JSON.stringify(obj, function(k,v) { return v; }, ' ') | |
} |
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 FN_ARGS = /^function\s*[^\(]*\(\s*([^\)]*)\)/m; | |
var FN_ARG_SPLIT = /,/; | |
var FN_ARG = /^\s*(_?)(\S+?)\1\s*$/; | |
var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg; | |
var $injectorMinErr = minErr('$injector'); | |
function annotate(fn) { | |
var $inject, | |
fnText, | |
argDecl, | |
last; |
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 debounce (delay, callback) { | |
var timeout = null; | |
return function (){ | |
if (timeout) { | |
clearTimeout(timeout); | |
} | |
var context = this; | |
var args = arguments; | |
timeout = setTimeout(function(){ | |
callback.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 throttle(delay, callback) { | |
var previousTime = new Date().getTime(); | |
return function() { | |
var newTime = new Date().getTime(); | |
if ((newTime - previousTime) > delay) { | |
previousTime = newTime; | |
callback.apply(null, arguments); | |
} | |
}; | |
} |