Add a .data pointer on ArrayBuffers for convenience, see #291

This commit is contained in:
dcodeIO
2018-10-03 01:06:48 +02:00
parent b7e7be20cf
commit db0e82fbc3
13 changed files with 89 additions and 31 deletions

View File

@ -9,6 +9,9 @@ export class ArrayBuffer {
readonly byteLength: i32; // capped to [0, MAX_LENGTH]
// @unsafe
get data(): usize { return changetype<usize>(this) + HEADER_SIZE; }
constructor(length: i32, unsafe: bool = false) {
if (<u32>length > <u32>MAX_BLENGTH) throw new RangeError("Invalid array buffer length");
var buffer = allocateUnsafe(length);