(value, indent)
| 106 | } |
| 107 | |
| 108 | function prettyPrintValue (value, indent) { |
| 109 | let type = typeof value; |
| 110 | |
| 111 | switch (type) { |
| 112 | case "string": |
| 113 | return JSON.stringify(value); |
| 114 | |
| 115 | case "number": |
| 116 | case "boolean": |
| 117 | case "undefined": |
| 118 | case "symbol": |
| 119 | return String(value); |
| 120 | |
| 121 | case "function": |
| 122 | return `[function ${value.name}]`; |
| 123 | |
| 124 | default: |
| 125 | if (value === null) { |
| 126 | return "null"; |
| 127 | } |
| 128 | else if (typeof value.toJSON === "function") { |
| 129 | return prettyPrintValue(value.toJSON(), indent); |
| 130 | } |
| 131 | else { |
| 132 | let str = String(value); |
| 133 | if (str === "[object Object]") { |
| 134 | return prettyPrint(value, `${indent} `); |
| 135 | } |
| 136 | else { |
| 137 | return str; |
| 138 | } |
| 139 | } |
| 140 | } |
| 141 | } |
no test coverage detected
searching dependent graphs…