Skip to content
This repository
Browse code

Make `_.toArray` work in legacy build.

  • Loading branch information...
commit bcf26884c6cd66388e416587f5662119a57e36e7 1 parent 62766d3
John-David Dalton authored March 25, 2013

Showing 1 changed file with 17 additions and 0 deletions. Show diff stats Hide diff stats

  1. 17  build.js
17  build.js
@@ -1145,6 +1145,7 @@
1145 1145
    * @returns {String} Returns the modified source.
1146 1146
    */
1147 1147
   function removeSupportNodeClass(source) {
  1148
+    source = removeFunction(source, 'isNode');
1148 1149
     source = removeSupportProp(source, 'nodeClass');
1149 1150
 
1150 1151
     // remove `support.nodeClass` from `shimIsPlainObject`
@@ -1751,6 +1752,7 @@
1751 1752
         dependencyMap.pick = _.without(dependencyMap.pick, 'forIn', 'isObject');
1752 1753
         dependencyMap.reduceRight = _.without(dependencyMap.reduceRight, 'isString');
1753 1754
         dependencyMap.template = _.without(dependencyMap.template, 'keys', 'values');
  1755
+        dependencyMap.toArray.push('isArray', 'map');
1754 1756
         dependencyMap.value = _.without(dependencyMap.value, 'isArray');
1755 1757
         dependencyMap.where.push('find', 'isEmpty');
1756 1758
 
@@ -2320,6 +2322,21 @@
2320 2322
           '}'
2321 2323
         ].join('\n'));
2322 2324
 
  2325
+        // replace `_.toArray`
  2326
+        if (useUnderscoreClone) {
  2327
+          source = replaceFunction(source, 'toArray', [
  2328
+            'function toArray(collection) {',
  2329
+            '  if (isArray(collection)) {',
  2330
+            '    return slice(collection);',
  2331
+            '  }',
  2332
+            "  if (collection && typeof collection.length == 'number') {",
  2333
+            '    return map(collection);',
  2334
+            '  }',
  2335
+            '  return values(collection);',
  2336
+            '}'
  2337
+          ].join('\n'));
  2338
+        }
  2339
+
2323 2340
         // replace `_.uniq`
2324 2341
         source = replaceFunction(source, 'uniq', [
2325 2342
           'function uniq(array, isSorted, callback, thisArg) {',

0 notes on commit bcf2688

Please sign in to comment.
Something went wrong with that request. Please try again.