From 355b2f09bf6ca7a930c2c06345f253cb343fd17b Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Mon, 20 May 2013 22:10:11 -0700 Subject: [PATCH] Make `getDependants` work with an array of method names. Former-commit-id: 55f3721735d93e95da10bb3367f8478d861e683c --- build.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/build.js b/build.js index b862eb6e0..c8e6a3822 100755 --- a/build.js +++ b/build.js @@ -714,17 +714,20 @@ } /** - * Gets an array of depenants for a method by a given name. + * Gets an array of depenants for the given method name(s). * * @private - * @param {String} methodName The method name. + * @param {String} methodName A method name or array of method names. * @returns {Array} Returns an array of method dependants. */ function getDependants(methodName) { - // iterate over the `dependencyMap`, adding the names of methods that - // have `methodName` as a dependency + // iterate over the `dependencyMap`, adding names of methods + // that have the `methodName` as a dependency + var methodNames = _.isArray(methodName) ? methodName : [methodName]; return _.reduce(dependencyMap, function(result, dependencies, otherName) { - if (_.contains(dependencies, methodName)) { + if (_.some(methodNames, function(methodName) { + return _.contains(dependencies, methodName); + })) { result.push(otherName); } return result; @@ -737,13 +740,12 @@ * plus any additional detected sub-dependencies. * * @private - * @param {Array|String} methodName A single method name or array of - * dependencies to query. + * @param {Array|String} methodName A method name or array of dependencies to query. * @param- {Object} [stackA=[]] Internally used track queried methods. * @returns {Array} Returns an array of method dependencies. */ function getDependencies(methodName, stack) { - var dependencies = Array.isArray(methodName) ? methodName : dependencyMap[methodName]; + var dependencies = _.isArray(methodName) ? methodName : dependencyMap[methodName]; if (!dependencies) { return []; }