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