*Refactor resolvers getter to return a Set of resolver client classes
This commit is contained in:
parent
2bf62cbd3e
commit
827505438d
12
src/index.ts
12
src/index.ts
|
@ -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";
|
||||||
|
|
Loading…
Reference in New Issue