1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | exports.getMemoizedDepTree = exports.memoize = void 0;
|
4 | function memoize(nodeId, memoizationMap, depTree, partitionedCycles) {
|
5 | const { cyclesStartWithThisNode, cyclesWithThisNode } = partitionedCycles;
|
6 | if (cyclesStartWithThisNode.length > 0) {
|
7 | const cycleNodeIds = new Set(...cyclesStartWithThisNode);
|
8 | memoizationMap.set(nodeId, { depTree, cycleNodeIds });
|
9 | }
|
10 | else if (cyclesWithThisNode.length === 0) {
|
11 | memoizationMap.set(nodeId, { depTree });
|
12 | }
|
13 |
|
14 | }
|
15 | exports.memoize = memoize;
|
16 | function getMemoizedDepTree(nodeId, ancestors, memoizationMap) {
|
17 | if (!memoizationMap.has(nodeId))
|
18 | return null;
|
19 | const { depTree, cycleNodeIds } = memoizationMap.get(nodeId);
|
20 | if (!cycleNodeIds)
|
21 | return depTree;
|
22 | const ancestorsArePartOfTheCycle = ancestors.some((nodeId) => cycleNodeIds.has(nodeId));
|
23 | return ancestorsArePartOfTheCycle ? null : depTree;
|
24 | }
|
25 | exports.getMemoizedDepTree = getMemoizedDepTree;
|
26 |
|
\ | No newline at end of file |