mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-12 03:47:50 +00:00
Simplify _.slice.
This commit is contained in:
10
lodash.js
10
lodash.js
@@ -3873,21 +3873,19 @@
|
|||||||
|
|
||||||
start = start == null ? 0 : (+start || 0);
|
start = start == null ? 0 : (+start || 0);
|
||||||
if (start < 0) {
|
if (start < 0) {
|
||||||
start = nativeMax(length + start, 0);
|
start = -start > length ? 0 : (length + start);
|
||||||
} else if (start > length) {
|
} else if (start > length) {
|
||||||
start = length;
|
start = length;
|
||||||
}
|
}
|
||||||
end = typeof end == 'undefined' ? length : (+end || 0);
|
end = (typeof end == 'undefined' || end > length) ? length : (+end || 0);
|
||||||
if (end < 0) {
|
if (end < 0) {
|
||||||
end = nativeMax(length + end, 0);
|
end += length;
|
||||||
} else if (end > length) {
|
|
||||||
end = length;
|
|
||||||
}
|
}
|
||||||
length = start > end ? 0 : (end - start);
|
length = start > end ? 0 : (end - start);
|
||||||
|
|
||||||
var result = Array(length);
|
var result = Array(length);
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
result[index] = array[start + index];
|
result[index] = array[index + start];
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user