client/src/utils.js
function expandKeys(object) {
  var hasFlattenedKeys = _.some(object, function(val, key) {
    return key.split('.').length > 1;
  });
  if (!hasFlattenedKeys) return object;

  return _.reduce(object, function(payload, value, key) {
    var path = key.split('.');
    if (path.length === 1) {
      var obj = {};
      obj[key] = value;
      payload = deepExtend(payload, obj);
      return payload;
    }
    var subKey = path.pop();
    var localObj = payload;
    while (path.length) {
      var subPath = path.shift();
      localObj = localObj[subPath] = localObj[subPath] || {};
    }
    localObj[subKey] = object[key];
    return payload;
  }, {});
}
function expandKeys(object) {
  var hasFlattenedKeys = _.some(object, function(val, key) {
    return key.split('.').length > 1;
  });
  if (!hasFlattenedKeys) return object;

  return _.reduce(object, function(payload, value, key) {
    var path = key.split('.');
    if (path.length === 1) {
      var obj = {};
      obj[key] = value;
      payload = deepExtend(payload, obj);
      return payload;
    }
    var subKey = path.pop();
    var localObj = payload;
    while (path.length) {
      var subPath = path.shift();
      localObj = localObj[subPath] = localObj[subPath] || {};
    }
    localObj[subKey] = object[key];
    return payload;
  }, {});
}
function expandKeys ( object ) { var hasFlattenedKeys = _ . some ( object , function ( val , key ) { return key . split ( '.' ) . length > 1 ; } ) ; if ( ! hasFlattenedKeys ) return object ; return _ . reduce ( object , function ( payload , value , key ) { var path = key . split ( '.' ) ; if ( path . length === 1 ) { var obj = { } ; obj [ key ] = value ; payload = deepExtend ( payload , obj ) ; return payload ; } var subKey = path . pop ( ) ; var localObj = payload ; while ( path . length ) { var subPath = path . shift ( ) ; localObj = localObj [ subPath ] = localObj [ subPath ] || { } ; } localObj [ subKey ] = object [ key ] ; return payload ; } , { } ) ; }
Expands any keys with dot notation in an object.
Returns the original object if there aren't any flattened keys to begin with.

@param  {Object} object
@return {Object} object with keys as nested objects
Expands any keys with dot notation in an object . Returns the original object if there aren t any flattened keys to begin with .