*Add ready method
This commit is contained in:
parent
ac9cc4cf0d
commit
47dc0be026
23
src/index.ts
23
src/index.ts
|
@ -1,18 +1,17 @@
|
|||
const DNS_MODULE = "AQBLKpieqOfKVRgMa8k45P4S_ILYgJmswVso4vT1qzoG-A";
|
||||
|
||||
let callModule: any,
|
||||
connectModule: any;
|
||||
let callModule: any, connectModule: any;
|
||||
|
||||
async function loadLibs() {
|
||||
if (callModule && connectModule) {
|
||||
return;
|
||||
}
|
||||
if (typeof window !== "undefined" && window?.document) {
|
||||
const pkg = (await import("libkernel"));
|
||||
const pkg = await import("libkernel");
|
||||
callModule = pkg.callModule;
|
||||
connectModule = pkg.connectModule;
|
||||
} else {
|
||||
const pkg = (await import("libkmodule"));
|
||||
const pkg = await import("libkmodule");
|
||||
callModule = pkg.callModule;
|
||||
connectModule = pkg.connectModule;
|
||||
}
|
||||
|
@ -20,7 +19,21 @@ async function loadLibs() {
|
|||
|
||||
export async function resolve(domain: string, params: any, force = false) {
|
||||
await loadLibs();
|
||||
const [resp, err] = await callModule(DNS_MODULE, "resolve", {domain, params, force});
|
||||
const [resp, err] = await callModule(DNS_MODULE, "resolve", {
|
||||
domain,
|
||||
params,
|
||||
force,
|
||||
});
|
||||
|
||||
if (err) {
|
||||
throw new Error(err);
|
||||
}
|
||||
|
||||
return resp;
|
||||
}
|
||||
export async function ready() {
|
||||
await loadLibs();
|
||||
const [resp, err] = await callModule(DNS_MODULE, "ready");
|
||||
|
||||
if (err) {
|
||||
throw new Error(err);
|
||||
|
|
Loading…
Reference in New Issue