(arr: T[], indent: Indent, baseIndent: string)
| 12 | } |
| 13 | |
| 14 | function serializeArray<T>(arr: T[], indent: Indent, baseIndent: string): string { |
| 15 | let output = '['; |
| 16 | const separator = indent ? `\n${baseIndent}${indent}` : ''; |
| 17 | for (let i = 0; i < arr.length; i++) { |
| 18 | const key = arr[i]; |
| 19 | output += `${i > 0 ? ',' : ''}${separator}${serialize(key, indent, baseIndent + indent)}`; |
| 20 | } |
| 21 | return `${output}${indent ? `\n${baseIndent}` : ''}]`; |
| 22 | } |
| 23 | |
| 24 | function serializeObject(obj: object, indent: Indent, baseIndent: string): string { |
| 25 | let output = '{'; |