I'm trying to write some application using ArrayBuffers, Websockets and DataStream.js library, but it is failing on pretty simple code and I haven't found any related pages about same problem.
The problem is that
var arr = new Uint8Array(6);
alert(arr.BYTES_PER_ELEMENT);
Returns undefined. I can use directly Uint8Array.BYTES_PER_ELEMENT
(which is in Opera 1), but DataStream.js library is using "universal" way to get this property: (DataStream.js:377)
DataStream.memcpy(arr.buffer, 0,
this.buffer, this.byteOffset+this.position,
length*arr.BYTES_PER_ELEMENT);
Is there some way to keep it universal but working in Opera 12? Something like arr.__proto__.BYTES_PER_ELEMENT
.
Or am I doing something wrong? In Chromium it works OK.
So, after short discussion with ivy_lynx, I decided to do it this simple way, which sets value that should be set in prototypes. Now the DataStream.js library works OK even in Opera 12.16
if (Uint8Array.prototype.BYTES_PER_ELEMENT == undefined) {
Uint8Array.prototype.BYTES_PER_ELEMENT = Uint8Array.BYTES_PER_ELEMENT;
Uint8ClampedArray.prototype.BYTES_PER_ELEMENT = Uint8ClampedArray.BYTES_PER_ELEMENT;
Int8Array.prototype.BYTES_PER_ELEMENT = Int8Array.BYTES_PER_ELEMENT;
Uint16Array.prototype.BYTES_PER_ELEMENT = Uint16Array.BYTES_PER_ELEMENT;
Int16Array.prototype.BYTES_PER_ELEMENT = Int16Array.BYTES_PER_ELEMENT;
Uint32Array.prototype.BYTES_PER_ELEMENT = Uint32Array.BYTES_PER_ELEMENT;
Int32Array.prototype.BYTES_PER_ELEMENT = Int32Array.BYTES_PER_ELEMENT;
Float64Array.prototype.BYTES_PER_ELEMENT = Float64Array.BYTES_PER_ELEMENT;
}