(indent, name, value, seen)
| 138 | } |
| 139 | |
| 140 | function jsToYaml(indent, name, value, seen) { |
| 141 | if (value === undefined) { |
| 142 | return ''; |
| 143 | } |
| 144 | |
| 145 | const prefix = `${indent} ${name}:`; |
| 146 | |
| 147 | if (value === null) { |
| 148 | return `${prefix} ~\n`; |
| 149 | } |
| 150 | |
| 151 | if (typeof value !== 'object') { |
| 152 | if (typeof value !== 'string') { |
| 153 | return `${prefix} ${inspectWithNoCustomRetry(value, inspectOptions)}\n`; |
| 154 | } |
| 155 | |
| 156 | const lines = RegExpPrototypeSymbolSplit(kLineBreakRegExp, value); |
| 157 | |
| 158 | if (lines.length === 1) { |
| 159 | return `${prefix} ${inspectWithNoCustomRetry(value, inspectOptions)}\n`; |
| 160 | } |
| 161 | |
| 162 | let str = `${prefix} |-\n`; |
| 163 | |
| 164 | for (let i = 0; i < lines.length; i++) { |
| 165 | str += `${indent} ${lines[i]}\n`; |
| 166 | } |
| 167 | |
| 168 | return str; |
| 169 | } |
| 170 | |
| 171 | seen.add(value); |
| 172 | const entries = ObjectEntries(value); |
| 173 | const isErrorObj = isError(value); |
| 174 | let propsIndent = indent; |
| 175 | let result = ''; |
| 176 | |
| 177 | if (name != null) { |
| 178 | result += prefix; |
| 179 | if (internalBinding('types').isDate(value)) { |
| 180 | // YAML uses the ISO-8601 standard to express dates. |
| 181 | result += ' ' + DatePrototypeToISOString(value); |
| 182 | } |
| 183 | result += '\n'; |
| 184 | propsIndent += ' '; |
| 185 | } |
| 186 | |
| 187 | for (let i = 0; i < entries.length; i++) { |
| 188 | const { 0: key, 1: value } = entries[i]; |
| 189 | |
| 190 | if (isErrorObj && (key === 'cause' || key === 'code')) { |
| 191 | continue; |
| 192 | } |
| 193 | if (seen.has(value)) { |
| 194 | result += `${propsIndent} ${key}: <Circular>\n`; |
| 195 | continue; |
| 196 | } |
| 197 |
no test coverage detected