/** * Utility functions */ export const rand = (n) => Math.random() * n; export const randint = (limit) => Math.floor(Math.random() * limit); export const choice = (list) => list[randint(list.length)]; export const mod = (n, m) => n - m * Math.floor(n / m); export const pad = (value) => (value < 10 ? "0" + value : value); export const capitalizeWord = (text = "") => text ? text.charAt(0).toUpperCase() + text.slice(1) : ""; export const capitalize = (text = "") => String(text || "") .split(" ") .map(capitalizeWord) .join(" ");