Skip to content

Commit

Permalink
packager: getInverseDependencies: @flow
Browse files Browse the repository at this point in the history
Reviewed By: davidaurelio

Differential Revision: D5052190

fbshipit-source-id: ebfa2a698233e914b016fe50f790ee8aa758c4f2
  • Loading branch information
Jean Lauliac authored and facebook-github-bot committed May 12, 2017
1 parent d0c2b06 commit 174f84c
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions packager/src/node-haste/lib/getInverseDependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,27 @@
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @flow
* @format
*/

'use strict';

function resolveModuleRequires(resolutionResponse, module) {
import type ResolutionResponse from '../DependencyGraph/ResolutionResponse';

function resolveModuleRequires<TModule: {hash(): string}, TOptions>(
resolutionResponse: ResolutionResponse<TModule, TOptions>,
module: TModule,
) {
const pairs = resolutionResponse.getResolvedDependencyPairs(module);
return pairs
? pairs.map(([, dependencyModule]) => dependencyModule)
: [];
return pairs ? pairs.map(([, dependencyModule]) => dependencyModule) : [];
}

function getModuleDependents(cache, module) {
function getModuleDependents<TModule>(
cache: Map<TModule, Set<TModule>>,
module: TModule,
): Set<TModule> {
let dependents = cache.get(module);
if (!dependents) {
dependents = new Set();
Expand All @@ -27,7 +37,9 @@ function getModuleDependents(cache, module) {
/**
* Returns an object that indicates in which module each module is required.
*/
function getInverseDependencies(resolutionResponse) {
function getInverseDependencies<TModule: {hash(): string}, TOptions>(
resolutionResponse: ResolutionResponse<TModule, TOptions>,
): Map<TModule, Set<TModule>> {
const cache = new Map();

resolutionResponse.dependencies.forEach(module => {
Expand Down

0 comments on commit 174f84c

Please sign in to comment.