Use ArrayBuffer.isView rather than instanceof to distinguish between views and array buffers.
Using instanceof to determine ArrayBuffers is fraught with problems in Javascript. See, for example, lodash’s implementation of isArrayBuffer, or the many isArrayBuffer libraries out there. Apparently, ArrayBuffers from a different context (like an iframe, or perhaps something in a test setup) so instanceof won’t work always. See https://github.com/feross/buffer/issues/166 for some more examples.