decla-red/frontend/src/scripts/helper/pretty-print.ts
2020-09-21 09:42:00 +02:00

4 lines
193 B
TypeScript

export const prettyPrint = (o: any): string =>
JSON.stringify(o, (_, v) => (v.toFixed ? Number(v.toFixed(3)) : v), ' ')
.replace(/("|,|{|^\n)/g, '')
.replace(/(\W*}\n?)+/g, '\n\n');