'use strict';

var _castPath = require('./_castPath.js');
var last = require('./last.js');
var _parent = require('./_parent.js');
var _toKey = require('./_toKey.js');

/**
 * The base implementation of `_.unset`.
 *
 * @private
 * @param {Object} object The object to modify.
 * @param {Array|string} path The property path to unset.
 * @returns {boolean} Returns `true` if the property is deleted, else `false`.
 */
function baseUnset(object, path) {
  path = _castPath(path, object);
  object = _parent(object, path);
  return object == null || delete object[_toKey(last(path))];
}

module.exports = baseUnset;
