Extract something from an object by the path

@author   Jelle De Loecker   <jelle@develry.be>
@since    0.1.0
@version  1.0.0

@param    {Object}    obj
@param    {String}    path

@return   {Mixed}
420429
function fromPath(obj, path) {

	var pieces,
	    here,
	    len,
	    i;

	if (typeof path == 'string') {
		pieces = path.split('.');
	} else {
		pieces = path;
	}

	here = obj;

	// Go over every piece in the path
	for (i = 0; i < pieces.length; i++) {
		if (here != null) {
			if (here.hasOwnProperty(pieces[i])) {
				here = here[pieces[i]];
			} else {
				return null;
			}
		} else {
			break;
		}
	}

	return here;
}
1354939
function walk(obj, path, initializeMissing = false) {
  let newObj = obj;

  if (path) {
    const ar = path.split('.');
    while (ar.length) {
      const k = ar.shift();
      if (initializeMissing && obj[k] == null) {
        newObj[k] = {};
        newObj = newObj[k];
      } else if (k in newObj) {
        newObj = newObj[k];
      } else {
        throw new Error(`cannot find configuration param '${path}'`);
      }
    }
  }

  return newObj;
}
988523
function format(path) {
  var obj = require(path);
  return function(req, res){
    res.format(obj);
  };
}
276112
function getProp(obj, key) {
    var path = [].concat(key);
    var val = obj;
    for (var _i = 0, path_1 = path; _i < path_1.length; _i++) {
        var pathKey = path_1[_i];
        if (val[pathKey] === undefined) {
            return undefined;
        }
        val = val[pathKey];
    }
    return val;
}
417529
function parent(object, path) {
    return path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1));
  }
392669
def object!(path)
      object = find_object path
      raise FileNotFoundError.new(path) if object.nil?
      object
    end
978507
function setFromPath(obj, path, value){
		var parts = path.split('.');
		
		for(var i = 0, l = parts.length; i < l; i++){
			if(i < (l - 1) && !obj.hasOwnProperty(parts[i]))
				obj[parts[i]] = {};
	
			if(i == l - 1)
				obj[parts[i]] = value;
			
			else
				obj = obj[parts[i]];
		}
		
		return obj;
	}
381711
function retrieve(obj, path) {
  if (!path) {
    return obj;
  }

  var arr = path.split(DELIMITER);
  var result = obj;
  for (var i = 0, l = arr.length; i < l; i++) {
    result = result[arr[i]];
  }
  return result;
}
601726
function makePath(object, path, index) {
		index = index || 0;
		var obj;

		if (path.length > index + 1) {
			obj = object[path[index]];

			// we always want the last object in an array
			if (_.isArray(obj)) obj = _.last(obj);

			makePath(obj, path, index + 1);
		} else {
			obj = object[path[index]];

			if (!obj) {
				// object doesn't exist yet so make it
				object[path[index]] = {};
			} else {
				if (!_.isArray(obj)) {
					// object isn't an array yet so make an array with the object as the first element
					object[path[index]] = [obj];
				}

				// append the new object
				object[path[index]].push({});
			}
		}
	}
778641
function getPath (obj, ks) {
      if (typeof ks == "string") ks = ks.split(".");

      // If we have reached an undefined property
      // then stop executing and return undefined
      if (obj === undefined) return void 0;

      // If the path array has no more elements, we've reached
      // the intended property and return its value
      if (ks.length === 0) return obj;

      // If we still have elements in the path array and the current
      // value is null, stop executing and return undefined
      if (obj === null) return void 0;

      return getPath(obj[_.first(ks)], _.rest(ks));
    }
440019
function setPath(obj, value, path) {
                var keys     = path.split('.');
                var ret      = obj;
                var lastKey  = keys[keys.length -1];
                var target   = ret;

                var parentPathKeys = keys.slice(0, keys.length -1);
                parentPathKeys.forEach(function(key) {
                    if (!target.hasOwnProperty(key)) {
                        target[key] = {};
                    }
                    target = target[key];
                });

                target[lastKey] = value;
                return ret;
            }
79778
function eraseFromPath(obj, path){
		var parts = path.split('.'),
			clone = obj;
		
		for(var i = 0, l = parts.length; i < l; i++){
			if (!obj.hasOwnProperty(parts[i])){
				break;
			
			} else if (i < l - 1){
				obj = obj[parts[i]];
				
			} else if(i == l - 1){
				delete obj[parts[i]];
				break;
			}
		}
		
		return clone;
	}
933344
function(path) {
      return path.lastIndexOf('.') != -1 ? 
        path.slice(path.lastIndexOf('.') + 1, path.length) :
          null
    }
169242
function deepValueGetter(obj, path) {
    if (obj == null)
        return '';
    if (!obj || !path)
        return obj;
    // check if path matches a root-level field
    // { "a.b.c": 123 }
    var current = obj[path];
    if (current !== undefined)
        return current;
    current = obj;
    var split = path.split('.');
    if (split.length) {
        for (var i = 0; i < split.length; i++) {
            current = current[split[i]];
            // if found undefined, return empty string
            if (current === undefined || current === null)
                return '';
        }
    }
    return current;
}
1359517
function baseGet(object, path) {
  path = _castPath(path, object);

  var index = 0,
      length = path.length;

  while (object != null && index < length) {
    object = object[_toKey(path[index++])];
  }
  return (index && index == length) ? object : undefined;
}
523480
private function getObjectRecursive($path)
    {
        $tree = $object = $this;
        foreach ($this->splitPath($path) as $part) {
            $object = $tree->getObject($part);
            if (!$object instanceof Tree) {
                return $object;
            }
            $tree = $object;
        }

        return $object;
    }
973070
public static Object getByPath(Object target, List<String> path) {
        Object obj = target;

        for (String field : path) {
            if (obj == null) {
                return null;
            }
            obj = evaluate(obj, trimType(field));
        }

        return obj;
    }