Closed
Description
Hi,
I would like to know how a class could inherit from the new Buffer implementation.
I'm trying to upgrade the node-ogg module for node v4 and nan v2.
(Here is my work so far)
I tried this classic inheritance model:
function ogg_packet (buffer) {
if (!Buffer.isBuffer(buffer)) {
Buffer.call(this, binding.sizeof_ogg_packet);
} else {
Buffer.call(this, buffer);
}
if (this.length != binding.sizeof_ogg_packet) {
throw new Error('"buffer.length" = ' + this.length + ', expected ' + binding.sizeof_ogg_packet);
}
}
inherits(ogg_packet, Buffer);
But I get this error when trying to access this.length :
Uncaught TypeError: Method Uint8Array.length called on incompatible receiver [object Object]
Thanks
Note: I also asked the question on SO:
http://stackoverflow.com/questions/32555714