summaryrefslogtreecommitdiff
path: root/src/store
diff options
context:
space:
mode:
Diffstat (limited to 'src/store')
-rw-r--r--src/store/denormalizer.js16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/store/denormalizer.js b/src/store/denormalizer.js
new file mode 100644
index 00000000..fbf15430
--- /dev/null
+++ b/src/store/denormalizer.js
@@ -0,0 +1,16 @@
+export function denormalize(state, objectType, id) {
+ const object = Object.assign({}, state.objects[objectType][id]);
+
+ for (let prop in object) {
+ if (!object.hasOwnProperty(prop)) {
+ continue;
+ }
+
+ if (prop.endsWith("Id")) {
+ const propType = prop.replace("Id", "");
+ object[propType] = state.objects[propType][object[prop]];
+ }
+ }
+
+ return object;
+}