buffer, null, array etc. all belong to object
This commit is contained in:
parent
ff1b7d18f6
commit
680652d01c
1 changed files with 12 additions and 12 deletions
|
@ -53,19 +53,19 @@ let getObjectPrototype = function (object) {
|
|||
let valueToMeta = function (sender, value, optimizeSimpleObject = false) {
|
||||
// Determine the type of value.
|
||||
let meta = { type: typeof value }
|
||||
if (Buffer.isBuffer(value)) {
|
||||
meta.type = 'buffer'
|
||||
} else if (value === null) {
|
||||
meta.type = 'value'
|
||||
} else if (Array.isArray(value)) {
|
||||
meta.type = 'array'
|
||||
} else if (value instanceof Error) {
|
||||
meta.type = 'error'
|
||||
} else if (value instanceof Date) {
|
||||
meta.type = 'date'
|
||||
} else if (meta.type === 'object') {
|
||||
if (meta.type === 'object') {
|
||||
// Recognize certain types of objects.
|
||||
if (value.constructor != null && value.constructor.name === 'Promise') {
|
||||
if (value === null) {
|
||||
meta.type = 'value'
|
||||
} else if (Buffer.isBuffer(value)) {
|
||||
meta.type = 'buffer'
|
||||
} else if (Array.isArray(value)) {
|
||||
meta.type = 'array'
|
||||
} else if (value instanceof Error) {
|
||||
meta.type = 'error'
|
||||
} else if (value instanceof Date) {
|
||||
meta.type = 'date'
|
||||
} else if (value.constructor != null && value.constructor.name === 'Promise') {
|
||||
meta.type = 'promise'
|
||||
} else if (value.hasOwnProperty('callee') && value.length != null) {
|
||||
// Treat the arguments object as array.
|
||||
|
|
Loading…
Reference in a new issue