]>
Commit | Line | Data |
---|---|---|
1 | import { readable } from 'svelte/store'; | |
2 | import { generate } from '$lib/rule_generator'; | |
3 | ||
4 | const internals = { | |
5 | ruleCount: 4 | |
6 | }; | |
7 | ||
8 | export const getRules = function () { | |
9 | ||
10 | return readable([], function (set) { | |
11 | ||
12 | (async function() { | |
13 | ||
14 | const rules = []; | |
15 | for (let i = 0; i < internals.ruleCount; ++i) { | |
16 | rules.push(await generate()); | |
17 | } | |
18 | ||
19 | set(rules.sort(() => Math.random() - 0.5)); | |
20 | })(); | |
21 | ||
22 | return function stop() {}; | |
23 | }); | |
24 | }; |