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 findPropIn(propName, obj) { | |
if (obj == undefined || typeof obj != 'object') return; | |
if (propName in obj) { // 🗒️ If propName exists in the prototype chain | |
return obj[propName]; | |
} else { | |
for (let prop of Object.keys(obj)) { // 👈🏽 looping through the keys | |
let ret = findPropIn(propName, obj[prop]); | |
if (ret !== undefined) { | |
return ret; | |
} |
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
export default { | |
clamp (n, min, max) { | |
return Math.min(Math.max(n, min), max); | |
} | |
}; |
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
@mixin centerer($horizontal: true, $vertical: true, $offsetH: 0%, $offsetV: 0%) { | |
position: absolute; | |
@if ($horizontal and $vertical) { | |
top: 50% + $offsetV; | |
left: 50% + $offsetH; | |
transform: translate(-50%, -50%); | |
} @else if ($horizontal) { | |
left: 50% + $offsetH; | |
transform: translate(-50%, 0); | |
} @else if ($vertical) { |
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 : descBy(one of the property name of objects present in an array) | |
* Usage : arrayHoldingNames.sort(by(firstName)); | |
* ---------------------------------------------------------------------- | |
* Used to sort any array of objects in descending order by a property name | |
* of the obejcts inside that array. | |
*/ | |
function descBy(propertyName) { | |
return function(m, n) { | |
if(typeof m === 'object' && typeof n === 'object') { |
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 ($) { | |
var o = $( {} ); // to return an instance of jquery that is to pass an empty object literal to jQuery to get a new | |
$.each({ | |
trigger : 'publish', | |
on : 'subscribe', | |
off : 'unsubscribe' | |
}, function(key, val) { | |
jQuery[val] = function() { | |
o[key].apply(o, 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 debounce(fn, duration) { | |
var timeout; | |
return function() { | |
clearTimeout(timeout); | |
timeout = setTimeout(fn, duration); | |
}; | |
} |