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 multiply(a, b, c) { | |
if (!multiply.cache) { | |
multiply.cache = {}; | |
} | |
var cachedArgs = JSON.stringify(arguments); | |
if (multiply.cache[cachedArgs]) { | |
return multiply.cache[cachedArgs]; | |
} | |
return multiply.cache[cachedArgs] = a * b * c; |
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 () { | |
var config = { | |
elem: document.querySelector('.moveable'), // absolute or relative positioned DOM node | |
states: [], | |
speed: 2, // pixel per frame | |
loop: true, | |
target: { | |
from: 0, | |
to: 500 | |
} |
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
String.prototype.startsWith = function (input) { | |
return this.substring(0, input.length) === input; | |
}; | |
String.prototype.relativeTo = function (input) { | |
var toTop = /..\//gi; | |
var abs = /^https?:\/\//i; | |
var inCurrent = './'; | |
var matches; |
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 isArray(arr) { | |
return Object.prototype.toString.call(arr) === '[object Array]'; | |
} | |
function arrToFlat(arr, arrToReturn) { | |
if (!isArray(arr)) { | |
return false; | |
} | |
if (!arrToReturn) { | |
arrToReturn = []; |