Created
November 27, 2017 15:20
-
-
Save IgorMing/f6f2f32913318f6b08a36bacd16b2ba5 to your computer and use it in GitHub Desktop.
Simple normalizer
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 normalize(array, key) { | |
return array.reduce((acc, curr) => { | |
acc.all[curr[key]] = curr; | |
acc.ids.push(curr[key]); | |
return { ...acc }; | |
}, { all: {}, ids: [] }); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment