MCPcopy Create free account
hub / github.com/awayjs/core / writeUnsignedShort

Method writeUnsignedShort

lib/utils/ByteArray.ts:134–152  ·  view source on GitHub ↗
(b: number)

Source from the content-addressed store, hash-verified

132 }
133
134 public writeUnsignedShort(b: number): void {
135 this.ensureWriteableSpace(2);
136
137 if ((this.position & 1) == 0) {
138 const view = new Uint16Array(this.arraybytes);
139 view[ this.position >> 1 ] = (~~b) & 0xffff; // ~~ is cast to int in js...
140 } else {
141 const view = new Uint16Array(this.unalignedarraybytestemp, 0, 1);
142 view[0] = (~~b) & 0xffff;
143 const view2 = new Uint8Array(this.arraybytes, this.position, 2);
144 const view3 = new Uint8Array(this.unalignedarraybytestemp, 0, 2);
145 view2.set(view3);
146 }
147
148 this.position += 2;
149
150 if (this.position > this.length)
151 this.length = this.position;
152 }
153
154 public readUTFBytes(len: number): string {
155 let value: string = '';

Callers

nothing calls this directly

Calls 2

ensureWriteableSpaceMethod · 0.95
setMethod · 0.80

Tested by

no test coverage detected