aboutsummaryrefslogtreecommitdiff
path: root/src/lib/stores/rules.js
blob: 8c2755eda331e0fb1477b1df887992802a9f85d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import { readable } from 'svelte/store';
import { generate } from '$lib/rule_generator';

const internals = {
	ruleCount: 4
};

export const getRules = function () {

	return readable([], function (set) {

		(async function() {
			
			const rules = [];
			for (let i = 0; i < internals.ruleCount; ++i) {
				rules.push(await generate());
			}

			set(rules.sort(() => Math.random() - 0.5));
		})();
		
		return function stop() {};
	});
};