(day)
| 1 | function activityTable(day) { |
| 2 | let table = []; |
| 3 | for (let i = 0; i < 24; i++) table[i] = 0; |
| 4 | |
| 5 | return textFile("camera_logs.txt").then(files => { |
| 6 | return Promise.all(files.split("\n").map(name => { |
| 7 | return textFile(name).then(log => { |
| 8 | for (let timestamp of log.split("\n")) { |
| 9 | let date = new Date(Number(timestamp)); |
| 10 | if (date.getDay() == day) { |
| 11 | table[date.getHours()]++; |
| 12 | } |
| 13 | } |
| 14 | }); |
| 15 | })); |
| 16 | }).then(() => table); |
| 17 | } |
| 18 | |
| 19 | activityTable(6) |
| 20 | .then(table => console.log(activityGraph(table))); |