MCPcopy Create free account
hub / github.com/apache/fory / reset

Method reset

javascript/packages/core/lib/reader/index.ts:41–67  ·  view source on GitHub ↗
(ab: Uint8Array)

Source from the content-addressed store, hash-verified

39 }
40
41 reset(ab: Uint8Array) {
42 this.platformBuffer = fromUint8Array(ab);
43 this.byteLength = this.platformBuffer.byteLength;
44 // Reuse DataView when the underlying ArrayBuffer, byteOffset, and byteLength are unchanged.
45 const buf = this.platformBuffer.buffer;
46 if (
47 buf !== this.cachedArrayBuffer
48 || !this.dataView
49 || this.dataView.byteOffset !== this.platformBuffer.byteOffset
50 || this.dataView.byteLength !== this.byteLength
51 ) {
52 this.dataView = new DataView(
53 buf,
54 this.platformBuffer.byteOffset,
55 this.byteLength,
56 );
57 this.cachedArrayBuffer = buf;
58 }
59 if (this.sliceStringEnable) {
60 this.bigString = this.platformBuffer.toString(
61 "latin1",
62 0,
63 this.byteLength,
64 );
65 }
66 this.cursor = 0;
67 }
68
69 readUint8() {
70 return this.dataView.getUint8(this.cursor++);

Callers 1

typeMetaBodyOffsetFunction · 0.95

Calls 1

toStringMethod · 0.65

Tested by 1

typeMetaBodyOffsetFunction · 0.76