-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.mjs
36 lines (27 loc) · 928 Bytes
/
index.mjs
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
import { fetch } from './fetchInput';
import Log from './log';
import days from './solutions/solutions';
console.log();
console.log(' Advent of Code 2018 ');
console.log(' https://adventofcode.com/2018 ');
console.log(' Author: Josip "Allypost" Igrec ');
console.log();
const promiseDays =
days
.map(Day => async () => {
const day = new Day();
process.stdout.write(`Day ${ day.DAY }: `);
const data = await fetch(day.DAY);
day.on('progress', (part, data) => Log.progress(data));
process.stdout.write('\tPart 1: ');
Log.result(await day.part1(data));
process.stdout.write('\tPart 2: ');
Log.result(await day.part2(data));
console.log();
return true;
});
(async () => {
for (const day of promiseDays)
await day();
console.log('Done!');
})();