Fix TypedArray check, add check when instanceof doesn't work for TypedArrays.

This commit is contained in:
haad 2016-07-23 12:43:49 +01:00
parent 2757046e71
commit fac330fb50
3 changed files with 4 additions and 3 deletions

View file

@ -63,7 +63,7 @@ let valueToMeta = function (sender, value, optimizeSimpleObject = false) {
meta.type = 'buffer' meta.type = 'buffer'
} else if (Array.isArray(value)) { } else if (Array.isArray(value)) {
meta.type = 'array' meta.type = 'array'
} else if (isTypedArray(value.buffer)) { } else if (isTypedArray(value)) {
meta.type = 'typed-array' meta.type = 'typed-array'
} else if (value instanceof Error) { } else if (value instanceof Error) {
meta.type = 'error' meta.type = 'error'

View file

@ -11,6 +11,7 @@ module.exports = function isTypedArray (val) {
val instanceof Uint16Array || val instanceof Uint16Array ||
val instanceof Uint32Array || val instanceof Uint32Array ||
val instanceof Float32Array || val instanceof Float32Array ||
val instanceof Float64Array) val instanceof Float64Array) ||
(Object.prototype.toString.call(val).substr(-6, 5) === 'Array')
) )
} }

View file

@ -35,7 +35,7 @@ const wrapArgs = function (args, visited) {
type: 'buffer', type: 'buffer',
value: Array.prototype.slice.call(value, 0) value: Array.prototype.slice.call(value, 0)
} }
} else if (isTypedArray(value.buffer)) { } else if (isTypedArray(value)) {
return { return {
type: 'typed-array', type: 'typed-array',
value: Array.prototype.slice.call(value) value: Array.prototype.slice.call(value)