c50286b5cfe23eecd0aa3f40508c3ea20129efc6
[yaffs-website] / node_modules / uncss / node_modules / lodash / internal / baseUnset.js
1 var baseToPath = require('./baseToPath'),
2     has = require('../has'),
3     isKey = require('./isKey'),
4     last = require('../last'),
5     parent = require('./parent');
6
7 /**
8  * The base implementation of `_.unset`.
9  *
10  * @private
11  * @param {Object} object The object to modify.
12  * @param {Array|string} path The path of the property to unset.
13  * @returns {boolean} Returns `true` if the property is deleted, else `false`.
14  */
15 function baseUnset(object, path) {
16   path = isKey(path, object) ? [path + ''] : baseToPath(path);
17   object = parent(object, path);
18   var key = last(path);
19   return (object != null && has(object, key)) ? delete object[key] : true;
20 }
21
22 module.exports = baseUnset;