UNPKG

578 BJavaScriptView Raw
1import castPath from './_castPath.js';
2import last from './last.js';
3import parent from './_parent.js';
4import toKey from './_toKey.js';
5
6/**
7 * The base implementation of `_.unset`.
8 *
9 * @private
10 * @param {Object} object The object to modify.
11 * @param {Array|string} path The property path to unset.
12 * @returns {boolean} Returns `true` if the property is deleted, else `false`.
13 */
14function baseUnset(object, path) {
15 path = castPath(path, object);
16 object = parent(object, path);
17 return object == null || delete object[toKey(last(path))];
18}
19
20export default baseUnset;