Files
habitica/website/client/libs/store/helpers/internals.js
Matteo Pagliazzi d9d7c69432 Client: async resources, make store reusable, move plugins and add getTaskFor getter (#8575)
Add library to manage async resource
Make Store reusable for easier testing
Move plugin to libs
Add getTaskFor getter with tests
2017-03-18 18:33:08 +01:00

32 lines
556 B
JavaScript

/* Flatten multiple objects into a single, namespaced object.
Example:
getters
user
gems
tasks
...
tasks
todos
dailys
...
Result:
getters
user:gems
user:tasks
tasks:todos
tasks:dailys
*/
export function flattenAndNamespace (namespaces) {
let result = {};
Object.keys(namespaces).forEach(namespace => {
Object.keys(namespaces[namespace]).forEach(itemName => {
result[`${namespace}:${itemName}`] = namespaces[namespace][itemName];
});
});
return result;
}