]> git.r.bdr.sh - rbdr/corona-regeln/blob - src/lib/rule_generator.js
Add license
[rbdr/corona-regeln] / src / lib / rule_generator.js
1 import Rules from './rules';
2
3 const internals = {
4
5 dates: [
6 'today',
7 'tomorrow',
8 'next friday',
9 'next wednesday',
10 'last thursday',
11 'last tuesday',
12 'the next day divisible by 7',
13 'this afternoon',
14 'next fiscal quarter',
15 ],
16
17 rules: [
18 ...Rules
19 ],
20 currentIndex: 0
21 }
22
23 export const generate = async function () {
24
25 const rule = internals.rules[internals.currentIndex];
26 const time = internals.dates[Math.floor(Math.random() * internals.dates.length)];
27 internals.currentIndex = (internals.currentIndex + 1) % internals.rules.length
28 return {
29 rule: rule(),
30 time
31 }
32 }