Skip to content

Instantly share code, notes, and snippets.

Created November 1, 2016 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/32b4891ec154df47fa1313b5d8dc65d9 to your computer and use it in GitHub Desktop.
Save anonymous/32b4891ec154df47fa1313b5d8dc65d9 to your computer and use it in GitHub Desktop.
const segments = (state = {}, action) => {
switch (action.type) {
case actions.LOAD_SEGMENTS:
return {
...state,
segments: action.segments
.map(segments => segments.values_)
.reduce((result, item) => {
return {
...result,
[item.highway]: {
...result[item.highway],
[item.district]: {
...(result[item.highway] ? result[item.highway][item.district] : {}),
[item.segment]: item,
}
},
}
}, {}),
}
default:
return state;
}
};
@k4p7
Copy link

k4p7 commented Nov 1, 2016

I am going to jail for this code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment