mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-04 00:57:48 +00:00
Ensure _.at and _.pullAt work with falsey array and collection values when keys are provided.
This commit is contained in:
@@ -3999,7 +3999,7 @@
|
||||
* // => [10, 20]
|
||||
*/
|
||||
function pullAt(array) {
|
||||
return basePullAt(array, baseFlatten(arguments, false, false, 1));
|
||||
return basePullAt(array || [], baseFlatten(arguments, false, false, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
24
test/test.js
24
test/test.js
@@ -953,6 +953,18 @@
|
||||
deepEqual(actual, ['d', 'a', 'c']);
|
||||
});
|
||||
|
||||
test('should work with a falsey `array` argument when keys are provided', 1, function() {
|
||||
var expected = _.map(falsey, _.constant([undefined, undefined]));
|
||||
|
||||
var actual = _.map(falsey, function(value) {
|
||||
try {
|
||||
return _.at(value, 0, 1);
|
||||
} catch(e) {}
|
||||
});
|
||||
|
||||
deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
test('should work with an `arguments` object for `collection`', 1, function() {
|
||||
var actual = _.at(args, [2, 0]);
|
||||
deepEqual(actual, ['c', 'a']);
|
||||
@@ -9184,6 +9196,18 @@
|
||||
deepEqual(actual, ['d', 'a', 'c']);
|
||||
});
|
||||
|
||||
test('should work with a falsey `array` argument when keys are provided', 1, function() {
|
||||
var expected = _.map(falsey, _.constant([undefined, undefined]));
|
||||
|
||||
var actual = _.map(falsey, function(value) {
|
||||
try {
|
||||
return _.pullAt(value, 0, 1);
|
||||
} catch(e) {}
|
||||
});
|
||||
|
||||
deepEqual(actual, expected);
|
||||
});
|
||||
|
||||
test('should ignore non-index values', 2, function() {
|
||||
var array = ['a', 'b', 'c'],
|
||||
clone = array.slice();
|
||||
|
||||
Reference in New Issue
Block a user