Compare commits

..

No commits in common. "1551e0aa75cba001f5cf257e7a25ae734f1aea52" and "aba5fad2c74c44da89921b52488d957c12311098" have entirely different histories.

4 changed files with 11 additions and 24 deletions

View File

@ -18,7 +18,7 @@ export interface ResolverModule extends ResolverModuleConstructor {
options: ResolverOptions, options: ResolverOptions,
bypassCache: boolean bypassCache: boolean
): Promise<DNSResult>; ): Promise<DNSResult>;
getSupportedTlds(): string[] | Promise<string[]>; getSupportedTlds(): string[];
} }
export declare abstract class AbstractResolverModule { export declare abstract class AbstractResolverModule {
protected resolver: ResolverRegistry; protected resolver: ResolverRegistry;
@ -28,8 +28,8 @@ export declare abstract class AbstractResolverModule {
options: ResolverOptions, options: ResolverOptions,
bypassCache: boolean bypassCache: boolean
): Promise<DNSResult>; ): Promise<DNSResult>;
getSupportedTlds(): string[] | Promise<string[]>; getSupportedTlds(): string[];
isTldSupported(domain: string): boolean | Promise<boolean>; isTldSupported(domain: string): boolean;
} }
export {}; export {};
//# sourceMappingURL=resolverModule.d.ts.map //# sourceMappingURL=resolverModule.d.ts.map

View File

@ -1 +1 @@
{"version":3,"file":"resolverModule.d.ts","sourceRoot":"","sources":["../src/resolverModule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAG7D,OAAO,OAAO,gBAAgB;IAC5B,IAAI,SAAS,IAAI,GAAG,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC;IACpE,OAAO,CACL,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,eAAe,EACzB,WAAW,CAAC,EAAE,OAAO,GACpB,OAAO,CAAC,SAAS,CAAC;IACrB,QAAQ,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IACxC,KAAK,IAAI,IAAI;CACd;AAED,MAAM,WAAW,yBAAyB;IACxC,KAAK,QAAQ,EAAE,gBAAgB,OAAE;CAClC;AAED,MAAM,WAAW,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AAE,eAAe,EACxB,WAAW,EAAE,OAAO,GACnB,OAAO,CAAC,SAAS,CAAC,CAAC;IAEtB,gBAAgB,IAAI,MAAM,EAAE,CAAC;CAC9B;AAGD,8BAAsB,sBAAsB;IAC1C,SAAS,CAAC,QAAQ,EAAE,gBAAgB,CAAC;gBAEzB,QAAQ,EAAE,gBAAgB;IAItC,QAAQ,CAAC,OAAO,CACd,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,eAAe,EACxB,WAAW,EAAE,OAAO,GACnB,OAAO,CAAC,SAAS,CAAC;IAErB,gBAAgB,IAAI,MAAM,EAAE;IAI5B,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO;CAGxC"}

View File

@ -1,4 +1,4 @@
import { getTld, isPromise } from "./util.js"; import { getTld } from "./util.js";
// ts-ignore // ts-ignore
export class AbstractResolverModule { export class AbstractResolverModule {
resolver; resolver;
@ -9,12 +9,6 @@ export class AbstractResolverModule {
return []; return [];
} }
isTldSupported(domain) { isTldSupported(domain) {
let supported = this.getSupportedTlds(); return this.getSupportedTlds().includes(getTld(domain));
if (isPromise(supported)) {
return supported.then((supported) => {
return supported.includes(getTld(domain));
});
}
return supported.includes(getTld(domain));
} }
} }

View File

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