sdf-2d-demo/src/helper/pretty-print.ts
2020-10-19 12:22:08 +02:00

4 lines
194 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');