Match-id-e1124faaed58084937cabc0567c12f8c01af6016

This commit is contained in:
* 2023-02-17 18:17:06 +08:00
parent 2293727e6b
commit 20694046d6
1 changed files with 1 additions and 13 deletions

View File

@ -25,7 +25,6 @@ function makeStoreSnapshot({ type, data }) {
return snapshot; return snapshot;
} }
<<<<<<< Updated upstream
// safely serializes variables containing values wrapped in Proxy object // safely serializes variables containing values wrapped in Proxy object
function getType(value) { function getType(value) {
if (!value) return 'nullish'; if (!value) return 'nullish';
@ -40,11 +39,8 @@ function getType(value) {
if (typeof value === 'object') return 'object'; if (typeof value === 'object') return 'object';
return 'primitive'; return 'primitive';
} }
function makeProxySnapshot(obj) {
const type = getType(obj);
=======
function makeProxySnapshot(obj, visited: any[] = []) { function makeProxySnapshot(obj, visited: any[] = []) {
>>>>>>> Stashed changes const type = getType(obj);
let clone; let clone;
try { try {
@ -58,7 +54,6 @@ function makeProxySnapshot(obj, visited: any[] = []) {
if (type === 'function') { if (type === 'function') {
return obj.toString(); return obj.toString();
} }
<<<<<<< Updated upstream
// VNODE // VNODE
if (type === 'vnode') { if (type === 'vnode') {
return { return {
@ -98,21 +93,14 @@ function makeProxySnapshot(obj, visited: any[] = []) {
} }
// ARRAY // ARRAY
if (type === 'array') { if (type === 'array') {
=======
if (Array.isArray(obj)) {
if (visited.some(item => item === obj)) return `<Cyclic ${obj.toString()}>`; if (visited.some(item => item === obj)) return `<Cyclic ${obj.toString()}>`;
>>>>>>> Stashed changes
clone = []; clone = [];
obj.forEach(item => clone.push(makeProxySnapshot(item, visited.concat([obj])))); obj.forEach(item => clone.push(makeProxySnapshot(item, visited.concat([obj]))));
return clone; return clone;
<<<<<<< Updated upstream
} }
// OBJECT // OBJECT
if (type === 'object') { if (type === 'object') {
=======
} else if (typeof obj === 'object') {
if (visited.some(item => item === obj)) return `<Cyclic ${obj.toString()}>`; if (visited.some(item => item === obj)) return `<Cyclic ${obj.toString()}>`;
>>>>>>> Stashed changes
clone = {}; clone = {};
Object.entries(obj).forEach(([id, value]) => (clone[id] = makeProxySnapshot(value, visited.concat([obj])))); Object.entries(obj).forEach(([id, value]) => (clone[id] = makeProxySnapshot(value, visited.concat([obj]))));
return clone; return clone;