mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 02:47:50 +00:00
Reduce _.intersection and _.where.
Former-commit-id: b8d87f72c72c0f42e693eff67296135f0a5c548b
This commit is contained in:
25
build.js
25
build.js
@@ -93,7 +93,7 @@
|
||||
'identity': [],
|
||||
'indexOf': ['sortedIndex'],
|
||||
'initial': [],
|
||||
'intersection': ['indexOf'],
|
||||
'intersection': ['filter', 'indexOf'],
|
||||
'invert': ['forOwn'],
|
||||
'invoke': ['forEach'],
|
||||
'isArguments': [],
|
||||
@@ -154,7 +154,7 @@
|
||||
'uniqueId': [],
|
||||
'value': ['mixin'],
|
||||
'values': ['forOwn'],
|
||||
'where': ['forEach', 'forIn'],
|
||||
'where': ['filter', 'forIn'],
|
||||
'without': ['indexOf'],
|
||||
'wrap': [],
|
||||
'zip': ['max', 'pluck']
|
||||
@@ -1092,23 +1092,20 @@
|
||||
// replace `_.intersection`
|
||||
source = source.replace(/^( +)function intersection[\s\S]+?\n\1}/m, [
|
||||
' function intersection(array) {',
|
||||
' var argsLength = arguments.length,',
|
||||
' index = -1,',
|
||||
' length = array.length,',
|
||||
' result = [];',
|
||||
' var args = argument,',
|
||||
' argsLength = args.length;',
|
||||
'',
|
||||
' array: while (++index < length) {',
|
||||
' var value = array[index]',
|
||||
' return filter(array, function(value) {',
|
||||
' if (indexOf(result, value) < 0) {',
|
||||
' for (var argsIndex = 1; argsIndex < argsLength; argsIndex++) {',
|
||||
' if (indexOf(arguments[argsIndex], value) < 0) {',
|
||||
' continue array;',
|
||||
' var length = argsLength;',
|
||||
' while (--length) {',
|
||||
' if (indexOf(args[length], value) < 0) {',
|
||||
' return false;',
|
||||
' }',
|
||||
' }',
|
||||
' result.push(value);',
|
||||
' return true;',
|
||||
' }',
|
||||
' }',
|
||||
' return result',
|
||||
' });',
|
||||
' }'
|
||||
].join('\n'));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user