MCPcopy Index your code
hub / github.com/parse-community/parse-server / getCircularReplacer

Method getCircularReplacer

src/Utils.js:502–519  ·  view source on GitHub ↗

* Creates a JSON replacer function that handles Map, Set, and circular references. * This replacer can be used with JSON.stringify to safely serialize complex objects. * * @returns {Function} A replacer function for JSON.stringify that: * - Converts Map instances to plain objects * -

()

Source from the content-addressed store, hash-verified

500 * // Output: {"name":"test","map":{"key":"value"},"self":"[Circular]"}
501 */
502 static getCircularReplacer() {
503 const seen = new WeakSet();
504 return (key, value) => {
505 if (Utils.isMap(value)) {
506 return Object.fromEntries(value);
507 }
508 if (Utils.isSet(value)) {
509 return Array.from(value);
510 }
511 if (typeof value === 'object' && value !== null) {
512 if (seen.has(value)) {
513 return '[Circular]';
514 }
515 seen.add(value);
516 }
517 return value;
518 };
519 }
520
521 /**
522 * Gets a nested property value from an object using dot notation.

Callers 2

connectMethod · 0.80
Utils.spec.jsFile · 0.80

Calls 2

isMapMethod · 0.80
isSetMethod · 0.80

Tested by

no test coverage detected