mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 11:27:50 +00:00
Ensure _.pullAt sorts indexes greater than 9 correctly. [closes #2254]
This commit is contained in:
@@ -3461,7 +3461,7 @@
|
|||||||
|
|
||||||
while (length--) {
|
while (length--) {
|
||||||
var index = indexes[length];
|
var index = indexes[length];
|
||||||
if (lastIndex == length || index != previous) {
|
if (length == lastIndex || index !== previous) {
|
||||||
var previous = index;
|
var previous = index;
|
||||||
if (isIndex(index)) {
|
if (isIndex(index)) {
|
||||||
splice.call(array, index, 1);
|
splice.call(array, index, 1);
|
||||||
@@ -6837,7 +6837,7 @@
|
|||||||
* // => [10, 20]
|
* // => [10, 20]
|
||||||
*/
|
*/
|
||||||
var pullAt = rest(function(array, indexes) {
|
var pullAt = rest(function(array, indexes) {
|
||||||
indexes = arrayMap(baseFlatten(indexes, 1), String);
|
indexes = baseFlatten(indexes, 1);
|
||||||
|
|
||||||
var result = baseAt(array, indexes);
|
var result = baseAt(array, indexes);
|
||||||
basePullAt(array, indexes.sort(compareAscending));
|
basePullAt(array, indexes.sort(compareAscending));
|
||||||
|
|||||||
@@ -17717,11 +17717,11 @@
|
|||||||
QUnit.test('should work with unsorted indexes', function(assert) {
|
QUnit.test('should work with unsorted indexes', function(assert) {
|
||||||
assert.expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
var array = [1, 2, 3, 4],
|
var array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
|
||||||
actual = _.pullAt(array, [1, 3, 0]);
|
actual = _.pullAt(array, [1, 3, 11, 7, 5, 9]);
|
||||||
|
|
||||||
assert.deepEqual(array, [3]);
|
assert.deepEqual(array, [1, 3, 5, 7, 9, 11]);
|
||||||
assert.deepEqual(actual, [2, 4, 1]);
|
assert.deepEqual(actual, [2, 4, 12, 8, 6, 10]);
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test('should work with repeated indexes', function(assert) {
|
QUnit.test('should work with repeated indexes', function(assert) {
|
||||||
|
|||||||
Reference in New Issue
Block a user