fix(core): update
This commit is contained in:
		
							
								
								
									
										11
									
								
								ts/index.ts
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								ts/index.ts
									
									
									
									
									
								
							| @@ -49,8 +49,17 @@ export class Smartjson { | |||||||
|    */ |    */ | ||||||
|   public foldToObject() { |   public foldToObject() { | ||||||
|     const newFoldedObject: { [key: string]: any } = {}; |     const newFoldedObject: { [key: string]: any } = {}; | ||||||
|  |     const trackMap = []; | ||||||
|     for (const keyName of this.saveableProperties) { |     for (const keyName of this.saveableProperties) { | ||||||
|       newFoldedObject[keyName] = plugins.lodashCloneDeep(this[keyName]); |       let value = this[keyName]; | ||||||
|  |       if (value instanceof Smartjson) { | ||||||
|  |         if (trackMap.includes(value)) { | ||||||
|  |           throw new Error('cycle detected'); | ||||||
|  |         } | ||||||
|  |         trackMap.push(value); | ||||||
|  |         value = value.foldToObject(); | ||||||
|  |       } | ||||||
|  |       newFoldedObject[keyName] = plugins.lodashCloneDeep(value); | ||||||
|     } |     } | ||||||
|     return newFoldedObject; |     return newFoldedObject; | ||||||
|   } |   } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user