-
Notifications
You must be signed in to change notification settings - Fork 326
/
data.js
66 lines (56 loc) · 1.73 KB
/
data.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//import history from '!json!../assets/data/history.json'
import metadata from '!json!../assets/data/metadata.json'
// Loading latest data in the main bundle itself
import latestSeasonData from '!json!../assets/data/season-latest.json'
// import latestScoresData from '!json!../assets/data/scores-latest.json'
import latestDistData from '!json!../assets/data/distributions/season-latest-nat.json'
import incCaseSeasonData from '!json!../assets/data/season-Incident Cases.json'
import incDeathSeasonData from '!json!../assets/data/season-Incident Deaths.json'
const seasonDataCtx = require.context(
'file-loader!../assets/data/',
false,
/^\.\/season.*\.json$/
)
// const scoresDataCtx = require.context(
// 'file-loader!../assets/data/',
// false,
// /^\.\/scores.*\.json$/
// )
const distDataCtx = require.context(
'file-loader!../assets/data/distributions/',
false,
/^\.\/.*\.json$/
)
const seasonDataUrls = seasonDataCtx.keys().reduce((acc, key) => {
if (key.startsWith('./season-')) {
// Identifier is like '2013-2014'
acc[key.slice(9, -5)] = seasonDataCtx(key)
}
return acc
}, {})
// const scoresDataUrls = scoresDataCtx.keys().reduce((acc, key) => {
// if (key.startsWith('./scores-')) {
// // Identifier is like '2013-2014'
// acc[key.slice(9, -5)] = scoresDataCtx(key)
// }
// return acc
// }, {})
const distDataUrls = distDataCtx.keys().reduce((acc, key) => {
if (key.startsWith('./season-')) {
// Identifier is like '2013-2014-hhs10'
acc[key.slice(9, -5)] = distDataCtx(key)
}
return acc
}, {})
export {
seasonDataUrls,
// scoresDataUrls,
distDataUrls,
latestSeasonData,
// latestScoresData,
latestDistData,
incCaseSeasonData,
incDeathSeasonData,
//history,
metadata
}