Move _.isArguments fallback noArgsClass work into removeNoArgsClass in build.js.

Former-commit-id: 3627e59c65b67a61fc5ee04166004e400d816d13
This commit is contained in:
John-David Dalton
2013-02-09 19:36:10 -08:00
parent 77804907b6
commit 1b27834c41

View File

@@ -716,7 +716,7 @@
* @returns {String} Returns the `isArguments` fallback.
*/
function getIsArgumentsFallback(source) {
return (source.match(/(?:\s*\/\/.*)*\n( *)if *\(noArgsClass\)[\s\S]+?};\n\1}/) || [''])[0];
return (source.match(/(?:\s*\/\/.*)*\n( *)if *\((?:noArgsClass|!isArguments)[\s\S]+?};\n\1}/) || [''])[0];
}
/**
@@ -1064,6 +1064,11 @@
function removeNoArgsClass(source) {
source = removeVar(source, 'noArgsClass');
// replace `noArgsClass` in the `_.isArguments` fallback
source = source.replace(getIsArgumentsFallback(source), function(match) {
return match.replace(/noArgsClass/g, '!isArguments(arguments)');
});
// remove `noArgsClass` from `_.isEmpty`
source = source.replace(matchFunction(source, 'isEmpty'), function(match) {
return match.replace(/ *\|\| *\(noArgsClass *&&[^)]+?\)\)/g, '');
@@ -2185,11 +2190,6 @@
}
});
// replace `noArgsClass` in the `_.isArguments` fallback
source = source.replace(getIsArgumentsFallback(source), function(match) {
return match.replace(/noArgsClass/g, '!isArguments(arguments)');
});
// remove chainability from `each` and `_.forEach`
_.each(['each', 'forEach'], function(methodName) {
source = source.replace(matchFunction(source, methodName), function(match) {