質問

Given some ArrayBuffer like:

var data = new ArrayBuffer(64);

I want to be able to write 32bit integers at any position (not only 32bit aligned).

For example:

[0][1][2][3][4][5][6][7][8][9] ... byte data
   [__________][__________] ... I want to create an Int32Array with 1 byte offset

Is that possible?

Unfortunately, the byteOffset attribute is read-only and if it's set when creating the view, it only accepts multiples of 4 (for int32s).

役に立ちましたか?

解決

If you need to read various types of values from arbitrary offsets, DataView is more handy. It has no alignment requirements.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top