decla-red/shared/src/helper/pretty-print.ts
2020-10-05 19:07:17 +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');