Last active
May 10, 2024 00:34
-
-
Save veteran29/5d50c975c8f6d0df9208dad68de3deb4 to your computer and use it in GitHub Desktop.
ES2015 Snippets
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
const createRange = (start, amount) => | |
Array.from(Array(amount), (_, idx) => start + idx); | |
/** | |
* @param {array} array | |
*/ | |
const uniqueArray = array => [...new Set(array)]; | |
/** | |
* @param {array} array | |
* @param {string} key Should not repeat in array or only last one will be in resulting object | |
*/ | |
const arrayToObject = (array, groupKey) => | |
Object.assign({}, ...array.map(item => ({ [item[groupKey]]: item }))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment