Reduce the size of lodash.underscore.min.js.

Former-commit-id: fd7d512e104c6325a38a7d0e09015235ca69b1da
This commit is contained in:
John-David Dalton
2012-09-30 22:36:57 -07:00
parent db1a87d10c
commit ffe02ad7bf
2 changed files with 43 additions and 32 deletions

View File

@@ -1050,6 +1050,18 @@
source = removeVar(source, 'arrayLikeClasses');
source = removeVar(source, 'cloneableClasses');
// remove large array optimizations from `cachedContains`
source = source.replace(/( +)function cachedContains[\s\S]+?\n\1}/, [
' function cachedContains(array, fromIndex) {',
' return function(value) {',
' return indexOf(array, value, fromIndex || 0) > -1;',
' };',
' }'
].join('\n'));
// reduce the number of arguments passed to `cachedContains` from 3 to 2
source = source.replace(/(cachedContains\(\w+, *\w+), *\w+/g, '$1');
// replace `arrayLikeClasses` in `_.isEmpty`
source = source.replace(/'if *\(arrayLikeClasses[\s\S]+?' \|\|\\n/, "'if (isArray(value) || className == stringClass ||");