Remove props related to _.sortBy if the method isn't included in a given build.

Former-commit-id: b3da4dab8257b9001b7458263a28bf22b0a2c831
This commit is contained in:
John-David Dalton
2013-06-04 09:12:11 -07:00
parent 2c59dcd929
commit 2c950f74bc

View File

@@ -1058,8 +1058,8 @@
return source; return source;
} }
// remove data object property assignment // remove data object property assignment
var modified = snippet.replace(RegExp("^(?: *\\/\\/.*\\n)* *data\\." + identifier + " *= *(.+\\n+)", 'm'), function(match, postlude) { var modified = snippet.replace(RegExp("^(?: *\\/\\/.*\\n)* *(\\w+)\\." + identifier + " *= *(.+\\n+)", 'm'), function(match, object, postlude) {
return /\bdata\b/.test(postlude) ? postlude : ''; return RegExp('\\b' + object + '\\.').test(postlude) ? postlude : '';
}); });
source = source.replace(snippet, function() { source = source.replace(snippet, function() {
@@ -1077,23 +1077,31 @@
.replace(/,(?=\s*\))/, ''); .replace(/,(?=\s*\))/, '');
}); });
return removeFromGetObject(source, identifier); return removeFromObjectPoolFunctions(source, identifier);
} }
/** /**
* Removes all references to `identifier` from `getObject` in `source`. * Removes all references to `identifier` from the `objectPool` functions in `source`.
* *
* @private * @private
* @param {String} source The source to process. * @param {String} source The source to process.
* @param {String} identifier The name of the property to remove. * @param {String} identifier The name of the property to remove.
* @returns {String} Returns the modified source. * @returns {String} Returns the modified source.
*/ */
function removeFromGetObject(source, identifier) { function removeFromObjectPoolFunctions(source, identifier) {
return source.replace(matchFunction(source, 'getObject'), function(match) { _.each(['getObject', 'releaseObject'], function(methodName) {
return match source = source.replace(matchFunction(source, methodName), function(match) {
.replace(RegExp("^(?: *\\/\\/.*\\n)* *'" + identifier + "':.+\\n+", 'm'), '') // remove object property assignments
.replace(/,(?=\s*})/, ''); return match
.replace(RegExp("^(?: *\\/\\/.*\\n)* *'" + identifier + "':.+\\n+", 'm'), '')
.replace(/,(?=\s*})/, '')
.replace(RegExp("^(?: *\\/\\/.*\\n)* *(\\w+)\\." + identifier + " *= *(.+\\n+)", 'm'), function(match, object, postlude) {
return RegExp('\\b' + object + '\\.').test(postlude) ? postlude : '';
});
});
}); });
return source;
} }
/** /**
@@ -3025,7 +3033,7 @@
source = removeFunction(source, 'createIterator'); source = removeFunction(source, 'createIterator');
iteratorOptions.forEach(function(prop) { iteratorOptions.forEach(function(prop) {
source = removeFromGetObject(source, prop); source = removeFromObjectPoolFunctions(source, prop);
}); });
// inline all functions defined with `createIterator` // inline all functions defined with `createIterator`
@@ -3300,6 +3308,11 @@
source = removeVar(source, 'reLeadingSpacesAndZeros'); source = removeVar(source, 'reLeadingSpacesAndZeros');
source = removeVar(source, 'whitespace'); source = removeVar(source, 'whitespace');
} }
if (isRemoved(source, 'sortBy')) {
source = removeFromObjectPoolFunctions(source, 'criteria');
source = removeFromObjectPoolFunctions(source, 'index');
source = removeFromObjectPoolFunctions(source, 'value');
}
if (isRemoved(source, 'template')) { if (isRemoved(source, 'template')) {
// remove `templateSettings` assignment // remove `templateSettings` assignment
source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *lodash\.templateSettings[\s\S]+?};\n/, ''); source = source.replace(/(?:\n +\/\*[^*]*\*+(?:[^\/][^*]*\*+)*\/)?\n *lodash\.templateSettings[\s\S]+?};\n/, '');