mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 01:47:48 +00:00
Optimize lazy slice for start of 0 and an end value.
This commit is contained in:
@@ -12342,8 +12342,13 @@
|
|||||||
|
|
||||||
LazyWrapper.prototype.slice = function(start, end) {
|
LazyWrapper.prototype.slice = function(start, end) {
|
||||||
start = start == null ? 0 : (+start || 0);
|
start = start == null ? 0 : (+start || 0);
|
||||||
var result = start < 0 ? this.takeRight(-start) : this.drop(start);
|
|
||||||
|
|
||||||
|
var result = this;
|
||||||
|
if (start < 0) {
|
||||||
|
result = this.takeRight(-start);
|
||||||
|
} else if (start) {
|
||||||
|
result = this.drop(start);
|
||||||
|
}
|
||||||
if (end !== undefined) {
|
if (end !== undefined) {
|
||||||
end = (+end || 0);
|
end = (+end || 0);
|
||||||
result = end < 0 ? result.dropRight(-end) : result.take(end - start);
|
result = end < 0 ? result.dropRight(-end) : result.take(end - start);
|
||||||
|
|||||||
Reference in New Issue
Block a user