mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-09 02:17:50 +00:00
Allow getDependencies and getDependants to be used with Array#map and cleanup expand in build.js.
Former-commit-id: b05ca0cdb9f9b8db4a0503a126e85d902f5bf7b1
This commit is contained in:
25
build.js
25
build.js
@@ -1189,6 +1189,12 @@
|
|||||||
* @returns {Array} Returns an array of function dependants.
|
* @returns {Array} Returns an array of function dependants.
|
||||||
*/
|
*/
|
||||||
function getDependants(funcName, isShallow, stack) {
|
function getDependants(funcName, isShallow, stack) {
|
||||||
|
// allows working with ES5 Array methods without using their callback
|
||||||
|
// arguments for `isShallow` and `stack`
|
||||||
|
if (typeof isShallow != 'boolean' && isShallow != null) {
|
||||||
|
isShallow = false;
|
||||||
|
stack = null;
|
||||||
|
}
|
||||||
var funcNames = _.isArray(funcName) ? funcName : [funcName];
|
var funcNames = _.isArray(funcName) ? funcName : [funcName];
|
||||||
stack || (stack = []);
|
stack || (stack = []);
|
||||||
|
|
||||||
@@ -1226,6 +1232,11 @@
|
|||||||
if (!deps || !deps.length) {
|
if (!deps || !deps.length) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
// juggle arguments to allow working with ES5 Array methods
|
||||||
|
if (typeof isShallow != 'boolean' && isShallow != null) {
|
||||||
|
isShallow = false;
|
||||||
|
stack = null;
|
||||||
|
}
|
||||||
if (isShallow) {
|
if (isShallow) {
|
||||||
return deps.slice();
|
return deps.slice();
|
||||||
}
|
}
|
||||||
@@ -2860,16 +2871,17 @@
|
|||||||
}());
|
}());
|
||||||
|
|
||||||
if (!isNoDep) {
|
if (!isNoDep) {
|
||||||
|
// add properties, variables, and their function dependencies to include in the build
|
||||||
(function() {
|
(function() {
|
||||||
function expand(result, depMap, funcNames, stack) {
|
function expand(result, depMap, funcNames, stack) {
|
||||||
stack || (stack = []);
|
stack || (stack = []);
|
||||||
return _.uniq(_.transform(funcNames || depMap, function(result, identifiers, funcName) {
|
return _.uniq(_.reduce(funcNames || depMap, function(result, identifiers, funcName) {
|
||||||
// juggle arguments
|
// juggle arguments
|
||||||
if (funcNames) {
|
if (funcNames) {
|
||||||
funcName = identifiers;
|
funcName = identifiers;
|
||||||
identifiers = depMap[funcName] || [];
|
identifiers = depMap[funcName] || [];
|
||||||
}
|
}
|
||||||
if (!_.contains(stack, funcName) && _.contains(buildFuncs, funcName)) {
|
if (!_.contains(stack, funcName) && (funcNames || _.contains(buildFuncs, funcName))) {
|
||||||
var deps = _.uniq(_.transform(identifiers, function(deps, identifier) {
|
var deps = _.uniq(_.transform(identifiers, function(deps, identifier) {
|
||||||
push.apply(deps, getDependencies(identifier));
|
push.apply(deps, getDependencies(identifier));
|
||||||
}));
|
}));
|
||||||
@@ -2878,15 +2890,14 @@
|
|||||||
push.apply(result, identifiers);
|
push.apply(result, identifiers);
|
||||||
|
|
||||||
buildFuncs = _.union(buildFuncs, deps);
|
buildFuncs = _.union(buildFuncs, deps);
|
||||||
expand(result, depMap, deps);
|
result = expand(result, depMap, deps);
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
}, result));
|
}, result));
|
||||||
}
|
}
|
||||||
// add properties to include in the build
|
|
||||||
expand(includeProps, propDependencyMap);
|
|
||||||
|
|
||||||
// add variables to include in the build
|
includeProps = expand(includeProps, propDependencyMap);
|
||||||
expand(includeVars, varDependencyMap);
|
includeVars = expand(includeVars, varDependencyMap);
|
||||||
}());
|
}());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user