I'm setting up a server that communicates with raw TCP using the 'net' module. I noticed something very strange: the data has a toArrayBuffer method, but it returns something that isn't an ArrayBuffer
net.createServer( function(socket) {
socket.on('data', function(data) {
var ab = data.toArrayBuffer();
// prints "function ArrayBuffer() { [native code] }"
console.log( ab.constructor );
// prints 'false'
console.log( ab.constructor == ArrayBuffer );
});
}).listen(port);
Why is that the case? Is there something special about the array buffer that's coming from socket data?