(ctx, value, recurseTimes, visibleKeys, key, array)
| 3208 | |
| 3209 | |
| 3210 | function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { |
| 3211 | var name, str, desc; |
| 3212 | desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; |
| 3213 | if (desc.get) { |
| 3214 | if (desc.set) { |
| 3215 | str = ctx.stylize('[Getter/Setter]', 'special'); |
| 3216 | } else { |
| 3217 | str = ctx.stylize('[Getter]', 'special'); |
| 3218 | } |
| 3219 | } else { |
| 3220 | if (desc.set) { |
| 3221 | str = ctx.stylize('[Setter]', 'special'); |
| 3222 | } |
| 3223 | } |
| 3224 | if (!hasOwnProperty(visibleKeys, key)) { |
| 3225 | name = '[' + key + ']'; |
| 3226 | } |
| 3227 | if (!str) { |
| 3228 | if (ctx.seen.indexOf(desc.value) < 0) { |
| 3229 | if (isNull(recurseTimes)) { |
| 3230 | str = formatValue(ctx, desc.value, null); |
| 3231 | } else { |
| 3232 | str = formatValue(ctx, desc.value, recurseTimes - 1); |
| 3233 | } |
| 3234 | if (str.indexOf('\n') > -1) { |
| 3235 | if (array) { |
| 3236 | str = str.split('\n').map(function(line) { |
| 3237 | return ' ' + line; |
| 3238 | }).join('\n').substr(2); |
| 3239 | } else { |
| 3240 | str = '\n' + str.split('\n').map(function(line) { |
| 3241 | return ' ' + line; |
| 3242 | }).join('\n'); |
| 3243 | } |
| 3244 | } |
| 3245 | } else { |
| 3246 | str = ctx.stylize('[Circular]', 'special'); |
| 3247 | } |
| 3248 | } |
| 3249 | if (isUndefined(name)) { |
| 3250 | if (array && key.match(/^\d+$/)) { |
| 3251 | return str; |
| 3252 | } |
| 3253 | name = JSON.stringify('' + key); |
| 3254 | if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { |
| 3255 | name = name.substr(1, name.length - 2); |
| 3256 | name = ctx.stylize(name, 'name'); |
| 3257 | } else { |
| 3258 | name = name.replace(/'/g, "\\'") |
| 3259 | .replace(/\\"/g, '"') |
| 3260 | .replace(/(^"|"$)/g, "'"); |
| 3261 | name = ctx.stylize(name, 'string'); |
| 3262 | } |
| 3263 | } |
| 3264 | |
| 3265 | return name + ': ' + str; |
| 3266 | } |
| 3267 |
no test coverage detected