MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / writeName

Method writeName

modules/network/dns/dnsserializer.js:172–191  ·  view source on GitHub ↗
(parts)

Source from the content-addressed store, hash-verified

170 state.position += bytes.byteLength;
171 }
172 writeName(parts) {
173 const state = this.state;
174 for (let i = 0; i < parts.length; i++) {
175 const suffix = parts.slice(i).join(".");
176 const target = state.nameOffsets.get(suffix);
177 if (undefined !== target) {
178 this.writeU16(0xC000 | target);
179 return;
180 }
181
182 if (state.position < 0x4000)
183 state.nameOffsets.set(suffix, state.position);
184
185 const label = ArrayBuffer.fromString(parts[i]);
186 this.writeU8(label.byteLength);
187 this.writeBytes(new Uint8Array(label));
188 }
189
190 this.writeU8(0);
191 }
192 writeRData(type, data) {
193 if (!data)
194 return;

Callers 2

writeRDataMethod · 0.95
writeRecordMethod · 0.95

Calls 7

writeU16Method · 0.95
writeU8Method · 0.95
writeBytesMethod · 0.95
fromStringMethod · 0.80
sliceMethod · 0.65
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected