Add fromIndex to _.contains.

Former-commit-id: 9f61db3ceda2d87ddfbfd4cffb2bd1f9732cc79a
This commit is contained in:
John-David Dalton
2012-11-04 11:24:29 -08:00
parent 1d3488fa8e
commit 218e3b66f2
5 changed files with 67 additions and 23 deletions

View File

@@ -1060,6 +1060,16 @@
].join('\n'));
}
// replace `_.contains`
source = source.replace(/^( +)function contains[\s\S]+?\n\1}/m, [
' function contains(collection, target) {',
' var length = collection ? collection.length : 0;',
" return typeof length == 'number'",
' ? indexOf(collection, target) > -1',
' : some(collection, function(value) { return value === target; });',
' }'
].join('\n'));
// replace `_.difference`
source = source.replace(/^( +)function difference[\s\S]+?\n\1}/m, [
' function difference(array) {',
@@ -1198,9 +1208,6 @@
' }'
].join('\n'));
// remove string support from `_.contains`
source = source.replace(/return *\(toString\.call.+?stringClass[\s\S]+?;/, 'return indexOf(collection, target) > -1;');
// remove `arguments` object check from `_.isEqual`
source = source.replace(/ *\|\| *className *== *argsClass/, '');
@@ -1382,7 +1389,7 @@
'',
' var index = 0,',
' source = "__p += \'",',
" variable = options.variable;",
' variable = options.variable;',
'',
' var reDelimiters = RegExp(',
" (options.escape || reNoMatch).source + '|' +",