This file contains hidden or 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
/** | |
* Succesively filter an array until the minimum result set is found | |
* @param {array} array - Array to be filtered | |
* @param {function...} fn1..fnN - Any number of filter functions | |
* @returns {array} The smallest non-empty array given the set of filters | |
*/ | |
function successiveFilter(array /* ... */) { | |
var prevArray, | |
fnArray = Array.prototype.slice.call(arguments, 1); |
This file contains hidden or 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
define( | |
'EntityToUnicode', | |
function() { | |
var el = document.createElement('p'); | |
/** | |
* HTML Entities to unicode text | |
* @param {string} str - String which contains HTML entities to decode | |
* @returns {string} A string of the equivalent unicode text | |
*/ |
This file contains hidden or 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
define( | |
'dateFormat', | |
function() { | |
var DAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Firday', 'Saturday'], | |
MONTHS = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], | |
MONTHS_ABBREV = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'], | |
datePrototype = Date.prototype, | |
formatCharacters = { | |
// DAY | |
// Numeric representation (with leading zero) |
This file contains hidden or 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
define( | |
'Eventable', | |
function() { | |
function extend(dest, src) { | |
for (var key in src) { | |
if (src.hasOwnProperty(key)) { | |
dest[key] = src[key]; | |
} | |
} |
This file contains hidden or 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
define( | |
'Heap', | |
function() { | |
function Heap(array, fn) { | |
var instance = Object.create(Heap.prototype); | |
instance._sortFn = typeof fn === 'function' ? fn : Heap.defaultSort; | |
instance._store = Array.isArray(array) ? array : []; | |
Heap.heapify(instance._store, instance._sortFn); |
This file contains hidden or 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
define( | |
'console', | |
function() { | |
var QUEUED_API = [ | |
'count', | |
'dir', | |
'error', | |
'group', | |
'groupCollapsed', | |
'groupEnd', |
This file contains hidden or 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 select(selector) { | |
var elements = [document], | |
queryStart = 0, | |
callQueue = [], | |
temp, | |
i; | |
for (i = 0; i < selector.length; i++) { | |
switch (selector[i]) { | |
case '#': |
This file contains hidden or 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
/** | |
* Creates a string using indexed format string | |
* @param {string} Format of string | |
* @param {...string} One or more strings to be using in the format | |
*/ | |
function formatString(/* ... */) { | |
var args = Array.apply(0, arguments); | |
return args.shift().replace(/\{(\d+)\}/g, function(match, index) { | |
return index < args.length | |
? args[index] |
This file contains hidden or 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
/** | |
* Calculate the annual contributions required to reach a desired future value. | |
* @param {number} P - Current principle value. | |
* @param {number} FV - Desired future value. | |
* @param {number} r - Rate of return. | |
* @param {number} Y - Years of growth. | |
* @returns {number} Annual contribution. | |
*/ | |
function annualContributions(P, FV, r, Y) { | |
var z = 1 + r; |
This file contains hidden or 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
/** | |
* Factory to take some of the boilerplate out of creating constructors | |
* which instantiate objects even without the new keyword. | |
* @param {function} fn - Input function to create constructor from. | |
* @returns The updated constructor. | |
*/ | |
function constructorFactory(fn) { | |
if (typeof fn !== 'function') { | |
throw new TypeError('Expected function!'); | |
} |
NewerOlder