*Refactor resolvers getter to return a Set of resolver client classes

This commit is contained in:
Derrick Hammer 2023-02-19 20:57:12 -05:00
parent 2bf62cbd3e
commit 827505438d
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 10 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import {
DNSResult, DNSResult,
ResolverOptions, ResolverOptions,
} from "@lumeweb/libresolver"; } from "@lumeweb/libresolver";
import { createModule, ResolverModule } from "./module.js";
const MODULE = "PACYNuYbp_5hgCjMK16EGcytB9QCxDLe4_uitahwePdeaA"; const MODULE = "PACYNuYbp_5hgCjMK16EGcytB9QCxDLe4_uitahwePdeaA";
@ -14,8 +15,14 @@ export class DnsClient extends Client {
public async clear(): Promise<void> { public async clear(): Promise<void> {
return this.callModuleReturn("clear"); return this.callModuleReturn("clear");
} }
get resolvers(): Promise<string[]> { get resolvers(): Promise<Set<ResolverModule>> {
return this.callModuleReturn("getResolvers"); return this.callModuleReturn("getResolvers").then((resolvers: string[]) => {
return new Set(
resolvers.map((resolver: string): ResolverModule => {
return createModule(resolver, this);
})
);
});
} }
public async ready(): Promise<void> { public async ready(): Promise<void> {
return this.callModuleReturn("ready"); return this.callModuleReturn("ready");
@ -30,3 +37,4 @@ export class DnsClient extends Client {
} }
export const createClient = factory<DnsClient>(DnsClient, MODULE); export const createClient = factory<DnsClient>(DnsClient, MODULE);
export * from "./module.js";