mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
move the toJSON check before the cyclic dependency check
This commit is contained in:
parent
b0e2b188d5
commit
19b8139264
|
@ -9,6 +9,13 @@ export const deepCopy = <T>(source: T, hash = new WeakMap(), path = ''): T => {
|
||||||
if (typeof source !== 'object' || source === null || source instanceof Function) {
|
if (typeof source !== 'object' || source === null || source instanceof Function) {
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
// Date and other Serializable objects
|
||||||
|
const toJSON = (source as Serializable).toJSON;
|
||||||
|
if (typeof toJSON === 'function') {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||||
|
return toJSON.call(source) as T;
|
||||||
|
}
|
||||||
|
// Break any cyclic dependencies
|
||||||
if (hash.has(source)) {
|
if (hash.has(source)) {
|
||||||
return hash.get(source);
|
return hash.get(source);
|
||||||
}
|
}
|
||||||
|
@ -21,13 +28,6 @@ export const deepCopy = <T>(source: T, hash = new WeakMap(), path = ''): T => {
|
||||||
}
|
}
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
// Date and other Serializable objects
|
|
||||||
const toJSON = (source as Serializable).toJSON;
|
|
||||||
if (typeof toJSON === 'function') {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
||||||
return toJSON.call(source) as T;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Object
|
// Object
|
||||||
clone = {};
|
clone = {};
|
||||||
hash.set(source, clone);
|
hash.set(source, clone);
|
||||||
|
|
Loading…
Reference in a new issue