UNPKG

sveltekit-superforms

Version:

Making SvelteKit validation and displaying of forms easier than ever!

18 lines (17 loc) 457 B
export function splitPath(path) { return path .toString() .split(/[[\].]+/) .filter((p) => p); } export function mergePath(path) { return path.reduce((acc, next) => { if (typeof next === 'number' || !isNaN(parseInt(String(next), 10))) acc += `[${String(next)}]`; else if (!acc) acc += String(next); else acc += `.${String(next)}`; return acc; }, ''); }