MCPcopy
hub / github.com/axios/axios / stringifyWithDepthLimit

Function stringifyWithDepthLimit

lib/helpers/toFormData.js:167–188  ·  view source on GitHub ↗
(value, depth)

Source from the content-addressed store, hash-verified

165 }
166
167 function stringifyWithDepthLimit(value, depth) {
168 if (maxDepth === Infinity) {
169 return JSON.stringify(value);
170 }
171
172 const ancestors = [];
173
174 return JSON.stringify(value, function limitDepth(_key, currentValue) {
175 if (!utils.isObject(currentValue)) {
176 return currentValue;
177 }
178
179 while (ancestors.length && ancestors[ancestors.length - 1] !== this) {
180 ancestors.pop();
181 }
182
183 ancestors.push(currentValue);
184 throwIfMaxDepthExceeded(depth + ancestors.length - 1);
185
186 return currentValue;
187 });
188 }
189
190 /**
191 * Default visitor.

Callers 1

defaultVisitorFunction · 0.85

Calls 1

throwIfMaxDepthExceededFunction · 0.85

Tested by

no test coverage detected