function set (object, path, value) {
  if (typeof path === 'string') {
    if (isPath(path)) {
      return set(object, path.split('.'), value)
    } else {
      object[path] = value
      return object
    }
  }

  let child = object
  for (let i = 0; i < path.length - 1; i++) {
    const key = path[i]
    if (child[key] === undefined) {
      child[key] = {}
    }
    child = child[key]
  }

  if (path.length > 0) {
    const lastKey = path[path.length - 1]
    child[lastKey] = value
  }

  return object
}
Set a nested property in an object
Mutates the object itself
If the path doesn't exist, it will be created
@param {Object} object
@param {string | string[]} path
@param {*} value
@returns {Object}