MCPcopy Create free account
hub / github.com/RubyLouvre/anu / formatProperty

Function formatProperty

test/babel.js:10950–11004  ·  view source on GitHub ↗
(ctx, value, recurseTimes, visibleKeys, key, array)

Source from the content-addressed store, hash-verified

10948 }
10949
10950 function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) {
10951 var name, str, desc;
10952 desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] };
10953 if (desc.get) {
10954 if (desc.set) {
10955 str = ctx.stylize('[Getter/Setter]', 'special');
10956 } else {
10957 str = ctx.stylize('[Getter]', 'special');
10958 }
10959 } else {
10960 if (desc.set) {
10961 str = ctx.stylize('[Setter]', 'special');
10962 }
10963 }
10964 if (!hasOwnProperty(visibleKeys, key)) {
10965 name = '[' + key + ']';
10966 }
10967 if (!str) {
10968 if (ctx.seen.indexOf(desc.value) < 0) {
10969 if (isNull(recurseTimes)) {
10970 str = formatValue(ctx, desc.value, null);
10971 } else {
10972 str = formatValue(ctx, desc.value, recurseTimes - 1);
10973 }
10974 if (str.indexOf('\n') > -1) {
10975 if (array) {
10976 str = str.split('\n').map(function (line) {
10977 return ' ' + line;
10978 }).join('\n').substr(2);
10979 } else {
10980 str = '\n' + str.split('\n').map(function (line) {
10981 return ' ' + line;
10982 }).join('\n');
10983 }
10984 }
10985 } else {
10986 str = ctx.stylize('[Circular]', 'special');
10987 }
10988 }
10989 if (isUndefined(name)) {
10990 if (array && key.match(/^\d+$/)) {
10991 return str;
10992 }
10993 name = JSON.stringify('' + key);
10994 if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
10995 name = name.substr(1, name.length - 2);
10996 name = ctx.stylize(name, 'name');
10997 } else {
10998 name = name.replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'");
10999 name = ctx.stylize(name, 'string');
11000 }
11001 }
11002
11003 return name + ': ' + str;
11004 }
11005
11006 function reduceToSingleString(output, base, braces) {
11007 var numLinesEst = 0;

Callers 2

formatValueFunction · 0.85
formatArrayFunction · 0.85

Calls 4

hasOwnPropertyFunction · 0.85
isNullFunction · 0.85
formatValueFunction · 0.85
isUndefinedFunction · 0.85

Tested by

no test coverage detected