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

Class BufferView

g2all/900/module/rw.js:29–63  ·  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 read16(offset) {
36 return this._dview.getUint16(offset, true);
37 }
38
39 read32(offset) {
40 return this._dview.getUint32(offset, true);
41 }
42
43 read64(offset) {
44 return new Int(
45 this._dview.getUint32(offset, true),
46 this._dview.getUint32(offset + 4, true),
47 );
48 }
49
50 write16(offset, value) {
51 this._dview.setUint16(offset, value, true);
52 }
53
54 write32(offset, value) {
55 this._dview.setUint32(offset, value, true);
56 }
57
58 write64(offset, value) {
59 const values = lohi_from_one(value);
60 this._dview.setUint32(offset, values[0], true);
61 this._dview.setUint32(offset + 4, values[1], true);
62 }
63}
64
65// WARNING: These functions are now deprecated. use BufferView instead.
66

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected