MCPcopy Index your code
hub / github.com/ptmt/react-native-macos / Graph

Function Graph

packager/src/ModuleGraph/Graph.js:58–98  ·  view source on GitHub ↗
(entryPoints, platform, options, callback = noop)

Source from the content-addressed store, hash-verified

56
57exports.create = function create(resolve: ResolveFn, load: LoadFn): GraphFn {
58 function Graph(entryPoints, platform, options, callback = noop) {
59 const {
60 log = (console: any),
61 optimize = false,
62 skip,
63 } = options || NO_OPTIONS;
64
65 if (typeof platform !== 'string') {
66 log.error('`Graph`, called without a platform');
67 callback(Error('The target platform has to be passed'));
68 return;
69 }
70
71 const loadQueue: LoadQueue = queue(seq(
72 ({id, parent}, cb) => resolve(id, parent, platform, options || NO_OPTIONS, cb),
73 memoize((file, cb) => load(file, {log, optimize}, cb)),
74 ), Number.MAX_SAFE_INTEGER);
75
76 const {collect, loadModule} = createGraphHelpers(loadQueue, skip);
77
78 loadQueue.drain = () => {
79 loadQueue.kill();
80 callback(null, collect());
81 };
82 loadQueue.error = error => {
83 loadQueue.error = noop;
84 loadQueue.kill();
85 callback(error);
86 };
87
88 let i = 0;
89 for (const entryPoint of entryPoints) {
90 loadModule(entryPoint, null, i++);
91 }
92
93 if (i === 0) {
94 log.error('`Graph` called without any entry points');
95 loadQueue.kill();
96 callback(Error('At least one entry point has to be passed.'));
97 }
98 }
99
100 return Graph;
101};

Callers

nothing calls this directly

Calls 6

createGraphHelpersFunction · 0.85
collectFunction · 0.85
killMethod · 0.80
loadModuleFunction · 0.70
errorMethod · 0.65
callbackFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…