mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 10:07:48 +00:00
Leverage _.indexOf's fromIndex in _.difference and _.without.
Former-commit-id: 0fd092d2ee109b99a50791899e7f2d690b3852af
This commit is contained in:
16
lodash.js
16
lodash.js
@@ -424,7 +424,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// set additional template data values
|
// set additional template `data` values
|
||||||
var args = data.args,
|
var args = data.args,
|
||||||
arrayBranch = data.arrayBranch,
|
arrayBranch = data.arrayBranch,
|
||||||
objectBranch = data.objectBranch,
|
objectBranch = data.objectBranch,
|
||||||
@@ -934,7 +934,7 @@
|
|||||||
if (!collection) {
|
if (!collection) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
if (toString.call(collection.toArray) == funcClass) {
|
if (collection.toArray && toString.call(collection.toArray) == funcClass) {
|
||||||
return collection.toArray();
|
return collection.toArray();
|
||||||
}
|
}
|
||||||
var length = collection.length;
|
var length = collection.length;
|
||||||
@@ -999,10 +999,10 @@
|
|||||||
}
|
}
|
||||||
var index = -1,
|
var index = -1,
|
||||||
length = array.length,
|
length = array.length,
|
||||||
flattened = concat.apply(result, slice.call(arguments, 1));
|
flattened = concat.apply(result, arguments);
|
||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
if (indexOf(flattened, array[index]) < 0) {
|
if (indexOf(flattened, array[index], length) < 0) {
|
||||||
result.push(array[index]);
|
result.push(array[index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1731,12 +1731,11 @@
|
|||||||
if (!array) {
|
if (!array) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
var excluded = slice.call(arguments, 1),
|
var index = -1,
|
||||||
index = -1,
|
|
||||||
length = array.length;
|
length = array.length;
|
||||||
|
|
||||||
while (++index < length) {
|
while (++index < length) {
|
||||||
if (indexOf(excluded, array[index]) < 0) {
|
if (indexOf(arguments, array[index], 1) < 0) {
|
||||||
result.push(array[index]);
|
result.push(array[index]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1911,8 +1910,7 @@
|
|||||||
*
|
*
|
||||||
* var buttonView = {
|
* var buttonView = {
|
||||||
* 'label': 'lodash',
|
* 'label': 'lodash',
|
||||||
* 'onClick': function() { alert('clicked: ' + this.label); },
|
* 'onClick': function() { alert('clicked: ' + this.label); }
|
||||||
* 'onHover': function() { console.log('hovering: ' + this.label); }
|
|
||||||
* };
|
* };
|
||||||
*
|
*
|
||||||
* _.bindAll(buttonView);
|
* _.bindAll(buttonView);
|
||||||
|
|||||||
@@ -312,10 +312,10 @@
|
|||||||
suites.push(
|
suites.push(
|
||||||
Benchmark.Suite('`_.difference`')
|
Benchmark.Suite('`_.difference`')
|
||||||
.add('Lo-Dash', function() {
|
.add('Lo-Dash', function() {
|
||||||
lodash.difference(numbers, fourNumbers);
|
lodash.difference(numbers, fourNumbers, twoNumbers);
|
||||||
})
|
})
|
||||||
.add('Underscore', function() {
|
.add('Underscore', function() {
|
||||||
_.difference(numbers, fourNumbers);
|
_.difference(numbers, fourNumbers, twoNumbers);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user