MCPcopy Create free account
hub / github.com/GamerHack/GamerHack.github.io / BufferView

Class BufferView

g2all/700/module/rw.js:29–68  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27// instances of BufferView will their have m_mode set to WastefulTypedArray
28// since we use the .buffer getter to create a DataView
29export class BufferView extends Uint8Array {
30 constructor(...args) {
31 super(...args);
32 this._dview = new DataView(this.buffer, this.byteOffset);
33 }
34
35 read8(offset) {
36 return this._dview.getUint8(offset);
37 }
38
39 read16(offset) {
40 return this._dview.getUint16(offset, true);
41 }
42
43 read32(offset) {
44 return this._dview.getUint32(offset, true);
45 }
46
47 read64(offset) {
48 return new Int(this._dview.getUint32(offset, true), this._dview.getUint32(offset + 4, true));
49 }
50
51 write8(offset, value) {
52 this._dview.setUint8(offset, value);
53 }
54
55 write16(offset, value) {
56 this._dview.setUint16(offset, value, true);
57 }
58
59 write32(offset, value) {
60 this._dview.setUint32(offset, value, true);
61 }
62
63 write64(offset, value) {
64 const values = lohi_from_one(value);
65 this._dview.setUint32(offset, values[0], true);
66 this._dview.setUint32(offset + 4, values[1], true);
67 }
68}
69
70// WARNING: These functions are now deprecated. use BufferView instead.
71

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected