I have this data scenario:
var data = [
{
'name': 'social-button',
'group': null
}, {
'name': 'social-button',
'group': null
}, {
'name': 'social-button',
'group': 'buttons'
}, {
'name': 'social-button',
'group': null
}, {
'name': 'icon',
'group': 'icons'
}, {
'name': 'other',
'group': null
}, {
'name': 'icon',
'group': null
}
];
I would like to normalize this data to this:
var data = [
{
'name': 'social-button',
'group': 'buttons'
}, {
'name': 'social-button',
'group': 'buttons'
}, {
'name': 'social-button',
'group': 'buttons'
}, {
'name': 'social-button',
'group': 'buttons'
}, {
'name': 'icon',
'group': 'icons'
}, {
'name': 'other',
'group': null
}, {
'name': 'icon',
'group': 'icons'
}
];
So basically, I would like to ensure every element which have the same name should also have the same group, if just one of the same have one.
Does exists some node module could help in this?
Or maybe, does exist some smart way to do that?