Skip to content

Commit 2b14887

Browse files
committed
refactor: move getReexports
1 parent 340eb9e commit 2b14887

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

ui/src/lib/ws/middleware.js

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,35 @@ import * as actions from "./actions";
33
import { repoSlice } from "../store";
44
import Stomp from "stompjs";
55

6+
function getReexports({ id, pods }) {
7+
// Get the reexports available for the deck id. Those are from this deck's subdecks
8+
let reexports = Object.assign(
9+
{},
10+
...pods[id].children
11+
.filter(({ id }) => pods[id].type === "DECK" && !pods[id].thundar)
12+
.map(({ id, type }) => pods[id])
13+
.map((deck) =>
14+
Object.assign(
15+
{},
16+
...deck.children
17+
.filter(({ id }) => pods[id].type !== "DECK")
18+
.map(({ id }) => pods[id])
19+
.map((pod) => pod.reexports)
20+
)
21+
)
22+
);
23+
24+
// change reexport from name=>id to ns=>names
25+
let res = {};
26+
for (let [name, id] of Object.entries(reexports)) {
27+
if (!res[pods[id].ns]) {
28+
res[pods[id].ns] = [];
29+
}
30+
res[pods[id].ns].push(name);
31+
}
32+
return res;
33+
}
34+
635
function powerRun_racket({ id, storeAPI, socket }) {
736
let pods = storeAPI.getState().repo.pods;
837
let pod = pods[id];
@@ -90,35 +119,6 @@ ${struct_codes.join("\n")}
90119
);
91120
}
92121

93-
function getReexports({ id, pods }) {
94-
// Get the reexports available for the deck id. Those are from this deck's subdecks
95-
let reexports = Object.assign(
96-
{},
97-
...pods[id].children
98-
.filter(({ id }) => pods[id].type === "DECK" && !pods[id].thundar)
99-
.map(({ id, type }) => pods[id])
100-
.map((deck) =>
101-
Object.assign(
102-
{},
103-
...deck.children
104-
.filter(({ id }) => pods[id].type !== "DECK")
105-
.map(({ id }) => pods[id])
106-
.map((pod) => pod.reexports)
107-
)
108-
)
109-
);
110-
111-
// change reexport from name=>id to ns=>names
112-
let res = {};
113-
for (let [name, id] of Object.entries(reexports)) {
114-
if (!res[pods[id].ns]) {
115-
res[pods[id].ns] = [];
116-
}
117-
res[pods[id].ns].push(name);
118-
}
119-
return res;
120-
}
121-
122122
function powerRun_julia({ id, storeAPI, socket }) {
123123
let pods = storeAPI.getState().repo.pods;
124124
let pod = pods[id];

0 commit comments

Comments
 (0)