Function
formatJSObject
(o: { [key: string]: any })
Source from the content-addressed store, hash-verified
| 1 | import util from 'util'; |
| 2 | |
| 3 | export function formatJSObject(o: { [key: string]: any }): string { |
| 4 | try { |
| 5 | o = JSON.parse(JSON.stringify(o)); |
| 6 | } catch (e: any) { |
| 7 | throw new Error(`Cannot parse object as JSON: ${e.stack ? e.stack : e}`); |
| 8 | } |
| 9 | |
| 10 | return util.inspect(o, { |
| 11 | compact: false, |
| 12 | breakLength: Infinity, |
| 13 | depth: Infinity, |
| 14 | maxArrayLength: Infinity, |
| 15 | maxStringLength: Infinity, |
| 16 | }); |
| 17 | } |
Tested by
no test coverage detected