mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-05 09:27:49 +00:00
Make getDependants work with an array of method names.
Former-commit-id: 55f3721735d93e95da10bb3367f8478d861e683c
This commit is contained in:
18
build.js
18
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
|
* @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.
|
* @returns {Array} Returns an array of method dependants.
|
||||||
*/
|
*/
|
||||||
function getDependants(methodName) {
|
function getDependants(methodName) {
|
||||||
// iterate over the `dependencyMap`, adding the names of methods that
|
// iterate over the `dependencyMap`, adding names of methods
|
||||||
// have `methodName` as a dependency
|
// that have the `methodName` as a dependency
|
||||||
|
var methodNames = _.isArray(methodName) ? methodName : [methodName];
|
||||||
return _.reduce(dependencyMap, function(result, dependencies, otherName) {
|
return _.reduce(dependencyMap, function(result, dependencies, otherName) {
|
||||||
if (_.contains(dependencies, methodName)) {
|
if (_.some(methodNames, function(methodName) {
|
||||||
|
return _.contains(dependencies, methodName);
|
||||||
|
})) {
|
||||||
result.push(otherName);
|
result.push(otherName);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -737,13 +740,12 @@
|
|||||||
* plus any additional detected sub-dependencies.
|
* plus any additional detected sub-dependencies.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Array|String} methodName A single method name or array of
|
* @param {Array|String} methodName A method name or array of dependencies to query.
|
||||||
* dependencies to query.
|
|
||||||
* @param- {Object} [stackA=[]] Internally used track queried methods.
|
* @param- {Object} [stackA=[]] Internally used track queried methods.
|
||||||
* @returns {Array} Returns an array of method dependencies.
|
* @returns {Array} Returns an array of method dependencies.
|
||||||
*/
|
*/
|
||||||
function getDependencies(methodName, stack) {
|
function getDependencies(methodName, stack) {
|
||||||
var dependencies = Array.isArray(methodName) ? methodName : dependencyMap[methodName];
|
var dependencies = _.isArray(methodName) ? methodName : dependencyMap[methodName];
|
||||||
if (!dependencies) {
|
if (!dependencies) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user