feat(massageConfiguration): Add data-transformation function

The meta-configuration structure imposes we change the way `react-hijack` parses and pulls its data. Because that work is both error-prone and also time-consuming, we chose to implement a function that would "massage" the data so it fits the current way react-hijack expects it.
This commit is contained in:
Adrian Oprea 2018-01-16 17:23:15 +02:00
parent a5ecc1a36e
commit d7b63f5941

View file

@ -0,0 +1,21 @@
const massageConfiguration = (config, identifier) => {
const result = {
[identifier]: {}
};
Object.keys(config)
.forEach(
addon => Object.keys(config[addon])
.forEach(
component => {
if (config[addon][component].areas.indexOf(identifier) !== -1) {
result[identifier][component] = config[addon][component];
}
}
)
);
return result;
};
export default massageConfiguration;