lib/lbt/graph/topologicalSort.js
function createDependencyGraph(pool, moduleNames, indegreeOnly) {
	const graph = Object.create(null);

	const promises = moduleNames.map( (moduleName) => {
		return pool.getModuleInfo(moduleName).
			then( (module) => {
				let node = graph[moduleName];
				if ( node == null ) {
					node = new GraphNode(moduleName, indegreeOnly);
					graph[moduleName] = node;
				}
				const p = module.dependencies.map( function(dep) {
					if ( module.isConditionalDependency(dep) ) {
						return;
					}
					return pool.getModuleInfo(dep).then( (depModule) => {
						if ( moduleNames.indexOf(dep) >= 0 ) {
							let depNode = graph[dep];
							if ( depNode == null ) {
								depNode = new GraphNode(dep, indegreeOnly);
								graph[dep] = depNode;
							}
							node.outgoing.push(depNode);
							if ( indegreeOnly ) {
								depNode.indegree++;
							} else {
								depNode.incoming.push(node);
							}
						}
					}, (erro) => null);
				});
				return Promise.all(p);
			}, (err) => {
				log.error("module %s not found in pool", moduleName);
			});
	});

	return Promise.all(promises).then(function() {
		// if ( trace.isTrace() ) trace.trace("initial module dependency graph: %s", dumpGraph(graph, moduleNames));
		return graph;
	});
}
function createDependencyGraph(pool, moduleNames, indegreeOnly) {
	const graph = Object.create(null);

	const promises = moduleNames.map( (moduleName) => {
		return pool.getModuleInfo(moduleName).
			then( (module) => {
				let node = graph[moduleName];
				if ( node == null ) {
					node = new GraphNode(moduleName, indegreeOnly);
					graph[moduleName] = node;
				}
				const p = module.dependencies.map( function(dep) {
					if ( module.isConditionalDependency(dep) ) {
						return;
					}
					return pool.getModuleInfo(dep).then( (depModule) => {
						if ( moduleNames.indexOf(dep) >= 0 ) {
							let depNode = graph[dep];
							if ( depNode == null ) {
								depNode = new GraphNode(dep, indegreeOnly);
								graph[dep] = depNode;
							}
							node.outgoing.push(depNode);
							if ( indegreeOnly ) {
								depNode.indegree++;
							} else {
								depNode.incoming.push(node);
							}
						}
					}, (erro) => null);
				});
				return Promise.all(p);
			}, (err) => {
				log.error("module %s not found in pool", moduleName);
			});
	});

	return Promise.all(promises).then(function() {
		// if ( trace.isTrace() ) trace.trace("initial module dependency graph: %s", dumpGraph(graph, moduleNames));
		return graph;
	});
}
function createDependencyGraph ( pool , moduleNames , indegreeOnly ) { const graph = Object . create ( null ) ; const promises = moduleNames . map ( ( moduleName ) => { return pool . getModuleInfo ( moduleName ) . then ( ( module ) => { let node = graph [ moduleName ] ; if ( node == null ) { node = new GraphNode ( moduleName , indegreeOnly ) ; graph [ moduleName ] = node ; } const p = module . dependencies . map ( function ( dep ) { if ( module . isConditionalDependency ( dep ) ) { return ; } return pool . getModuleInfo ( dep ) . then ( ( depModule ) => { if ( moduleNames . indexOf ( dep ) >= 0 ) { let depNode = graph [ dep ] ; if ( depNode == null ) { depNode = new GraphNode ( dep , indegreeOnly ) ; graph [ dep ] = depNode ; } node . outgoing . push ( depNode ) ; if ( indegreeOnly ) { depNode . indegree ++ ; } else { depNode . incoming . push ( node ) ; } } } , ( erro ) => null ) ; } ) ; return Promise . all ( p ) ; } , ( err ) => { log . error ( "module %s not found in pool" , moduleName ) ; } ) ; } ) ; return Promise . all ( promises ) . then ( function ( ) { // if ( trace.isTrace() ) trace.trace("initial module dependency graph: %s", dumpGraph(graph, moduleNames)); return graph ; } ) ; }
Creates a dependency graph from the given moduleNames.
Ignores modules not in the pool

@param {ResourcePool} pool
@param {string[]} moduleNames
@param {boolean} indegreeOnly
@returns {Promise<Object>}
@private
Creates a dependency graph from the given moduleNames . Ignores modules not in the pool