mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 00:57:48 +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);
|
||||
if (start < 0) {
|
||||
start = nativeMax(length + start, 0);
|
||||
start = -start > length ? 0 : (length + start);
|
||||
} else if (start > length) {
|
||||
start = length;
|
||||
}
|
||||
end = typeof end == 'undefined' ? length : (+end || 0);
|
||||
end = (typeof end == 'undefined' || end > length) ? length : (+end || 0);
|
||||
if (end < 0) {
|
||||
end = nativeMax(length + end, 0);
|
||||
} else if (end > length) {
|
||||
end = length;
|
||||
end += length;
|
||||
}
|
||||
length = start > end ? 0 : (end - start);
|
||||
|
||||
var result = Array(length);
|
||||
while (++index < length) {
|
||||
result[index] = array[start + index];
|
||||
result[index] = array[index + start];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user