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

Function visit

lib/utils.js:836–864  ·  view source on GitHub ↗
(source)

Source from the content-addressed store, hash-verified

834 const visited = new WeakSet();
835
836 const visit = (source) => {
837 if (isObject(source)) {
838 if (visited.has(source)) {
839 return;
840 }
841
842 //Buffer check
843 if (isBuffer(source)) {
844 return source;
845 }
846
847 if (!('toJSON' in source)) {
848 // add-on descent / delete-on-ascent: preserves path semantics, so DAG nodes serialise at every occurrence (see #7230).
849 visited.add(source);
850 const target = isArray(source) ? [] : {};
851
852 forEach(source, (value, key) => {
853 const reducedValue = visit(value);
854 !isUndefined(reducedValue) && (target[key] = reducedValue);
855 });
856
857 visited.delete(source);
858
859 return target;
860 }
861 }
862
863 return source;
864 };
865
866 return visit(obj);
867};

Callers 1

toJSONObjectFunction · 0.70

Calls 5

isObjectFunction · 0.85
isBufferFunction · 0.85
forEachFunction · 0.85
hasMethod · 0.80
deleteMethod · 0.80

Tested by

no test coverage detected