Make _.toArray work in legacy build.

Former-commit-id: 36866e65670f563b587af51168db9f95f01ed248
This commit is contained in:
John-David Dalton
2013-03-25 08:21:43 -07:00
parent 244c8dc391
commit ffdac30b3c

View File

@@ -1145,6 +1145,7 @@
* @returns {String} Returns the modified source.
*/
function removeSupportNodeClass(source) {
source = removeFunction(source, 'isNode');
source = removeSupportProp(source, 'nodeClass');
// remove `support.nodeClass` from `shimIsPlainObject`
@@ -1751,6 +1752,7 @@
dependencyMap.pick = _.without(dependencyMap.pick, 'forIn', 'isObject');
dependencyMap.reduceRight = _.without(dependencyMap.reduceRight, 'isString');
dependencyMap.template = _.without(dependencyMap.template, 'keys', 'values');
dependencyMap.toArray.push('isArray', 'map');
dependencyMap.value = _.without(dependencyMap.value, 'isArray');
dependencyMap.where.push('find', 'isEmpty');
@@ -2320,6 +2322,21 @@
'}'
].join('\n'));
// replace `_.toArray`
if (useUnderscoreClone) {
source = replaceFunction(source, 'toArray', [
'function toArray(collection) {',
' if (isArray(collection)) {',
' return slice(collection);',
' }',
" if (collection && typeof collection.length == 'number') {",
' return map(collection);',
' }',
' return values(collection);',
'}'
].join('\n'));
}
// replace `_.uniq`
source = replaceFunction(source, 'uniq', [
'function uniq(array, isSorted, callback, thisArg) {',