mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 17:47:49 +00:00
Disable use of basicIndexOf optimization if _.indexOf is customized.
Former-commit-id: 5b2273b36934581e34c6f6042de95bf556c61ca2
This commit is contained in:
34
build.js
34
build.js
@@ -88,14 +88,14 @@
|
||||
'cloneDeep': ['clone'],
|
||||
'compact': [],
|
||||
'compose': [],
|
||||
'contains': ['basicEach', 'basicIndexOf', 'isString'],
|
||||
'contains': ['basicEach', 'getIndexOf', 'isString'],
|
||||
'countBy': ['createCallback', 'forEach'],
|
||||
'createCallback': ['identity', 'isEqual', 'keys'],
|
||||
'debounce': ['isObject'],
|
||||
'defaults': ['createIterator', 'isArguments', 'keys'],
|
||||
'defer': ['bind'],
|
||||
'delay': [],
|
||||
'difference': ['basicIndexOf', 'createCache'],
|
||||
'difference': ['createCache'],
|
||||
'escape': ['escapeHtmlChar'],
|
||||
'every': ['basicEach', 'createCallback', 'isArray'],
|
||||
'filter': ['basicEach', 'createCallback', 'isArray'],
|
||||
@@ -113,7 +113,7 @@
|
||||
'identity': [],
|
||||
'indexOf': ['basicIndexOf', 'sortedIndex'],
|
||||
'initial': ['slice'],
|
||||
'intersection': ['basicIndexOf', 'createCache'],
|
||||
'intersection': ['createCache'],
|
||||
'invert': ['keys'],
|
||||
'invoke': ['forEach'],
|
||||
'isArguments': [],
|
||||
@@ -143,7 +143,7 @@
|
||||
'min': ['basicEach', 'charAtCallback', 'createCallback', 'isArray', 'isString'],
|
||||
'mixin': ['forEach', 'functions'],
|
||||
'noConflict': [],
|
||||
'omit': ['basicIndexOf', 'forIn'],
|
||||
'omit': ['forIn', 'getIndexOf'],
|
||||
'once': [],
|
||||
'pairs': ['keys'],
|
||||
'parseInt': ['isString'],
|
||||
@@ -172,7 +172,7 @@
|
||||
'transform': ['createCallback', 'createObject', 'forOwn', 'isArray'],
|
||||
'unescape': ['unescapeHtmlChar'],
|
||||
'union': ['isArray', 'uniq'],
|
||||
'uniq': ['basicIndexOf', 'createCache', 'overloadWrapper'],
|
||||
'uniq': ['createCache', 'getIndexOf', 'overloadWrapper'],
|
||||
'uniqueId': [],
|
||||
'unzip': ['max', 'pluck'],
|
||||
'value': ['basicEach', 'forOwn', 'isArray', 'lodashWrapper'],
|
||||
@@ -189,11 +189,12 @@
|
||||
'charAtCallback': [],
|
||||
'compareAscending': [],
|
||||
'createBound': ['createObject', 'isFunction', 'isObject'],
|
||||
'createCache': ['basicIndexOf'],
|
||||
'createCache': ['basicIndexOf', 'getIndexOf'],
|
||||
'createIterator': ['iteratorTemplate'],
|
||||
'createObject': [ 'isObject', 'noop'],
|
||||
'escapeHtmlChar': [],
|
||||
'escapeStringChar': [],
|
||||
'getIndexOf': ['basicIndexOf', 'indexOf'],
|
||||
'iteratorTemplate': [],
|
||||
'isNode': [],
|
||||
'lodashWrapper': [],
|
||||
@@ -2277,10 +2278,11 @@
|
||||
if (!useLodashMethod('contains')) {
|
||||
source = replaceFunction(source, 'contains', [
|
||||
'function contains(collection, target) {',
|
||||
' var length = collection ? collection.length : 0,',
|
||||
' var indexOf = getIndexOf(),',
|
||||
' length = collection ? collection.length : 0,',
|
||||
' result = false;',
|
||||
" if (length && typeof length == 'number') {",
|
||||
' result = basicIndexOf(collection, target) > -1;',
|
||||
' result = indexOf(collection, target) > -1;',
|
||||
' } else {',
|
||||
' basicEach(collection, function(value) {',
|
||||
' return !(result = value === target);',
|
||||
@@ -2347,13 +2349,14 @@
|
||||
source = replaceFunction(source, 'difference', [
|
||||
'function difference(array) {',
|
||||
' var index = -1,',
|
||||
' indexOf = getIndexOf(),',
|
||||
' length = array.length,',
|
||||
' flattened = concat.apply(arrayProto, nativeSlice.call(arguments, 1)),',
|
||||
' result = [];',
|
||||
'',
|
||||
' while (++index < length) {',
|
||||
' var value = array[index];',
|
||||
' if (basicIndexOf(flattened, value) < 0) {',
|
||||
' if (indexOf(flattened, value) < 0) {',
|
||||
' result.push(value);',
|
||||
' }',
|
||||
' }',
|
||||
@@ -2388,16 +2391,17 @@
|
||||
' var args = arguments,',
|
||||
' argsLength = args.length,',
|
||||
' index = -1,',
|
||||
' indexOf = getIndexOf(),',
|
||||
' length = array ? array.length : 0,',
|
||||
' result = [];',
|
||||
'',
|
||||
' outer:',
|
||||
' while (++index < length) {',
|
||||
' var value = array[index];',
|
||||
' if (basicIndexOf(result, value) < 0) {',
|
||||
' if (indexOf(result, value) < 0) {',
|
||||
' var argsIndex = argsLength;',
|
||||
' while (--argsIndex) {',
|
||||
' if (basicIndexOf(args[argsIndex], value) < 0) {',
|
||||
' if (indexOf(args[argsIndex], value) < 0) {',
|
||||
' continue outer;',
|
||||
' }',
|
||||
' }',
|
||||
@@ -2547,11 +2551,12 @@
|
||||
if (!useLodashMethod('omit')) {
|
||||
source = replaceFunction(source, 'omit', [
|
||||
'function omit(object) {',
|
||||
' var props = concat.apply(arrayProto, nativeSlice.call(arguments, 1)),',
|
||||
' var indexOf = getIndexOf(),',
|
||||
' props = concat.apply(arrayProto, nativeSlice.call(arguments, 1)),',
|
||||
' result = {};',
|
||||
'',
|
||||
' forIn(object, function(value, key) {',
|
||||
' if (basicIndexOf(props, key) < 0) {',
|
||||
' if (indexOf(props, key) < 0) {',
|
||||
' result[key] = value;',
|
||||
' }',
|
||||
' });',
|
||||
@@ -2716,6 +2721,7 @@
|
||||
source = replaceFunction(source, 'uniq', [
|
||||
'function uniq(array, isSorted, callback, thisArg) {',
|
||||
' var index = -1,',
|
||||
' indexOf = getIndexOf(),',
|
||||
' length = array ? array.length : 0,',
|
||||
' result = [],',
|
||||
' seen = result;',
|
||||
@@ -2735,7 +2741,7 @@
|
||||
'',
|
||||
' if (isSorted',
|
||||
' ? !index || seen[seen.length - 1] !== computed',
|
||||
' : basicIndexOf(seen, computed) < 0',
|
||||
' : indexOf(seen, computed) < 0',
|
||||
' ) {',
|
||||
' if (callback) {',
|
||||
' seen.push(computed);',
|
||||
|
||||
Reference in New Issue
Block a user