Simplify dependency map modifications, and fix typos in getIndexOf replacements.

Former-commit-id: 4066c6950ac6d73b579d0f3f83dfc06f03cc98c9
This commit is contained in:
John-David Dalton
2013-07-01 22:45:56 -07:00
parent 8e9a244cdd
commit 0a47378f7f

111
build.js
View File

@@ -1611,8 +1611,8 @@
function removeGetIndexOf(source) { function removeGetIndexOf(source) {
source = removeFunction(source, 'getIndexOf'); source = removeFunction(source, 'getIndexOf');
// replace all `getIndexOf` calls with `basicEach` // replace all `getIndexOf` calls with `basicIndexOf`
source = source.replace(/\bgetIndexOf\(\)/g, 'basicEach'); source = source.replace(/\bgetIndexOf\(\)/g, 'basicIndexOf');
return source; return source;
} }
@@ -2551,28 +2551,26 @@
funcDependencyMap.isPlainObject = _.without(funcDependencyMap.isPlainObject, 'shimIsPlainObject'); funcDependencyMap.isPlainObject = _.without(funcDependencyMap.isPlainObject, 'shimIsPlainObject');
funcDependencyMap.keys = _.without(funcDependencyMap.keys, 'shimKeys'); funcDependencyMap.keys = _.without(funcDependencyMap.keys, 'shimKeys');
} }
if (isModern) { if (isMobile) {
funcDependencyMap.reduceRight = _.without(funcDependencyMap.reduceRight, 'isString'); _.each(['assign', 'defaults'], function(funcName) {
funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'keys');
if (isMobile) { });
_.each(['assign', 'defaults'], function(funcName) { }
funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'keys'); else if (isModern) {
}); _.forOwn(funcDependencyMap, function(deps, funcName) {
} if (_.contains(deps, 'isArguments')) {
else { funcDependencyMap[funcName] = _.without(deps, 'isArguments');
_.each(['isEmpty', 'isEqual', 'isPlainObject', 'keys'], function(funcName) { }
funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'isArguments'); });
});
}
} }
if (isModularize) { if (isModularize) {
_.each(['contains', 'difference', 'intersection', 'omit', 'uniq'], function(funcName) { _.forOwn(funcDependencyMap, function(deps, funcName) {
funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'getIndexOf'); if (_.contains(deps, 'getIndexOf')) {
funcDependencyMap[funcName].push( 'basicEach'); (deps = funcDependencyMap[funcName] = _.without(deps, 'getIndexOf')).push( 'basicIndexOf');
}) }
if (_.contains(deps, 'lodash') || _.contains(deps, 'lodashWrapper')) {
_.each(['createIterator', 'lodash', 'value'], function(funcName) { funcDependencyMap[funcName] = _.without(deps, 'lodash', 'lodashWrapper');
funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'lodash', 'lodashWrapper'); }
}) })
} }
if (isUnderscore) { if (isUnderscore) {
@@ -2627,15 +2625,6 @@
} }
}); });
_.each(['clone', 'first', 'initial', 'last', 'rest', 'toArray'], function(funcName) {
if (funcName == 'clone'
? (!isLodashFunc('clone') && !isLodashFunc('cloneDeep'))
: !isLodashFunc(funcName)
) {
funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'slice');
}
});
_.each(['clone', 'flatten', 'isEqual', 'omit', 'pick'], function(funcName) { _.each(['clone', 'flatten', 'isEqual', 'omit', 'pick'], function(funcName) {
if (funcName == 'clone' if (funcName == 'clone'
? (!isLodashFunc('clone') && !isLodashFunc('cloneDeep')) ? (!isLodashFunc('clone') && !isLodashFunc('cloneDeep'))
@@ -2651,36 +2640,33 @@
} }
}); });
_.each(['difference', 'intersection', 'uniq'], function(funcName) { _.forOwn(funcDependencyMap, function(deps, funcName) {
if (!isLodashFunc(funcName)) { if (funcName == 'clone'
funcDependencyMap[funcName] = ['getIndexOf'].concat(_.without(funcDependencyMap[funcName], 'cacheIndexOf', 'createCache')); ? (!isLodashFunc('clone') && !isLodashFunc('cloneDeep'))
} : !isLodashFunc(funcName)
}); ) {
if (_.contains(deps, 'charAtCallback')) {
_.each(['flatten', 'uniq'], function(funcName) { deps = funcDependencyMap[funcName] = _.without(deps, 'charAtCallback', 'isArray', 'isString')
if (!isLodashFunc(funcName)) { }
funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'overloadWrapper'); if (_.contains(deps, 'overloadWrapper')) {
} deps = funcDependencyMap[funcName] = _.without(deps, 'overloadWrapper');
}); }
if (_.contains(deps, 'slice')) {
_.each(['max', 'min'], function(funcName) { deps = funcDependencyMap[funcName] = _.without(deps, 'slice');
if (!isLodashFunc(funcName)) { }
funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'charAtCallback', 'isArray', 'isString'); if (_.contains(deps, 'createCache')) {
(funcDependencyMap[funcName] = _.without(deps, 'cacheIndexOf', 'createCache')).push('getIndexOf');
}
} }
}); });
} }
if (isModern || isUnderscore) { if (isModern || isUnderscore) {
funcDependencyMap.reduceRight = _.without(funcDependencyMap.reduceRight, 'isString');
_.each(['assign', 'basicEach', 'defaults', 'forIn', 'forOwn', 'shimKeys'], function(funcName) { _.each(['assign', 'basicEach', 'defaults', 'forIn', 'forOwn', 'shimKeys'], function(funcName) {
if (!(isUnderscore && isLodashFunc(funcName))) { if (!(isUnderscore && isLodashFunc(funcName))) {
var deps = funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'createIterator');
(varDependencyMap[funcName] || (varDependencyMap[funcName] = [])).push('objectTypes'); (varDependencyMap[funcName] || (varDependencyMap[funcName] = [])).push('objectTypes');
if (funcName != 'shimKeys') { var deps = funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'createIterator');
deps.push('createCallback'); if (funcName != 'forIn' && funcName != 'shimKeys') {
}
if (/^(?:assign|basicEach|defaults|forOwn)$/.test(funcName)) {
deps.push('keys'); deps.push('keys');
} }
} }
@@ -2694,27 +2680,22 @@
} }
}); });
_.each(['at', 'forEach', 'toArray'], function(funcName) { _.forOwn(funcDependencyMap, function(deps, funcName) {
if (!(isUnderscore && isLodashFunc(funcName))) { if (_.contains(deps, 'isNode')) {
funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'isString'); deps = funcDependencyMap[funcName] = _.without(deps, 'isNode');
} }
}); if (_.contains(deps, 'toString') && (funcName != 'contains' && funcName != 'parseInt')) {
funcDependencyMap[funcName] = _.without(deps, 'isString');
_.each(['clone', 'isEqual', 'shimIsPlainObject'], function(funcName) {
if (!(isUnderscore && isLodashFunc(funcName))) {
funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'isNode');
} }
}); });
if (!isMobile) { if (!isMobile) {
_.each(['clone', 'transform', 'value'], function(funcName) { _.each(['clone', 'transform', 'value'], function(funcName) {
funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'basicEach'); (funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'basicEach')).push('forEach');
funcDependencyMap[funcName].push('forEach');
}); });
_.each(['contains', 'every', 'filter', 'find', 'forEach', 'map', 'max', 'min', 'reduce', 'some'], function(funcName) { _.each(['contains', 'every', 'filter', 'find', 'forEach', 'map', 'max', 'min', 'reduce', 'some'], function(funcName) {
funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'basicEach'); (funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'basicEach')).push('forOwn');
funcDependencyMap[funcName].push('forOwn');
}); });
_.each(['every', 'find', 'filter', 'forEach', 'forIn', 'forOwn', 'map', 'reduce', 'shimKeys'], function(funcName) { _.each(['every', 'find', 'filter', 'forEach', 'forIn', 'forOwn', 'map', 'reduce', 'shimKeys'], function(funcName) {