MCPcopy Index your code
hub / github.com/handsontable/handsontable / stringifyToJSON

Function stringifyToJSON

wrappers/vue3/src/helpers.ts:151–182  ·  view source on GitHub ↗
(val)

Source from the content-addressed store, hash-verified

149 let nextIdentityId = 0;
150
151 const stringifyToJSON = (val) => {
152 const seen = new WeakSet();
153
154 return JSON.stringify(val, (key, value) => {
155 if (typeof value === 'object' && value !== null) {
156 if (seen.has(value)) {
157 return undefined;
158 }
159
160 seen.add(value);
161
162 // DOM nodes carry framework metadata as enumerable own properties
163 // (e.g., Vue 3 attaches `_vnode` to the mount root). Recursing into them
164 // can reach getters that throw - see GH #11220 - and produces noise that
165 // is irrelevant to settings equality. Replace each Node with an identity
166 // token so reference equality is still detected.
167 if (typeof Node !== 'undefined' && value instanceof Node) {
168 let id = identityMap.get(value);
169
170 if (id === undefined) {
171 nextIdentityId += 1;
172 id = `__hot_node_${nextIdentityId}__`;
173 identityMap.set(value, id);
174 }
175
176 return id;
177 }
178 }
179
180 return value;
181 });
182 };
183
184 if (typeof objectA === 'function' && typeof objectB === 'function') {
185 return objectA.toString() === objectB.toString();

Callers 1

simpleEqualFunction · 0.85

Calls 4

hasMethod · 0.45
addMethod · 0.45
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…