mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 07:47:49 +00:00
Simplify baseUnset.
This commit is contained in:
13
lodash.js
13
lodash.js
@@ -3881,14 +3881,8 @@
|
||||
var previous = index;
|
||||
if (isIndex(index)) {
|
||||
splice.call(array, index, 1);
|
||||
}
|
||||
else {
|
||||
var path = castPath(index, array),
|
||||
object = parent(array, path);
|
||||
|
||||
if (object != null) {
|
||||
delete object[toKey(last(path))];
|
||||
}
|
||||
} else {
|
||||
baseUnset(array, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4352,8 +4346,7 @@
|
||||
function baseUnset(object, path) {
|
||||
path = castPath(path, object);
|
||||
object = parent(object, path);
|
||||
var key = toKey(last(path));
|
||||
return !(object != null && hasOwnProperty.call(object, key)) || delete object[key];
|
||||
return object == null || delete object[toKey(last(path))];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user