(ctx, value, recurseTimes, visibleKeys, key, array)
| 29853 | |
| 29854 | |
| 29855 | function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { |
| 29856 | var name, str, desc; |
| 29857 | desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; |
| 29858 | if (desc.get) { |
| 29859 | if (desc.set) { |
| 29860 | str = ctx.stylize('[Getter/Setter]', 'special'); |
| 29861 | } else { |
| 29862 | str = ctx.stylize('[Getter]', 'special'); |
| 29863 | } |
| 29864 | } else { |
| 29865 | if (desc.set) { |
| 29866 | str = ctx.stylize('[Setter]', 'special'); |
| 29867 | } |
| 29868 | } |
| 29869 | if (!hasOwnProperty(visibleKeys, key)) { |
| 29870 | name = '[' + key + ']'; |
| 29871 | } |
| 29872 | if (!str) { |
| 29873 | if (ctx.seen.indexOf(desc.value) < 0) { |
| 29874 | if (isNull(recurseTimes)) { |
| 29875 | str = formatValue(ctx, desc.value, null); |
| 29876 | } else { |
| 29877 | str = formatValue(ctx, desc.value, recurseTimes - 1); |
| 29878 | } |
| 29879 | if (str.indexOf('\n') > -1) { |
| 29880 | if (array) { |
| 29881 | str = str.split('\n').map(function(line) { |
| 29882 | return ' ' + line; |
| 29883 | }).join('\n').substr(2); |
| 29884 | } else { |
| 29885 | str = '\n' + str.split('\n').map(function(line) { |
| 29886 | return ' ' + line; |
| 29887 | }).join('\n'); |
| 29888 | } |
| 29889 | } |
| 29890 | } else { |
| 29891 | str = ctx.stylize('[Circular]', 'special'); |
| 29892 | } |
| 29893 | } |
| 29894 | if (isUndefined(name)) { |
| 29895 | if (array && key.match(/^\d+$/)) { |
| 29896 | return str; |
| 29897 | } |
| 29898 | name = JSON.stringify('' + key); |
| 29899 | if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { |
| 29900 | name = name.substr(1, name.length - 2); |
| 29901 | name = ctx.stylize(name, 'name'); |
| 29902 | } else { |
| 29903 | name = name.replace(/'/g, "\\'") |
| 29904 | .replace(/\\"/g, '"') |
| 29905 | .replace(/(^"|"$)/g, "'"); |
| 29906 | name = ctx.stylize(name, 'string'); |
| 29907 | } |
| 29908 | } |
| 29909 | |
| 29910 | return name + ': ' + str; |
| 29911 | } |
| 29912 |
no test coverage detected