Skip to content

Commit 3a3adb0

Browse files
committed
simplify
1 parent 6c11b6f commit 3a3adb0

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

test/plots/stocks-index.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,9 @@ function formatChange(x) {
88
}
99

1010
export default async function() {
11-
const [aapl, amzn, goog, ibm] = await Promise.all([
12-
d3.csv("data/aapl.csv", d3.autoType),
13-
d3.csv("data/amzn.csv", d3.autoType),
14-
d3.csv("data/goog.csv", d3.autoType),
15-
d3.csv("data/ibm.csv", d3.autoType)
16-
]);
17-
const stocks = [["AAPL", aapl], ["AMZN", amzn], ["GOOG", goog], ["IBM", ibm]]
18-
.flatMap(([symbol, data]) => {
11+
const stocks = (await Promise.all(["aapl", "amzn", "goog", "ibm"].map(async symbol => {
12+
return [symbol.toUpperCase(), await d3.csv(`data/${symbol}.csv`, d3.autoType)];
13+
}))).flatMap(([symbol, data]) => {
1914
const [{Close: basis}] = data;
2015
return data.map(({Date, Close}) => ({
2116
symbol,

0 commit comments

Comments
 (0)