fix: add factory back in

This commit is contained in:
Derrick Hammer 2023-06-28 00:32:39 -04:00
parent 021fcf424e
commit 480fdf23e8
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 12 additions and 1 deletions

View File

@ -61,3 +61,14 @@ export abstract class Client extends EventEmitter {
return ret[0]; return ret[0];
} }
} }
type ClientConstructor<U> = new (module: string, ...args: any[]) => U;
export const factory = function <T extends Client = Client>(
type: ClientConstructor<T>,
module: string,
) {
return function (...args: any): T {
return new type(module, ...args);
};
};

View File

@ -3,4 +3,4 @@ export { ActiveQuery, addHandler, handleMessage } from "./messages.js";
export { callModule, connectModule, newKernelQuery } from "./queries.js"; export { callModule, connectModule, newKernelQuery } from "./queries.js";
export { getDataFromKernel, getKey } from "./key.js"; export { getDataFromKernel, getKey } from "./key.js";
export { moduleQuery, presentKeyData } from "./types.js"; export { moduleQuery, presentKeyData } from "./types.js";
export { Client } from "./client.js"; export { Client, factory } from "./client.js";