UNPKG

@sigiljs/sigil

Version:

TypeScript-first Node.js HTTP framework offering schema-driven routing, modifier-based middleware, plugin extensibility, and flexible response templating

22 lines (21 loc) 481 B
function t(e, r) { if (typeof e == "string") return e; try { return JSON.stringify(e, r?.replacer, r?.space); } catch (n) { if (r?.throw) throw new Error("Cannot serialize json: " + n?.message); return r?.fallback ? String(r?.fallback) : null; } } function a(e, r) { try { return JSON.parse(e); } catch (n) { if (r) throw new Error("Cannot deserialize json: " + n?.message); return null; } } export { a as jsonParse, t as jsonStringify };