From ffdac30b3c6693c32adbb01c032acf4040459a6a Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 25 Mar 2013 08:21:43 -0700 Subject: [PATCH] Make `_.toArray` work in legacy build. Former-commit-id: 36866e65670f563b587af51168db9f95f01ed248 --- build.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/build.js b/build.js index 9daeae5be..87f41f426 100755 --- a/build.js +++ b/build.js @@ -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) {',