fix: cycles

This commit is contained in:
cha0s 2020-06-22 04:53:01 -05:00
parent 7567efe48e
commit b9b956c408

View File

@ -22,7 +22,7 @@ export class Context {
static allTypesInvertedDigraph() { static allTypesInvertedDigraph() {
const digraph = this.allTypesDigraph(); const digraph = this.allTypesDigraph();
const inverted = {}; let inverted = {};
const fromTypes = Object.keys(digraph); const fromTypes = Object.keys(digraph);
for (let i = 0; i < fromTypes.length; i++) { for (let i = 0; i < fromTypes.length; i++) {
const fromType = fromTypes[i]; const fromType = fromTypes[i];
@ -33,7 +33,12 @@ export class Context {
inverted[toType][fromType] = true; inverted[toType][fromType] = true;
} }
} }
return mapObject(inverted, (types) => Object.keys(types)); inverted = mapObject(inverted, (types) => Object.keys(types));
inverted = mapObject(
inverted,
(types) => arrayUnique(flatten(types.map((type) => (inverted[type] || []).concat(type)))),
);
return inverted;
} }
static describe(description, fn) { static describe(description, fn) {