Support remote Promise in renderer
This commit is contained in:
parent
2eaaad610d
commit
ddf2cfd48d
2 changed files with 4 additions and 0 deletions
|
@ -10,6 +10,7 @@ valueToMeta = (sender, value) ->
|
|||
meta.type = 'buffer' if Buffer.isBuffer value
|
||||
meta.type = 'value' if value is null
|
||||
meta.type = 'array' if Array.isArray value
|
||||
meta.type = 'promise' if Promise.resolve(value) == value
|
||||
|
||||
# Treat the arguments object as array.
|
||||
meta.type = 'array' if meta.type is 'object' and value.callee? and value.length?
|
||||
|
@ -29,6 +30,8 @@ valueToMeta = (sender, value) ->
|
|||
meta.members.push {name: prop, type: typeof field} for prop, field of value
|
||||
else if meta.type is 'buffer'
|
||||
meta.value = Array::slice.call value, 0
|
||||
else if meta.type is 'promise'
|
||||
meta.then = valueToMeta(sender, value.then.bind(value))
|
||||
else
|
||||
meta.type = 'value'
|
||||
meta.value = value
|
||||
|
|
|
@ -44,6 +44,7 @@ metaToValue = (meta) ->
|
|||
when 'value' then meta.value
|
||||
when 'array' then (metaToValue(el) for el in meta.members)
|
||||
when 'buffer' then new Buffer(meta.value)
|
||||
when 'promise' then Promise.resolve(then: metaToValue(meta.then))
|
||||
when 'error'
|
||||
throw new Error("#{meta.message}\n#{meta.stack}")
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue