diff --git a/src/resolverModule.ts b/src/resolverModule.ts index 9690f34..226f905 100644 --- a/src/resolverModule.ts +++ b/src/resolverModule.ts @@ -1,5 +1,5 @@ import type { DNSResult, ResolverOptions } from "./types.js"; -import { getTld } from "./util.js"; +import { getTld, isPromise } from "./util.js"; declare class ResolverRegistry { get resolvers(): Set | Promise>; @@ -23,7 +23,7 @@ export interface ResolverModule extends ResolverModuleConstructor { bypassCache: boolean ): Promise; - getSupportedTlds(): string[]; + getSupportedTlds(): string[] | Promise; } // ts-ignore @@ -40,11 +40,18 @@ export abstract class AbstractResolverModule { bypassCache: boolean ): Promise; - getSupportedTlds(): string[] { + getSupportedTlds(): string[] | Promise { return []; } - isTldSupported(domain: string): boolean { - return this.getSupportedTlds().includes(getTld(domain)); + isTldSupported(domain: string): boolean | Promise { + let supported = this.getSupportedTlds(); + if (isPromise(supported as Promise)) { + return (supported as Promise).then((supported: string[]) => { + return supported.includes(getTld(domain)); + }); + } + + return (supported as string[]).includes(getTld(domain)); } }