@crazy-thursday/use-kfc
Version:
generate crazy thursday info hooks!
49 lines (48 loc) • 1.34 kB
JavaScript
import { useRef as u, useMemo as y } from "react";
function T() {
return new Date().getDay() === 4;
}
function A(e) {
return Math.floor(Math.random() * e);
}
function I(e) {
const n = u(e);
return y(() => n.current !== e ? (n.current = e, e) : n.current, [e]);
}
const L = {
id: "0000TURSDAY_KFC",
content: "crazy thursday, vme50!"
};
function k(e) {
var d, s, l, f;
const c = u(T()).current || (e == null ? void 0 : e.skipDayCheck), t = u(), g = I(
(d = e == null ? void 0 : e.refreshSignal) != null ? d : t.current
), a = A(
(f = (l = (s = e == null ? void 0 : e.slogenList) == null ? void 0 : s.filter((r) => r.id !== t.current)) == null ? void 0 : l.length) != null ? f : 0
);
return c || console.error("today is not thursday!!!"), {
slogen: y(() => {
if (!c)
return "";
const { slogenList: r } = e != null ? e : {};
if (Array.isArray(r) && r.length) {
let h = r[0];
r.length > 1 && (h = r.filter((D) => D.id !== t.current)[a]);
const { content: m, id: R } = h;
return t.current = R, m;
}
return L.content;
}, [a, g])
};
}
function o(e) {
return Object.values(e);
}
export {
k as default,
I as useManualRefresh,
o as useParseSlogen,
A as useRandomIndex,
T as useThursday
};
//# sourceMappingURL=use-kfc.es.js.map