MCPcopy Index your code
hub / github.com/nodejs/node / writeIPv6

Function writeIPv6

test/common/dns.js:167–182  ·  view source on GitHub ↗
(ip)

Source from the content-addressed store, hash-verified

165}
166
167function writeIPv6(ip) {
168 const parts = ip.replace(/^:|:$/g, '').split(':');
169 const buf = Buffer.alloc(16);
170
171 let offset = 0;
172 for (const part of parts) {
173 if (part === '') {
174 offset += 16 - 2 * (parts.length - 1);
175 } else {
176 buf.writeUInt16BE(parseInt(part, 16), offset);
177 offset += 2;
178 }
179 }
180
181 return buf;
182}
183
184function writeDomainName(domain) {
185 return Buffer.concat(domain.split('.').map((label) => {

Callers 1

writeDNSPacketFunction · 0.85

Calls 2

allocMethod · 0.80
splitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…