MCPcopy Index your code
hub / github.com/nodejs/node / formatRaw

Function formatRaw

lib/internal/util/inspect.js:1206–1500  ·  view source on GitHub ↗
(ctx, value, recurseTimes, typedArray)

Source from the content-addressed store, hash-verified

1204}
1205
1206function formatRaw(ctx, value, recurseTimes, typedArray) {
1207 let keys;
1208 let protoProps;
1209 if (ctx.showHidden && (recurseTimes <= ctx.depth || ctx.depth === null)) {
1210 protoProps = [];
1211 }
1212
1213 const constructor = getConstructorName(value, ctx, recurseTimes, protoProps);
1214 // Reset the variable to check for this later on.
1215 if (protoProps !== undefined && protoProps.length === 0) {
1216 protoProps = undefined;
1217 }
1218
1219 let tag = '';
1220
1221 try {
1222 tag = value[SymbolToStringTag];
1223 } catch {
1224 // Ignore error.
1225 }
1226
1227 // Only list the tag in case it's non-enumerable / not an own property.
1228 // Otherwise we'd print this twice.
1229 if (typeof tag !== 'string' ||
1230 (tag !== '' &&
1231 (ctx.showHidden ?
1232 ObjectPrototypeHasOwnProperty :
1233 ObjectPrototypePropertyIsEnumerable)(
1234 value, SymbolToStringTag,
1235 ))) {
1236 tag = '';
1237 }
1238 let base = '';
1239 let formatter = getEmptyFormatArray;
1240 let braces;
1241 let noIterator = true;
1242 let i = 0;
1243 const filter = ctx.showHidden ? ALL_PROPERTIES : ONLY_ENUMERABLE;
1244
1245 let extrasType = kObjectType;
1246 let extraKeys;
1247
1248 // Iterators and the rest are split to reduce checks.
1249 // We have to check all values in case the constructor is set to null.
1250 // Otherwise it would not possible to identify all types properly.
1251 if (SymbolIterator in value || constructor === null) {
1252 noIterator = false;
1253 if (ArrayIsArray(value)) {
1254 // Only set the constructor for non ordinary ("Array [...]") arrays.
1255 const prefix = (constructor !== 'Array' || tag !== '') ?
1256 getPrefix(constructor, tag, 'Array', `(${value.length})`) :
1257 '';
1258 keys = getOwnNonIndexProperties(value, filter);
1259 braces = [`${prefix}[`, ']'];
1260 if (value.length === 0 && keys.length === 0 && protoProps === undefined)
1261 return `${braces[0]}]`;
1262 extrasType = kArrayExtrasType;
1263 formatter = formatArray;

Callers 1

formatValueFunction · 0.85

Calls 15

getConstructorNameFunction · 0.85
getPrefixFunction · 0.85
isSetFunction · 0.85
getKeysFunction · 0.85
isTypedArrayFunction · 0.85
getIteratorBracesFunction · 0.85
getFunctionBaseFunction · 0.85
isDataViewFunction · 0.85
getBoxedBaseFunction · 0.85
getCtxStyleFunction · 0.85
formatExtraPropertiesFunction · 0.85
formatPropertyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…