mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 09:27:49 +00:00
Remove the large array optimization for _.uniq from the underscore build.
Former-commit-id: 4cafbf2568c786834e40f0e4ea9b64ff670f60b7
This commit is contained in:
35
build.js
35
build.js
@@ -1151,6 +1151,36 @@
|
||||
' }'
|
||||
].join('\n'));
|
||||
|
||||
// replace `_.uniq`
|
||||
source = source.replace(/^( +)function uniq[\s\S]+?\n\1}/m, [
|
||||
' function uniq(array, isSorted, callback, thisArg) {',
|
||||
' var index = -1,',
|
||||
' length = array ? array.length : 0,',
|
||||
' result = [],',
|
||||
' seen = result;',
|
||||
'',
|
||||
' if (callback) {',
|
||||
' seen = [];',
|
||||
' callback = createCallback(callback, thisArg);',
|
||||
' }',
|
||||
' while (++index < length) {',
|
||||
' var value = array[index],',
|
||||
' computed = callback ? callback(value, index, array) : value;',
|
||||
'',
|
||||
' if (isSorted',
|
||||
' ? !index || seen[seen.length - 1] !== computed',
|
||||
' : indexOf(seen, computed) < 0',
|
||||
' ) {',
|
||||
' if (callback) {',
|
||||
' seen.push(computed);',
|
||||
' }',
|
||||
' result.push(value);',
|
||||
' }',
|
||||
' }',
|
||||
' return result;',
|
||||
' }'
|
||||
].join('\n'));
|
||||
|
||||
// replace `_.without`
|
||||
source = source.replace(/^( +)function without[\s\S]+?\n\1}/m, [
|
||||
' function without(array) {',
|
||||
@@ -1177,11 +1207,6 @@
|
||||
// simplify DOM node check from `_.isEqual`
|
||||
source = source.replace(/(if *\(className *!= *objectClass).+?noNodeClass[\s\S]+?{/, '$1) {');
|
||||
|
||||
// remove arguments juggling from `_.uniq`
|
||||
source = source.replace(matchFunction(source, 'uniq'), function(match) {
|
||||
return match.replace(/(?: *\/\/.*\n)*( +)if *\(typeof isSorted[^}]+?}\n/, '');
|
||||
});
|
||||
|
||||
// remove unused features from `createBound`
|
||||
if (buildMethods.indexOf('partial') == -1) {
|
||||
source = source.replace(matchFunction(source, 'createBound'), function(match) {
|
||||
|
||||
Reference in New Issue
Block a user