Don't expose _.forIn or _.forOwn if underscore build modifier is present and include doesn't contain forIn or forOwn.

Former-commit-id: 6ebd0bc61d3ae6e2d0506fe72dd22ed59c601c70
This commit is contained in:
John-David Dalton
2012-08-13 00:44:37 -07:00
parent 23ff403529
commit 408029e6e0

View File

@@ -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 },