Rename isLodashFunc to isLodash in build.js.

Former-commit-id: 4e7ae65eeba640e095aeaf92c2f36cc70ca783c2
This commit is contained in:
John-David Dalton
2013-07-08 08:34:15 -07:00
parent 36488fd836
commit fdae297fca

132
build.js
View File

@@ -2439,7 +2439,7 @@
}); });
}; };
var isLodashFunc = function(funcName) { var isLodash = function(funcName) {
if (_.contains(lodashOnlyFuncs, funcName) || /^(?:assign|zipObject)$/.test(funcName)) { if (_.contains(lodashOnlyFuncs, funcName) || /^(?:assign|zipObject)$/.test(funcName)) {
var funcNames = _.difference(_.union(includeFuncs, plusFuncs), minusFuncs); var funcNames = _.difference(_.union(includeFuncs, plusFuncs), minusFuncs);
return _.contains(funcNames, funcName); return _.contains(funcNames, funcName);
@@ -2449,7 +2449,7 @@
}; };
// delete the `_.findWhere` dependency map to enable its alias mapping // delete the `_.findWhere` dependency map to enable its alias mapping
if (!isUnderscore || isLodashFunc('findWhere')) { if (!isUnderscore || isLodash('findWhere')) {
delete funcDependencyMap.findWhere; delete funcDependencyMap.findWhere;
} }
@@ -2641,44 +2641,44 @@
}) })
} }
if (isUnderscore) { if (isUnderscore) {
if (!isLodashFunc('clone') && !isLodashFunc('cloneDeep')) { if (!isLodash('clone') && !isLodash('cloneDeep')) {
funcDependencyMap.clone = _.without(funcDependencyMap.clone, 'forEach', 'forOwn'); funcDependencyMap.clone = _.without(funcDependencyMap.clone, 'forEach', 'forOwn');
} }
if (!isLodashFunc('contains')) { if (!isLodash('contains')) {
funcDependencyMap.contains = _.without(funcDependencyMap.contains, 'isString'); funcDependencyMap.contains = _.without(funcDependencyMap.contains, 'isString');
} }
if (!isLodashFunc('isEmpty')) { if (!isLodash('isEmpty')) {
funcDependencyMap.isEmpty = ['isArray', 'isString']; funcDependencyMap.isEmpty = ['isArray', 'isString'];
} }
if (!isLodashFunc('isEqual')) { if (!isLodash('isEqual')) {
funcDependencyMap.isEqual = _.without(funcDependencyMap.isEqual, 'forIn', 'isArguments'); funcDependencyMap.isEqual = _.without(funcDependencyMap.isEqual, 'forIn', 'isArguments');
} }
if (!isLodashFunc('pick')){ if (!isLodash('pick')){
funcDependencyMap.pick = _.without(funcDependencyMap.pick, 'forIn', 'isObject'); funcDependencyMap.pick = _.without(funcDependencyMap.pick, 'forIn', 'isObject');
} }
if (!isLodashFunc('template')) { if (!isLodash('template')) {
funcDependencyMap.template = _.without(funcDependencyMap.template, 'keys', 'values'); funcDependencyMap.template = _.without(funcDependencyMap.template, 'keys', 'values');
} }
if (!isLodashFunc('toArray')) { if (!isLodash('toArray')) {
funcDependencyMap.toArray.push('isArray', 'map'); funcDependencyMap.toArray.push('isArray', 'map');
} }
if (!isLodashFunc('where')) { if (!isLodash('where')) {
funcDependencyMap.createCallback = _.without(funcDependencyMap.createCallback, 'isEqual'); funcDependencyMap.createCallback = _.without(funcDependencyMap.createCallback, 'isEqual');
funcDependencyMap.where.push('find', 'isEmpty'); funcDependencyMap.where.push('find', 'isEmpty');
} }
if (!isLodashFunc('forOwn')) { if (!isLodash('forOwn')) {
_.each(['contains', 'every', 'find', 'forOwn', 'some', 'transform'], function(funcName) { _.each(['contains', 'every', 'find', 'forOwn', 'some', 'transform'], function(funcName) {
(varDependencyMap[funcName] || (varDependencyMap[funcName] = [])).push('indicatorObject'); (varDependencyMap[funcName] || (varDependencyMap[funcName] = [])).push('indicatorObject');
}); });
} }
if (!isLodashFunc('forIn')) { if (!isLodash('forIn')) {
_.each(['isEqual', 'shimIsPlainObject'], function(funcName) { _.each(['isEqual', 'shimIsPlainObject'], function(funcName) {
(varDependencyMap[funcName] || (varDependencyMap[funcName] = [])).push('indicatorObject'); (varDependencyMap[funcName] || (varDependencyMap[funcName] = [])).push('indicatorObject');
}); });
} }
_.each(['flatten', 'uniq'], function(funcName) { _.each(['flatten', 'uniq'], function(funcName) {
if (!isLodashFunc(funcName)) { if (!isLodash(funcName)) {
var basicFuncName = 'basic' + capitalize(funcName); var basicFuncName = 'basic' + capitalize(funcName);
(funcDependencyMap.union = _.without(funcDependencyMap.union, basicFuncName)).push(funcName); (funcDependencyMap.union = _.without(funcDependencyMap.union, basicFuncName)).push(funcName);
@@ -2691,21 +2691,21 @@
}); });
_.each(['difference', 'intersection', 'uniq'], function(funcName) { _.each(['difference', 'intersection', 'uniq'], function(funcName) {
if (!isLodashFunc(funcName)) { if (!isLodash(funcName)) {
(funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'cacheIndexOf', 'createCache')).push('getIndexOf'); (funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'cacheIndexOf', 'createCache')).push('getIndexOf');
} }
}); });
_.each(['basicEach', 'forEach', 'forIn', 'forOwn'], function(funcName) { _.each(['basicEach', 'forEach', 'forIn', 'forOwn'], function(funcName) {
if (funcName == 'basicEach' || !isLodashFunc(funcName)) { if (funcName == 'basicEach' || !isLodash(funcName)) {
(varDependencyMap[funcName] || (varDependencyMap[funcName] = [])).push('indicatorObject'); (varDependencyMap[funcName] || (varDependencyMap[funcName] = [])).push('indicatorObject');
} }
}); });
_.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')) ? (!isLodash('clone') && !isLodash('cloneDeep'))
: !isLodashFunc(funcName) : !isLodash(funcName)
) { ) {
funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'createCallback'); funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'createCallback');
} }
@@ -2713,7 +2713,7 @@
_.forOwn(funcDependencyMap, function(deps, funcName) { _.forOwn(funcDependencyMap, function(deps, funcName) {
if (_.every(getDependants(funcName).concat(funcName), function(otherName) { if (_.every(getDependants(funcName).concat(funcName), function(otherName) {
return !isLodashFunc(otherName); return !isLodash(otherName);
})) { })) {
deps = funcDependencyMap[funcName]; deps = funcDependencyMap[funcName];
if (_.contains(deps, 'charAtCallback')) { if (_.contains(deps, 'charAtCallback')) {
@@ -2730,7 +2730,7 @@
} }
if (isModern || isUnderscore) { if (isModern || isUnderscore) {
_.each(['assign', 'basicEach', 'defaults', 'forIn', 'forOwn', 'shimKeys'], function(funcName) { _.each(['assign', 'basicEach', 'defaults', 'forIn', 'forOwn', 'shimKeys'], function(funcName) {
if (!(isUnderscore && isLodashFunc(funcName))) { if (!(isUnderscore && isLodash(funcName))) {
(varDependencyMap[funcName] || (varDependencyMap[funcName] = [])).push('objectTypes'); (varDependencyMap[funcName] || (varDependencyMap[funcName] = [])).push('objectTypes');
var deps = funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'createIterator'); var deps = funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'createIterator');
@@ -2743,7 +2743,7 @@
_.forOwn(propDependencyMap, function(deps, funcName) { _.forOwn(propDependencyMap, function(deps, funcName) {
if (funcName != 'bind' && if (funcName != 'bind' &&
!(isMobile && funcName == 'keys') && !(isMobile && funcName == 'keys') &&
!(isUnderscore && isLodashFunc(funcName))) { !(isUnderscore && isLodash(funcName))) {
propDependencyMap[funcName] = _.without(deps, 'support'); propDependencyMap[funcName] = _.without(deps, 'support');
} }
}); });
@@ -2760,7 +2760,7 @@
if (isUnderscore) { if (isUnderscore) {
_.forOwn(funcDependencyMap, function(deps, funcName) { _.forOwn(funcDependencyMap, function(deps, funcName) {
if (_.every(getDependants(funcName).concat(funcName), function(otherName) { if (_.every(getDependants(funcName).concat(funcName), function(otherName) {
return !isLodashFunc(otherName); return !isLodash(otherName);
})) { })) {
deps = funcDependencyMap[funcName]; deps = funcDependencyMap[funcName];
if (_.contains(deps, 'releaseArray')) { if (_.contains(deps, 'releaseArray')) {
@@ -2782,13 +2782,13 @@
}); });
_.each(['every', 'find', 'filter', 'forEach', 'forIn', 'forOwn', 'map', 'reduce', 'shimKeys'], function(funcName) { _.each(['every', 'find', 'filter', 'forEach', 'forIn', 'forOwn', 'map', 'reduce', 'shimKeys'], function(funcName) {
if (!(isUnderscore && isLodashFunc(funcName))) { if (!(isUnderscore && isLodash(funcName))) {
funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'isArguments', 'isArray'); funcDependencyMap[funcName] = _.without(funcDependencyMap[funcName], 'isArguments', 'isArray');
} }
}); });
_.each(['max', 'min'], function(funcName) { _.each(['max', 'min'], function(funcName) {
if (!(isUnderscore && isLodashFunc(funcName))) { if (!(isUnderscore && isLodash(funcName))) {
funcDependencyMap[funcName].push('forEach'); funcDependencyMap[funcName].push('forEach');
} }
}); });
@@ -2919,14 +2919,14 @@
}); });
} }
} }
if ((isLegacy || isMobile || isUnderscore) && !isLodashFunc('createCallback')) { if ((isLegacy || isMobile || isUnderscore) && !isLodash('createCallback')) {
source = removeBindingOptimization(source); source = removeBindingOptimization(source);
} }
if (isLegacy || isMobile || isUnderscore) { if (isLegacy || isMobile || isUnderscore) {
if (isMobile || (!isLodashFunc('assign') && !isLodashFunc('defaults') && !isLodashFunc('forIn') && !isLodashFunc('forOwn'))) { if (isMobile || (!isLodash('assign') && !isLodash('defaults') && !isLodash('forIn') && !isLodash('forOwn'))) {
source = removeKeysOptimization(source); source = removeKeysOptimization(source);
} }
if (!isLodashFunc('defer')) { if (!isLodash('defer')) {
source = removeDeferFork(source); source = removeDeferFork(source);
} }
} }
@@ -2964,7 +2964,7 @@
].join('\n')); ].join('\n'));
// replace `_.isRegExp` // replace `_.isRegExp`
if (!isUnderscore || (isUnderscore && isLodashFunc('isRegExp'))) { if (!isUnderscore || (isUnderscore && isLodash('isRegExp'))) {
source = replaceFunction(source, 'isRegExp', [ source = replaceFunction(source, 'isRegExp', [
'function isRegExp(value) {', 'function isRegExp(value) {',
" return value ? (typeof value == 'object' && toString.call(value) == regexpClass) : false;", " return value ? (typeof value == 'object' && toString.call(value) == regexpClass) : false;",
@@ -3018,7 +3018,7 @@
} }
else if (/^(?:max|min)$/.test(funcName)) { else if (/^(?:max|min)$/.test(funcName)) {
match = match.replace(/\bbasicEach\(/, 'forEach('); match = match.replace(/\bbasicEach\(/, 'forEach(');
if (!isUnderscore || isLodashFunc(funcName)) { if (!isUnderscore || isLodash(funcName)) {
return match; return match;
} }
} }
@@ -3049,7 +3049,7 @@
].join('\n')); ].join('\n'));
// replace `_.assign` // replace `_.assign`
if (!isLodashFunc('assign')) { if (!isLodash('assign')) {
source = replaceFunction(source, 'assign', [ source = replaceFunction(source, 'assign', [
'function assign(object) {', 'function assign(object) {',
' if (!object) {', ' if (!object) {',
@@ -3068,7 +3068,7 @@
].join('\n')); ].join('\n'));
} }
// replace `_.clone` // replace `_.clone`
if (!isLodashFunc('clone') && !isLodashFunc('cloneDeep')) { if (!isLodash('clone') && !isLodash('cloneDeep')) {
source = replaceFunction(source, 'clone', [ source = replaceFunction(source, 'clone', [
'function clone(value) {', 'function clone(value) {',
' return isObject(value)', ' return isObject(value)',
@@ -3078,7 +3078,7 @@
].join('\n')); ].join('\n'));
} }
// replace `_.contains` // replace `_.contains`
if (!isLodashFunc('contains')) { if (!isLodash('contains')) {
source = replaceFunction(source, 'contains', [ source = replaceFunction(source, 'contains', [
'function contains(collection, target) {', 'function contains(collection, target) {',
' var indexOf = getIndexOf(),', ' var indexOf = getIndexOf(),',
@@ -3096,7 +3096,7 @@
].join('\n')); ].join('\n'));
} }
// replace `_.defaults` // replace `_.defaults`
if (!isLodashFunc('defaults')) { if (!isLodash('defaults')) {
source = replaceFunction(source, 'defaults', [ source = replaceFunction(source, 'defaults', [
'function defaults(object) {', 'function defaults(object) {',
' if (!object) {', ' if (!object) {',
@@ -3117,7 +3117,7 @@
].join('\n')); ].join('\n'));
} }
// replace `_.difference` // replace `_.difference`
if (!isLodashFunc('difference')) { if (!isLodash('difference')) {
source = replaceFunction(source, 'difference', [ source = replaceFunction(source, 'difference', [
'function difference(array) {', 'function difference(array) {',
' var index = -1,', ' var index = -1,',
@@ -3137,7 +3137,7 @@
].join('\n')); ].join('\n'));
} }
// add Underscore's `_.findWhere` // add Underscore's `_.findWhere`
if (!isLodashFunc('findWhere') && !isLodashFunc('where')) { if (!isLodash('findWhere') && !isLodash('where')) {
source = source.replace(matchFunction(source, 'find'), function(match) { source = source.replace(matchFunction(source, 'find'), function(match) {
var indent = getIndent(match); var indent = getIndent(match);
return match && (match + [ return match && (match + [
@@ -3178,7 +3178,7 @@
}); });
} }
// replace `_.flatten` // replace `_.flatten`
if (!isLodashFunc('flatten')) { if (!isLodash('flatten')) {
source = replaceFunction(source, 'flatten', [ source = replaceFunction(source, 'flatten', [
'function flatten(array, isShallow) {', 'function flatten(array, isShallow) {',
' var index = -1,', ' var index = -1,',
@@ -3198,7 +3198,7 @@
].join('\n')); ].join('\n'));
} }
// replace `_.intersection` // replace `_.intersection`
if (!isLodashFunc('intersection')) { if (!isLodash('intersection')) {
source = replaceFunction(source, 'intersection', [ source = replaceFunction(source, 'intersection', [
'function intersection(array) {', 'function intersection(array) {',
' var args = arguments,', ' var args = arguments,',
@@ -3226,7 +3226,7 @@
].join('\n')); ].join('\n'));
} }
// replace `_.isEmpty` // replace `_.isEmpty`
if (!isLodashFunc('isEmpty')) { if (!isLodash('isEmpty')) {
source = replaceFunction(source, 'isEmpty', [ source = replaceFunction(source, 'isEmpty', [
'function isEmpty(value) {', 'function isEmpty(value) {',
' if (!value) {', ' if (!value) {',
@@ -3245,7 +3245,7 @@
].join('\n')); ].join('\n'));
} }
// replace `_.isEqual` // replace `_.isEqual`
if (!isLodashFunc('isEqual')) { if (!isLodash('isEqual')) {
source = replaceFunction(source, 'isEqual', [ source = replaceFunction(source, 'isEqual', [
'function isEqual(a, b, stackA, stackB) {', 'function isEqual(a, b, stackA, stackB) {',
' if (a === b) {', ' if (a === b) {',
@@ -3347,7 +3347,7 @@
].join('\n')); ].join('\n'));
} }
// replace `_.memoize` // replace `_.memoize`
if (!isLodashFunc('memoize')) { if (!isLodash('memoize')) {
source = replaceFunction(source, 'memoize', [ source = replaceFunction(source, 'memoize', [
'function memoize(func, resolver) {', 'function memoize(func, resolver) {',
' var cache = {};', ' var cache = {};',
@@ -3361,7 +3361,7 @@
].join('\n')); ].join('\n'));
} }
// replace `_.omit` // replace `_.omit`
if (!isLodashFunc('omit')) { if (!isLodash('omit')) {
source = replaceFunction(source, 'omit', [ source = replaceFunction(source, 'omit', [
'function omit(object) {', 'function omit(object) {',
' var indexOf = getIndexOf(),', ' var indexOf = getIndexOf(),',
@@ -3378,7 +3378,7 @@
].join('\n')); ].join('\n'));
} }
// replace `_.pick` // replace `_.pick`
if (!isLodashFunc('pick')) { if (!isLodash('pick')) {
source = replaceFunction(source, 'pick', [ source = replaceFunction(source, 'pick', [
'function pick(object) {', 'function pick(object) {',
' var index = -1,', ' var index = -1,',
@@ -3397,7 +3397,7 @@
].join('\n')); ].join('\n'));
} }
// replace `_.result` // replace `_.result`
if (!isLodashFunc('result')) { if (!isLodash('result')) {
source = replaceFunction(source, 'result', [ source = replaceFunction(source, 'result', [
'function result(object, property) {', 'function result(object, property) {',
' var value = object ? object[property] : undefined;', ' var value = object ? object[property] : undefined;',
@@ -3406,7 +3406,7 @@
].join('\n')); ].join('\n'));
} }
// replace `_.sortBy` // replace `_.sortBy`
if (!isLodashFunc('sortBy')) { if (!isLodash('sortBy')) {
source = replaceFunction(source, 'sortBy', [ source = replaceFunction(source, 'sortBy', [
'function sortBy(collection, callback, thisArg) {', 'function sortBy(collection, callback, thisArg) {',
' var index = -1,', ' var index = -1,',
@@ -3432,7 +3432,7 @@
].join('\n')); ].join('\n'));
} }
// replace `_.template` // replace `_.template`
if (!isLodashFunc('template')) { if (!isLodash('template')) {
// remove `_.templateSettings.imports assignment // remove `_.templateSettings.imports assignment
source = source.replace(/,[^']*'imports':[^}]+}/, ''); source = source.replace(/,[^']*'imports':[^}]+}/, '');
@@ -3493,7 +3493,7 @@
].join('\n')); ].join('\n'));
} }
// replace `_.throttle` // replace `_.throttle`
if (!isLodashFunc('throttle')) { if (!isLodash('throttle')) {
source = replaceFunction(source, 'throttle', [ source = replaceFunction(source, 'throttle', [
'function throttle(func, wait, options) {', 'function throttle(func, wait, options) {',
' var leading = true,', ' var leading = true,',
@@ -3515,7 +3515,7 @@
].join('\n')); ].join('\n'));
} }
// replace `_.times` // replace `_.times`
if (!isLodashFunc('times')) { if (!isLodash('times')) {
source = replaceFunction(source, 'times', [ source = replaceFunction(source, 'times', [
'function times(n, callback, thisArg) {', 'function times(n, callback, thisArg) {',
' var index = -1,', ' var index = -1,',
@@ -3529,7 +3529,7 @@
].join('\n')); ].join('\n'));
} }
// replace `_.toArray` // replace `_.toArray`
if (!isLodashFunc('toArray')) { if (!isLodash('toArray')) {
source = replaceFunction(source, 'toArray', [ source = replaceFunction(source, 'toArray', [
'function toArray(collection) {', 'function toArray(collection) {',
' if (isArray(collection)) {', ' if (isArray(collection)) {',
@@ -3543,7 +3543,7 @@
].join('\n')); ].join('\n'));
} }
// replace `_.uniq` // replace `_.uniq`
if (!isLodashFunc('uniq')) { if (!isLodash('uniq')) {
source = replaceFunction(source, 'uniq', [ source = replaceFunction(source, 'uniq', [
'function uniq(array, isSorted, callback, thisArg) {', 'function uniq(array, isSorted, callback, thisArg) {',
' var index = -1,', ' var index = -1,',
@@ -3580,7 +3580,7 @@
].join('\n')); ].join('\n'));
} }
// replace `_.uniqueId` // replace `_.uniqueId`
if (!isLodashFunc('uniqueId')) { if (!isLodash('uniqueId')) {
source = replaceFunction(source, 'uniqueId', [ source = replaceFunction(source, 'uniqueId', [
'function uniqueId(prefix) {', 'function uniqueId(prefix) {',
" var id = ++idCounter + '';", " var id = ++idCounter + '';",
@@ -3589,7 +3589,7 @@
].join('\n')); ].join('\n'));
} }
// replace `_.where` // replace `_.where`
if (!isLodashFunc('where')) { if (!isLodash('where')) {
source = replaceFunction(source, 'where', [ source = replaceFunction(source, 'where', [
'function where(collection, properties, first) {', 'function where(collection, properties, first) {',
' return (first && isEmpty(properties))', ' return (first && isEmpty(properties))',
@@ -3599,7 +3599,7 @@
].join('\n')); ].join('\n'));
} }
// replace `_.zip` // replace `_.zip`
if(!isLodashFunc('zip')) { if(!isLodash('zip')) {
source = replaceFunction(source, 'zip', [ source = replaceFunction(source, 'zip', [
'function zip() {', 'function zip() {',
' var index = -1,', ' var index = -1,',
@@ -3614,12 +3614,12 @@
].join('\n')); ].join('\n'));
} }
// unexpose `lodash.support` // unexpose `lodash.support`
if (!isLodashFunc('support')) { if (!isLodash('support')) {
source = source.replace(/\blodash\.support *= */, ''); source = source.replace(/\blodash\.support *= */, '');
} }
// add an `/` entry to `htmlEscapes`, `reEscapedHtml`, and `reUnescapedHtml` // add an `/` entry to `htmlEscapes`, `reEscapedHtml`, and `reUnescapedHtml`
if (!isLodashFunc('escape')) { if (!isLodash('escape')) {
source = source.replace(matchVar(source, 'htmlEscapes'), function(match) { source = source.replace(matchVar(source, 'htmlEscapes'), function(match) {
return match return match
.replace('#39', '#x27') .replace('#39', '#x27')
@@ -3637,7 +3637,7 @@
// replace `basicFlatten` and `basicUniq` with `flatten` and `uniq` in `_.union` // replace `basicFlatten` and `basicUniq` with `flatten` and `uniq` in `_.union`
_.each(['flatten', 'uniq'], function(funcName) { _.each(['flatten', 'uniq'], function(funcName) {
if (!isLodashFunc(funcName)) { if (!isLodash(funcName)) {
source = source.replace(matchFunction(source, 'union'), function(match) { source = source.replace(matchFunction(source, 'union'), function(match) {
var basicFuncName = 'basic' + capitalize(funcName); var basicFuncName = 'basic' + capitalize(funcName);
return match.replace(RegExp('\\b' + basicFuncName + '\\b', 'g'), funcName); return match.replace(RegExp('\\b' + basicFuncName + '\\b', 'g'), funcName);
@@ -3648,8 +3648,8 @@
// replace `slice` with `nativeSlice.call` // replace `slice` with `nativeSlice.call`
_.each(['clone', 'first', 'initial', 'last', 'rest', 'toArray'], function(funcName) { _.each(['clone', 'first', 'initial', 'last', 'rest', 'toArray'], function(funcName) {
if (funcName == 'clone' if (funcName == 'clone'
? (!isLodashFunc('clone') && !isLodashFunc('cloneDeep')) ? (!isLodash('clone') && !isLodash('cloneDeep'))
: !isLodashFunc(funcName) : !isLodash(funcName)
) { ) {
source = source.replace(matchFunction(source, funcName), function(match) { source = source.replace(matchFunction(source, funcName), function(match) {
return match.replace(/([^\w.])slice\(/g, '$1nativeSlice.call('); return match.replace(/([^\w.])slice\(/g, '$1nativeSlice.call(');
@@ -3659,7 +3659,7 @@
// remove conditional `charCodeCallback` use from `_.max` and `_.min` // remove conditional `charCodeCallback` use from `_.max` and `_.min`
_.each(['max', 'min'], function(funcName) { _.each(['max', 'min'], function(funcName) {
if (!isLodashFunc(funcName)) { if (!isLodash(funcName)) {
source = source.replace(matchFunction(source, funcName), function(match) { source = source.replace(matchFunction(source, funcName), function(match) {
return match.replace(/=.+?callback *&& *isString[^:]+:\s*/g, '= '); return match.replace(/=.+?callback *&& *isString[^:]+:\s*/g, '= ');
}); });
@@ -3667,7 +3667,7 @@
}); });
// remove `_.isEqual` use from `createCallback` // remove `_.isEqual` use from `createCallback`
if (!isLodashFunc('where')) { if (!isLodash('where')) {
source = source.replace(matchFunction(source, 'createCallback'), function(match) { source = source.replace(matchFunction(source, 'createCallback'), function(match) {
return match.replace(/\bisEqual\(([^,]+), *([^,]+)[^)]+\)/, '$1 === $2'); return match.replace(/\bisEqual\(([^,]+), *([^,]+)[^)]+\)/, '$1 === $2');
}); });
@@ -3791,7 +3791,7 @@
// inline all functions defined with `createIterator` // inline all functions defined with `createIterator`
_.functions(lodash).forEach(function(funcName) { _.functions(lodash).forEach(function(funcName) {
if (!(isUnderscore && isLodashFunc(funcName))) { if (!(isUnderscore && isLodash(funcName))) {
// strip leading underscores to match pseudo private functions // strip leading underscores to match pseudo private functions
var reFunc = RegExp('^( *)(var ' + funcName.replace(/^_/, '') + ' *= *)createIterator\\(((?:{|[a-zA-Z])[\\s\\S]+?)\\);\\n', 'm'); var reFunc = RegExp('^( *)(var ' + funcName.replace(/^_/, '') + ' *= *)createIterator\\(((?:{|[a-zA-Z])[\\s\\S]+?)\\);\\n', 'm');
if (reFunc.test(source)) { if (reFunc.test(source)) {
@@ -3807,7 +3807,7 @@
if (isUnderscore) { if (isUnderscore) {
// unexpose "exit early" feature of `basicEach`, `_.forEach`, `_.forIn`, and `_.forOwn` // unexpose "exit early" feature of `basicEach`, `_.forEach`, `_.forIn`, and `_.forOwn`
_.each(['basicEach', 'forEach', 'forIn', 'forOwn'], function(funcName) { _.each(['basicEach', 'forEach', 'forIn', 'forOwn'], function(funcName) {
if (funcName == 'basicEach' || !isLodashFunc(funcName)) { if (funcName == 'basicEach' || !isLodash(funcName)) {
source = source.replace(matchFunction(source, funcName), function(match) { source = source.replace(matchFunction(source, funcName), function(match) {
return match.replace(/=== *false\)/g, '=== indicatorObject)'); return match.replace(/=== *false\)/g, '=== indicatorObject)');
}); });
@@ -3815,7 +3815,7 @@
}); });
// modify `_.contains`, `_.every`, `_.find`, `_.some`, and `_.transform` to use the private `indicatorObject` // modify `_.contains`, `_.every`, `_.find`, `_.some`, and `_.transform` to use the private `indicatorObject`
if (isUnderscore && !isLodashFunc('forOwn')) { if (isUnderscore && !isLodash('forOwn')) {
source = source.replace(matchFunction(source, 'every'), function(match) { source = source.replace(matchFunction(source, 'every'), function(match) {
return match.replace(/\(result *= *(.+?)\);/g, '!(result = $1) && indicatorObject;'); return match.replace(/\(result *= *(.+?)\);/g, '!(result = $1) && indicatorObject;');
}); });
@@ -3835,7 +3835,7 @@
}); });
} }
// modify `_.isEqual` and `shimIsPlainObject` to use the private `indicatorObject` // modify `_.isEqual` and `shimIsPlainObject` to use the private `indicatorObject`
if (!isLodashFunc('forIn')) { if (!isLodash('forIn')) {
source = source.replace(matchFunction(source, 'isEqual'), function(match) { source = source.replace(matchFunction(source, 'isEqual'), function(match) {
return match.replace(/\(result *= *(.+?)\);/g, '!(result = $1) && indicatorObject;'); return match.replace(/\(result *= *(.+?)\);/g, '!(result = $1) && indicatorObject;');
}); });
@@ -3847,7 +3847,7 @@
// remove `thisArg` from unexposed `forIn` and `forOwn` // remove `thisArg` from unexposed `forIn` and `forOwn`
_.each(['forIn', 'forOwn'], function(funcName) { _.each(['forIn', 'forOwn'], function(funcName) {
if (!isLodashFunc(funcName)) { if (!isLodash(funcName)) {
source = source.replace(matchFunction(source, funcName), function(match) { source = source.replace(matchFunction(source, funcName), function(match) {
return match return match
.replace(/(callback), *thisArg/g, '$1') .replace(/(callback), *thisArg/g, '$1')
@@ -3857,11 +3857,11 @@
}); });
// replace `lodash.createCallback` references with `createCallback` // replace `lodash.createCallback` references with `createCallback`
if (!isLodashFunc('createCallback')) { if (!isLodash('createCallback')) {
source = source.replace(/\blodash\.(createCallback\()\b/g, '$1'); source = source.replace(/\blodash\.(createCallback\()\b/g, '$1');
} }
// remove chainability from `basicEach` and `_.forEach` // remove chainability from `basicEach` and `_.forEach`
if (!isLodashFunc('forEach')) { if (!isLodash('forEach')) {
_.each(['basicEach', 'forEach'], function(funcName) { _.each(['basicEach', 'forEach'], function(funcName) {
source = source.replace(matchFunction(source, funcName), function(match) { source = source.replace(matchFunction(source, funcName), function(match) {
return match return match
@@ -3873,7 +3873,7 @@
// remove `_.assign`, `_.forIn`, `_.forOwn`, `_.isPlainObject`, and `_.zipObject` assignments // remove `_.assign`, `_.forIn`, `_.forOwn`, `_.isPlainObject`, and `_.zipObject` assignments
source = source.replace(getMethodAssignments(source), function(match) { source = source.replace(getMethodAssignments(source), function(match) {
return _.reduce(['assign', 'createCallback', 'forIn', 'forOwn', 'isPlainObject', 'zipObject'], function(result, funcName) { return _.reduce(['assign', 'createCallback', 'forIn', 'forOwn', 'isPlainObject', 'zipObject'], function(result, funcName) {
return isLodashFunc(funcName) return isLodash(funcName)
? result ? result
: result.replace(RegExp('^(?: *//.*\\s*)* *lodash\\.' + funcName + ' *=[\\s\\S]+?;\\n', 'm'), ''); : result.replace(RegExp('^(?: *//.*\\s*)* *lodash\\.' + funcName + ' *=[\\s\\S]+?;\\n', 'm'), '');
}, match); }, match);