Only check arrays and objects for cycles
This commit is contained in:
		
					parent
					
						
							
								bd58e1b2c3
							
						
					
				
			
			
				commit
				
					
						00f82aaffe
					
				
			
		
					 1 changed files with 4 additions and 13 deletions
				
			
		|  | @ -7,18 +7,6 @@ const callbacksRegistry = new CallbacksRegistry() | |||
| 
 | ||||
| const remoteObjectCache = v8Util.createIDWeakMap() | ||||
| 
 | ||||
| // Check for circular reference.
 | ||||
| const isCircular = function (field, visited) { | ||||
|   if (visited.has(field)) { | ||||
|     return true | ||||
|   } | ||||
| 
 | ||||
|   if (typeof field === 'object') { | ||||
|     visited.add(field) | ||||
|   } | ||||
|   return false | ||||
| } | ||||
| 
 | ||||
| // Convert the arguments object into an array of meta data.
 | ||||
| const wrapArgs = function (args, visited) { | ||||
|   if (visited == null) { | ||||
|  | @ -26,7 +14,8 @@ const wrapArgs = function (args, visited) { | |||
|   } | ||||
| 
 | ||||
|   const valueToMeta = function (value) { | ||||
|     if (isCircular(value, visited)) { | ||||
|     // Check for circular reference.
 | ||||
|     if (visited.has(value)) { | ||||
|       return { | ||||
|         type: 'value', | ||||
|         value: null | ||||
|  | @ -34,6 +23,7 @@ const wrapArgs = function (args, visited) { | |||
|     } | ||||
| 
 | ||||
|     if (Array.isArray(value)) { | ||||
|       visited.add(value) | ||||
|       let meta = { | ||||
|         type: 'array', | ||||
|         value: wrapArgs(value, visited) | ||||
|  | @ -70,6 +60,7 @@ const wrapArgs = function (args, visited) { | |||
|         name: value.constructor != null ? value.constructor.name : '', | ||||
|         members: [] | ||||
|       } | ||||
|       visited.add(value) | ||||
|       for (let prop in value) { | ||||
|         meta.members.push({ | ||||
|           name: prop, | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Kevin Sawicki
				Kevin Sawicki