UNPKG

theme-editor-svelte

Version:
26 lines (25 loc) 651 B
export const capitalize = (str) => { const firstLetter = str.at(0); if (!firstLetter) return ''; return firstLetter.toUpperCase() + str.slice(1); }; export const normalizeName = (variable) => { return variable .replace(/--/g, '') .replace(/-/g, ' ') .split(' ') .map((word) => capitalize(word)) .join(' '); }; export const numberRegexp = /^(?<value>(?:\d+)?(?:\.\d+)?)(?<unit>[a-z]+)$/; export const customSerialization = { serialize: JSON.stringify, deserialize: (value) => { try { return JSON.parse(value); } catch (e) { } }, };