28 lines
593 B
JavaScript
28 lines
593 B
JavaScript
function u(n) {
|
|
return { title: n, options: [] };
|
|
}
|
|
function c(n, t) {
|
|
n.options.push({ id: crypto.randomUUID(), text: t, votes: [] });
|
|
}
|
|
function f(n, t, i) {
|
|
const o = n.options.find((s) => s.id === t);
|
|
return o ? o.votes.includes(i) : false;
|
|
}
|
|
function r(n, t, i) {
|
|
const o = n.options.find((s) => s.id === t);
|
|
o && (o.votes.includes(i) || o.votes.push(i));
|
|
}
|
|
function d(n, t, i) {
|
|
const o = n.options.find((e) => e.id === t);
|
|
if (!o) return;
|
|
const s = o.votes.indexOf(i);
|
|
s !== -1 && o.votes.splice(s, 1);
|
|
}
|
|
export {
|
|
c as a,
|
|
u as c,
|
|
f as h,
|
|
d as u,
|
|
r as v
|
|
};
|