mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-01 23:57:49 +00:00
Ensure lazy slice handles floating-point start and end params.
This commit is contained in:
@@ -11037,7 +11037,7 @@
|
||||
whileName = methodName + 'While';
|
||||
|
||||
LazyWrapper.prototype[methodName] = function(n) {
|
||||
n = n == null ? 1 : nativeMax(+n || 0, 0);
|
||||
n = n == null ? 1 : nativeMax(floor(n) || 0, 0);
|
||||
|
||||
var result = this.clone();
|
||||
if (result.__filtered__) {
|
||||
|
||||
11
test/test.js
11
test/test.js
@@ -12044,7 +12044,7 @@
|
||||
notStrictEqual(actual, array);
|
||||
});
|
||||
|
||||
test('should work in a lazy chain sequence', 12, function() {
|
||||
test('should work in a lazy chain sequence', 18, function() {
|
||||
if (!isNpm) {
|
||||
var wrapped = _(array);
|
||||
|
||||
@@ -12063,9 +12063,16 @@
|
||||
|
||||
deepEqual(wrapped.slice(0, 1).value(), [1]);
|
||||
deepEqual(wrapped.slice(NaN, '1').value(), [1]);
|
||||
|
||||
deepEqual(wrapped.slice(0.1, 1.1).value(), [1]);
|
||||
deepEqual(wrapped.slice('0', 1).value(), [1]);
|
||||
deepEqual(wrapped.slice(0, '1').value(), [1]);
|
||||
deepEqual(wrapped.slice('1').value(), [2, 3]);
|
||||
deepEqual(wrapped.slice(NaN, 1).value(), [1]);
|
||||
deepEqual(wrapped.slice(1, NaN).value(), []);
|
||||
}
|
||||
else {
|
||||
skipTest(12);
|
||||
skipTest(18);
|
||||
}
|
||||
});
|
||||
}());
|
||||
|
||||
Reference in New Issue
Block a user