(obj, level = 0)
| 29 | } |
| 30 | |
| 31 | function stringifyObject(obj, level = 0) { |
| 32 | if (typeof obj !== 'object') return obj; |
| 33 | const indent = ' '.repeat(level); |
| 34 | const o = Object.keys(obj).map(key => { |
| 35 | const v = stringifyObject(obj[key], level + 1); |
| 36 | return `\n${indent} ${property(null, key)}: ${v}`; |
| 37 | }); |
| 38 | return `{${o.join(',')}\n${indent}}`; |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Compile a collection of messages into an ES module. |