Only check arrays and objects for cycles
This commit is contained in:
Родитель
bd58e1b2c3
Коммит
00f82aaffe
|
@ -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,
|
||||
|
|
Загрузка…
Ссылка в новой задаче