Skip to content

Commit

Permalink
more elite code
Browse files Browse the repository at this point in the history
  • Loading branch information
oatkiller committed Jan 9, 2020
1 parent 31eddd3 commit 0e4a5a6
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,20 @@ function widthsOfProcessSubtrees(indexedProcessTree: IndexedProcessTree): Proces
return widths;
}

// bet sean loves this
/**
* TODO comments
*/
type ProcessWithWidthMetadata = {
process: ProcessEvent;
width: number;
} & (
| ({
| {
parent: ProcessEvent;
parentWidth: number;
} & ( // TODO bolete this
| { isOnlyChild: true; firstChildWidth: null; lastChildWidth: null }
| { isOnlyChild: false; firstChildWidth: number; lastChildWidth: number }
))
isOnlyChild: boolean;
firstChildWidth: number;
lastChildWidth: number;
}
| {
parent: null;
/* Without a parent, there is no parent width */
Expand Down Expand Up @@ -272,9 +274,8 @@ function* levelOrderWithWidths(
const siblings = indexedProcessTreeChildren(tree, parent);
if (siblings.length === 1) {
metadata.isOnlyChild = true;
// TODO, just make these === width
metadata.lastChildWidth = null;
metadata.firstChildWidth = null;
metadata.lastChildWidth = width;
metadata.firstChildWidth = width;
} else {
const firstChildWidth = widths.get(siblings[0]);
const lastChildWidth = widths.get(siblings[0]);
Expand Down

0 comments on commit 0e4a5a6

Please sign in to comment.