Cleanup getCategory, add removeProp, remove removeTemplateSettings, rename getMethodsByCategory to getNamesByCategory.

Former-commit-id: 290525ce178f67235683efd70a779aec62a08c71
This commit is contained in:
John-David Dalton
2013-06-30 21:58:01 -07:00
parent 69cbb6e109
commit 946029a3f7

View File

@@ -965,16 +965,16 @@
} }
/** /**
* Gets the category of the given function name. * Gets the category of the given `identifier`.
* *
* @private * @private
* @param {String} funcName The function name. * @param {String} identifier The identifier to query.
* @returns {String} Returns the function name's category. * @returns {String} Returns the identifier's category.
*/ */
function getCategory(funcName) { function getCategory(identifier) {
funcName = getRealName(funcName); identifier = getRealName(identifier);
return _.findKey(categoryMap, function(funcNames) { return _.findKey(categoryMap, function(identifiers) {
return _.contains(funcNames, funcName); return _.contains(identifiers, identifier);
}) || ''; }) || '';
} }
@@ -1154,13 +1154,13 @@
} }
/** /**
* Gets the names of functions in `source` belonging to the given `category`. * Gets the names of identifiers in `source` that belong to the given `category`.
* *
* @private * @private
* @param {String} category The category to filter by. * @param {String} category The category to filter by.
* @returns {Array} Returns a new array of function names belonging to the given category. * @returns {Array} Returns a new array of names.
*/ */
function getMethodsByCategory(category) { function getNamesByCategory(category) {
return categoryMap[category] || []; return categoryMap[category] || [];
} }
@@ -1605,6 +1605,25 @@
return source.replace(getMethodAssignments(source), ''); return source.replace(getMethodAssignments(source), '');
} }
/**
* Removes a given Lo-Dash property from `source`.
*
* @private
* @param {String} source The source to process.
* @param {String} propName The name of the property to remove.
* @returns {String} Returns the modified source.
*/
function removeProp(source, propName) {
return source.replace(RegExp(
multilineComment +
'(?: *|(.*?=))lodash\\.' + propName + '\\s*=[\\s\\S]+?' +
'(?:\\(function[\\s\\S]+?\\([^)]*\\)\\);\\n(?=\\n)|' +
'[;}]\\n(?=\\n(?!\\s*\\(func)))'
), function(match, prelude) {
return prelude ? 'undefined' : '';
});
}
/** /**
* Removes all pseudo private Lo-Dash properties from `source`. If a `propName` * Removes all pseudo private Lo-Dash properties from `source`. If a `propName`
* is specified, only the specified property is removed. * is specified, only the specified property is removed.
@@ -1933,17 +1952,6 @@
}); });
} }
/**
* Removes the `templateSettings` assignment from `source`.
*
* @private
* @param {String} source The source to inspect.
* @returns {String} Returns the modified source.
*/
function removeTemplateSettings(source) {
return source.replace(getTemplateSettings(source), '');
}
/** /**
* Removes a given variable from `source`. * Removes a given variable from `source`.
* *
@@ -2301,7 +2309,7 @@
var categories = _.intersection(funcNames, allCategories); var categories = _.intersection(funcNames, allCategories);
categories.forEach(function(category) { categories.forEach(function(category) {
var otherFuncs = getMethodsByCategory(category); var otherFuncs = getNamesByCategory(category);
// limit function names to those available for specific builds // limit function names to those available for specific builds
if (isBackbone) { if (isBackbone) {
@@ -3728,9 +3736,6 @@
].join('\n' + indent); ].join('\n' + indent);
}); });
} }
if (isExcluded('template') && !_.contains(includeProps, 'templateSettings')) {
source = removeTemplateSettings(source);
}
if (isExcluded('value')) { if (isExcluded('value')) {
source = removeLodashWrapper(source); source = removeLodashWrapper(source);
source = removeSpliceObjectsFix(source); source = removeSpliceObjectsFix(source);