Ensure _.pullAt sorts indexes greater than 9 correctly. [closes #2254]

This commit is contained in:
John-David Dalton
2016-04-14 16:17:32 -07:00
parent f6c14ec31f
commit 1a1e0e1a6b
2 changed files with 6 additions and 6 deletions

View File

@@ -3461,7 +3461,7 @@
while (length--) {
var index = indexes[length];
if (lastIndex == length || index != previous) {
if (length == lastIndex || index !== previous) {
var previous = index;
if (isIndex(index)) {
splice.call(array, index, 1);
@@ -6837,7 +6837,7 @@
* // => [10, 20]
*/
var pullAt = rest(function(array, indexes) {
indexes = arrayMap(baseFlatten(indexes, 1), String);
indexes = baseFlatten(indexes, 1);
var result = baseAt(array, indexes);
basePullAt(array, indexes.sort(compareAscending));

View File

@@ -17717,11 +17717,11 @@
QUnit.test('should work with unsorted indexes', function(assert) {
assert.expect(2);
var array = [1, 2, 3, 4],
actual = _.pullAt(array, [1, 3, 0]);
var array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
actual = _.pullAt(array, [1, 3, 11, 7, 5, 9]);
assert.deepEqual(array, [3]);
assert.deepEqual(actual, [2, 4, 1]);
assert.deepEqual(array, [1, 3, 5, 7, 9, 11]);
assert.deepEqual(actual, [2, 4, 12, 8, 6, 10]);
});
QUnit.test('should work with repeated indexes', function(assert) {