MCPcopy Create free account
hub / github.com/Effect-TS/effect / nameTextFromResolver

Function nameTextFromResolver

packages/platform/node-shared/src/NodeDns.ts:156–172  ·  view source on GitHub ↗
(name: string, radix: 8 | 10 = 10)

Source from the content-addressed store, hash-verified

154 * @since 4.0.0
155 */
156export const nameTextFromResolver = (name: string, radix: 8 | 10 = 10): string => {
157 if (!name.includes("\\")) return absoluteName(name)
158 const bytes: Array<number> = []
159 for (const [part, digits, escaped] of name.matchAll(nameParts)) {
160 if (digits !== undefined) {
161 const byte = Number.parseInt(digits, radix)
162 if (byte === 46 || byte === 92) bytes.push(92)
163 bytes.push(byte)
164 } else if (escaped !== undefined) {
165 if (escaped === "." || escaped === "\\") bytes.push(92)
166 bytes.push(...encoder.encode(escaped))
167 } else {
168 bytes.push(...encoder.encode(part))
169 }
170 }
171 return absoluteName(decoder.decode(Uint8Array.from(bytes)))
172}
173
174/**
175 * Converts a number of seconds that a resolver reports as a signed 32-bit

Callers 1

NodeDns.tsFile · 0.85

Calls 5

absoluteNameFunction · 0.85
encodeMethod · 0.80
fromMethod · 0.80
pushMethod · 0.65
decodeMethod · 0.45

Tested by

no test coverage detected