Skip to content

Instantly share code, notes, and snippets.

@IgorMing
Created November 27, 2017 15:20
Show Gist options
  • Save IgorMing/f6f2f32913318f6b08a36bacd16b2ba5 to your computer and use it in GitHub Desktop.
Save IgorMing/f6f2f32913318f6b08a36bacd16b2ba5 to your computer and use it in GitHub Desktop.
Simple normalizer
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