From 880f785d048cb74d7cf45c576cfb2fad66997356 Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sun, 30 Jun 2013 00:23:02 -0700 Subject: [PATCH] Add `removeAssignments` and the snippet that removes methods in build.js. Former-commit-id: 873a147f2fcb8a0ab19a7980644b1f542bab9b8b --- build.js | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/build.js b/build.js index bfe21cf40..ea6f90136 100755 --- a/build.js +++ b/build.js @@ -1538,6 +1538,22 @@ return source; } + /** + * Removes all Lo-Dash assignments from `source`. + * + * @private + * @param {String} source The source to inspect. + * @returns {String} Returns the modified source. + */ + function removeAssignments(source) { + source = removePseudoPrivates(source); + source = removeMethodAssignments(source); + + // remove intermediate assignments + source = source.replace(/(=\s*)lodash\.\w+\s*=\s*/g, '$1'); + return source; + } + /** * Removes the Lo-Dash method assignments snippet from `source`. * @@ -3566,17 +3582,6 @@ return snippet; }); - // remove methods from the build - allMethods.forEach(function(otherName) { - if (!_.contains(buildMethods, otherName) && - !(otherName == 'findWhere' && !isUnderscore)) { - source = removeFunction(source, otherName); - if (!isNoDep) { - source = removeFromCreateIterator(source, otherName); - } - } - }); - // remove `iteratorTemplate` dependency checks from `_.template` source = source.replace(matchFunction(source, 'template'), function(match) { return match @@ -3789,6 +3794,17 @@ }); } + // remove methods from the build + allMethods.forEach(function(otherName) { + if (!_.contains(buildMethods, otherName) && + !(otherName == 'findWhere' && !isUnderscore)) { + source = removeFunction(source, otherName); + if (!isNoDep) { + source = removeFromCreateIterator(source, otherName); + } + } + }); + // remove forks of removed methods _.each(['createObject', 'defer', 'isArguments', 'isArray', 'isFunction'], function(methodName) { if (isExcluded(methodName)) { @@ -3805,7 +3821,7 @@ while (varNames.length) { varNames = _.sortBy(varNames, function(varName) { - var result = isVarUsed(snippet, varName, isShallow); + var result = _.contains(includeVars, varName) || isVarUsed(snippet, varName, isShallow); useMap[varName] = result; return result; });