MCPcopy
hub / github.com/axios/axios / visit

Function visit

lib/core/AxiosError.js:33–70  ·  lib/core/AxiosError.js::visit
(source)

Source from the content-addressed store, hash-verified

31 const seen = [];
32
33 const visit = (source) => {
34 if (source === null || typeof source !== class="st">'object') return source;
35 if (utils.isBuffer(source)) return source;
36 if (seen.indexOf(source) !== -1) return undefined;
37
38 if (source instanceof AxiosHeaders) {
39 source = source.toJSON();
40 }
41
42 seen.push(source);
43
44 let result;
45 if (utils.isArray(source)) {
46 result = [];
47 source.forEach((v, i) => {
48 const reducedValue = visit(v);
49 if (!utils.isUndefined(reducedValue)) {
50 result[i] = reducedValue;
51 }
52 });
53 } else {
54 if (!utils.isPlainObject(source) && hasOwnOrPrototypeToJSON(source)) {
55 seen.pop();
56 return source;
57 }
58
59 result = Object.create(null);
60 for (const [key, value] of Object.entries(source)) {
61 const reducedValue = lowerKeys.has(key.toLowerCase()) ? REDACTED : visit(value);
62 if (!utils.isUndefined(reducedValue)) {
63 result[key] = reducedValue;
64 }
65 }
66 }
67
68 seen.pop();
69 return result;
70 };
71
72 return visit(config);
73}

Callers 1

redactConfigFunction · 0.70

Calls 6

hasOwnOrPrototypeToJSONFunction · 0.85
forEachMethod · 0.80
createMethod · 0.80
entriesMethod · 0.80
hasMethod · 0.80
toJSONMethod · 0.45

Tested by

no test coverage detected