You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
carbon/lib/util.js

11 lines
214 B
JavaScript

7 years ago
export const toHash = (array) => {
return array.reduce((hash, item) => {
const id = item.id
if (hash[id]) {
throw new Error('ID already exists')
}
hash[id] = item
return hash
}, {})
}