Cleanup the code determining value's type

This commit is contained in:
Cheng Zhao 2016-04-20 14:26:49 +09:00
parent d3bff7fffc
commit ff1b7d18f6
2 changed files with 35 additions and 46 deletions

View file

@ -45,17 +45,19 @@ var wrapArgs = function (args, visited) {
type: 'date',
value: value.getTime()
}
} else if ((value != null ? value.constructor.name : void 0) === 'Promise') {
return {
type: 'promise',
then: valueToMeta(function (v) { value.then(v) })
}
} else if ((value != null) && typeof value === 'object' && v8Util.getHiddenValue(value, 'atomId')) {
return {
type: 'remote-object',
id: v8Util.getHiddenValue(value, 'atomId')
}
} else if ((value != null) && typeof value === 'object') {
if (value.constructor != null && value.constructor.name === 'Promise') {
return {
type: 'promise',
then: valueToMeta(function (v) { value.then(v) })
}
} else if (v8Util.getHiddenValue(value, 'atomId')) {
return {
type: 'remote-object',
id: v8Util.getHiddenValue(value, 'atomId')
}
}
ret = {
type: 'object',
name: value.constructor.name,