1 | var castPath = require('./_castPath'),
|
2 | isKey = require('./_isKey'),
|
3 | last = require('./last'),
|
4 | parent = require('./_parent'),
|
5 | toKey = require('./_toKey');
|
6 |
|
7 |
|
8 | var objectProto = Object.prototype;
|
9 |
|
10 |
|
11 | var hasOwnProperty = objectProto.hasOwnProperty;
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 | function baseUnset(object, path) {
|
22 | path = isKey(path, object) ? [path] : castPath(path);
|
23 | object = parent(object, path);
|
24 |
|
25 | var key = toKey(last(path));
|
26 | return !(object != null && hasOwnProperty.call(object, key)) || delete object[key];
|
27 | }
|
28 |
|
29 | module.exports = baseUnset;
|