Permalink
Browse files

Make `_.toArray` work in legacy build.

  • Loading branch information...
jdalton committed Mar 25, 2013
1 parent 62766d3 commit bcf26884c6cd66388e416587f5662119a57e36e7
Showing with 17 additions and 0 deletions.
  1. +17 −0 build.js
View
@@ -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) {',

0 comments on commit bcf2688

Please sign in to comment.