(ctx, obj, key, isPrivate, inside_array)
| 303 | } |
| 304 | |
| 305 | function formatProperty(ctx, obj, key, isPrivate, inside_array) { |
| 306 | if (ctx.jsonParity && obj[key] === undefined) { |
| 307 | return null; // jsonParity: properties that are equal to 'undefined' are not printed |
| 308 | } |
| 309 | |
| 310 | var desc = Object.getOwnPropertyDescriptor(obj, key) || { value: obj[key] }; |
| 311 | var str; |
| 312 | if (desc.get || desc.set) { |
| 313 | if (! ctx.showAccessors) { |
| 314 | return null; |
| 315 | } |
| 316 | if (desc.get) { |
| 317 | if (desc.set) { |
| 318 | str = ctx.stylize('[Getter/Setter]', 'special'); |
| 319 | } else { |
| 320 | str = ctx.stylize('[Getter]', 'special'); |
| 321 | } |
| 322 | } else if (desc.set) { |
| 323 | str = ctx.stylize('[Setter]', 'special'); |
| 324 | } |
| 325 | } else if (ctx.seen.indexOf(desc.value) > -1) { |
| 326 | str = ctx.stylize('[Circular]', 'special'); |
| 327 | } else { |
| 328 | str = formatValue(ctx, desc.value); |
| 329 | if (str === null) { |
| 330 | return null; // skip key (e.g. functions in JSON mode) |
| 331 | } |
| 332 | if (str.indexOf('\n') > -1) { |
| 333 | str = str.split('\n').join('\n' + ctx.indent); |
| 334 | if (ctx.openBraceOnNewline) { |
| 335 | str = '\n' + ctx.indent + str; |
| 336 | } |
| 337 | } |
| 338 | } |
| 339 | |
| 340 | if (inside_array && key.match(/^\d+$/)) { |
| 341 | return str; |
| 342 | } else { |
| 343 | return formatKey(ctx, key, isPrivate) + ':' + ctx.space + str; |
| 344 | } |
| 345 | } |
| 346 | |
| 347 | function formatKey(ctx, key, isPrivate) { |
| 348 | var name = '' + key; |
no test coverage detected