Skip to content
This repository has been archived by the owner on Mar 20, 2022. It is now read-only.

Commit

Permalink
Merge 3f45e13 into a20d535
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-ushakov committed Sep 28, 2017
2 parents a20d535 + 3f45e13 commit 490ff39
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ describe('denormalize', () => {
const user = new schema.Entity('users');
const comment = new schema.Entity('comments', {
user: user
}, {
idAttribute: (value, parent, key) => `${value.id}-${parent.id}-${key}`
});
const article = new schema.Entity('articles', {
author: user,
Expand Down
6 changes: 2 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,12 @@ export const normalize = (input, schema) => {
return { entities, result };
};

const unvisitEntity = (input, schema, unvisit, getEntity, cache) => {
const entity = getEntity(input, schema);
const unvisitEntity = (id, schema, unvisit, getEntity, cache) => {
const entity = getEntity(id, schema);
if (typeof entity !== 'object' || entity === null) {
return entity;
}

const id = schema.getId(entity);

if (!cache[schema.key]) {
cache[schema.key] = {};
}
Expand Down

0 comments on commit 490ff39

Please sign in to comment.