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 isEqual(obj1, obj2, customizer = {}) { | |
| const keys1 = Object.keys(obj1); | |
| const keys2 = Object.keys(obj2); | |
| if (keys1.length !== keys2.length) return false; | |
| return keys1.every(key => { | |
| const item1 = obj1[key]; | |
| const item2 = obj2[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
| function capitalize (str) { | |
| return str.replace(/(\w)\w+/g, (match, g1) => `${g1.toUpperCase()}${match.substring(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
| /** | |
| * getLastWord - Splits the given string in | |
| * its last word and pass the result into the callback | |
| * | |
| * @param {String} str | |
| * @param {Function} callback - Takes as arguments the first part of the text (without the last word) and the last word. | |
| */ | |
| export function getLastWord(str, callback) { | |
| if (typeof str !== 'string') str = ''; |
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 generateHex() { | |
| const min = 1118481; // parseInt('111111', 16) | |
| const max = 16777215; // parseInt('FFFFFF', 16) | |
| const randomColor = Math.floor(Math.random() * (max - min + 1)) + min; | |
| return `#${randomColor.toString(16)}`; | |
| } |
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 removeExtension (path) { | |
| return path.split(/\.(\w{3}|(\w{4}))$/, 1)[0] | |
| } |
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
| (current + length + direction) % length | |
| (current + direction) % length |
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 createLoop (callback, delay, duration, animationEnd) { | |
| let start = null; | |
| let last = null; | |
| let endAnimation = null; | |
| function loop (timestamp) { | |
| if (!start) { | |
| start = timestamp; | |
| last = timestamp; | |
| }; |
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 hexToRgbA(hex, opacity){ | |
| var c; | |
| if(/^#([A-Fa-f0-9]{3}){1,2}$/.test(hex)){ | |
| c= hex.substring(1).split(''); | |
| if(c.length== 3){ | |
| c= [c[0], c[0], c[1], c[1], c[2], c[2]]; | |
| } | |
| c= '0x'+c.join(''); | |
| return 'rgba('+[(c>>16)&255, (c>>8)&255, c&255].join(',')+','+opacity+')'; | |
| } |
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 getPath (path, obj = {}) { | |
| const [head , ...tail] = Array.isArray(path) ? path : path.split(/\./g) | |
| const value = obj[head] | |
| if (tail.length === 0 || value === undefined) { | |
| return value | |
| } | |
| return getPath(tail, obj[head]) | |
| } |
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
| ^(ftp|https?):\/\/([^\s]+)\.([^\s|^\.]+)$ |