From 408029e6e06c561386fe232951372210a3fff30c Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 13 Aug 2012 00:44:37 -0700 Subject: [PATCH] Don't expose `_.forIn` or `_.forOwn` if `underscore` build modifier is present and `include` doesn't contain `forIn` or `forOwn`. Former-commit-id: 6ebd0bc61d3ae6e2d0506fe72dd22ed59c601c70 --- build.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/build.js b/build.js index 97ba1e11c..70c05413e 100755 --- a/build.js +++ b/build.js @@ -263,8 +263,8 @@ ]; /** Collections of method names */ - var excludeMethods, - includeMethods, + var excludeMethods = [], + includeMethods = [], allMethods = Object.keys(dependencyMap); var underscoreMethods = lodash.without.apply(lodash, [allMethods].concat([ @@ -720,6 +720,17 @@ /*--------------------------------------------------------------------------*/ + // don't expose `_.forIn` or `_.forOwn` if `isUnderscore` is `true` unless + // requested by `include` + if (isUnderscore) { + if (includeMethods.indexOf('forIn') == -1) { + source = source.replace(/ *lodash\.forIn *=.+\n/, ''); + } + if (includeMethods.indexOf('forOwn') == -1) { + source = source.replace(/ *lodash\.forOwn *=.+\n/, ''); + } + } + // add methods required by Backbone or Underscore [ { 'flag': isBackbone, 'methodNames': backboneDependencies },