Ensure _.slice coerces start and end arguments appropriately.

This commit is contained in:
John-David Dalton
2014-03-12 09:11:29 -07:00
parent a4c15e5fa5
commit 3ca80a7bf3
2 changed files with 12 additions and 11 deletions

View File

@@ -2975,21 +2975,19 @@
var index = -1,
length = array ? array.length : 0;
if (typeof start == 'undefined') {
start = 0;
} else if (start < 0) {
start |= 0;
if (start < 0) {
start = nativeMax(length + start, 0);
} else if (start > length) {
start = length;
}
if (typeof end == 'undefined') {
end = length;
} else if (end < 0) {
end = typeof end == 'undefined' ? length : (end | 0);
if (end < 0) {
end = nativeMax(length + end, 0);
} else if (end > length) {
end = length;
}
length = (length = (end - start) | 0) < 0 ? 0 : length;
length = start > end ? 0 : (end - start);
var result = Array(length);
while (++index < length) {