src/index.js
function denormalizeEntity(entityOrId, entities, schema, bag) {
  const key = schema.key;
  const { entity, id } = resolveEntityOrId(entityOrId, entities, schema);

  if (!bag.hasOwnProperty(key)) {
    bag[key] = {};
  }

  if (!bag[key].hasOwnProperty(id)) {
    // Ensure we don't mutate it non-immutable objects
    const obj = isImmutable(entity) ? entity : merge({}, entity);

    // Need to set this first so that if it is referenced within the call to
    // denormalizeObject, it will already exist.
    bag[key][id] = obj;
    bag[key][id] = denormalizeObject(obj, entities, schema, bag);
  }

  return bag[key][id];
}
function denormalizeEntity(entityOrId, entities, schema, bag) {
  const key = schema.key;
  const { entity, id } = resolveEntityOrId(entityOrId, entities, schema);

  if (!bag.hasOwnProperty(key)) {
    bag[key] = {};
  }

  if (!bag[key].hasOwnProperty(id)) {
    // Ensure we don't mutate it non-immutable objects
    const obj = isImmutable(entity) ? entity : merge({}, entity);

    // Need to set this first so that if it is referenced within the call to
    // denormalizeObject, it will already exist.
    bag[key][id] = obj;
    bag[key][id] = denormalizeObject(obj, entities, schema, bag);
  }

  return bag[key][id];
}
function denormalizeEntity ( entityOrId , entities , schema , bag ) { const key = schema . key ; const { entity , id } = resolveEntityOrId ( entityOrId , entities , schema ) ; if ( ! bag . hasOwnProperty ( key ) ) { bag [ key ] = { } ; } if ( ! bag [ key ] . hasOwnProperty ( id ) ) { // Ensure we don't mutate it non-immutable objects const obj = isImmutable ( entity ) ? entity : merge ( { } , entity ) ; // Need to set this first so that if it is referenced within the call to // denormalizeObject, it will already exist. bag [ key ] [ id ] = obj ; bag [ key ] [ id ] = denormalizeObject ( obj , entities , schema , bag ) ; } return bag [ key ] [ id ] ; }
Takes an entity, saves a reference to it in the 'bag' and then denormalizes
it. Saving the reference is necessary for circular dependencies.

@param   {object|Immutable.Map|number|string} entityOrId
@param   {object|Immutable.Map} entities
@param   {schema.Entity} schema
@param   {object} bag
@returns {object|Immutable.Map}
Takes an entity saves a reference to it in the bag and then denormalizes it . Saving the reference is necessary for circular dependencies .