export function notImplemented(msg?: string): never { const message = msg ? `Not implemented: ${msg}` : "Not implemented"; throw new Error(message); } // API helpers export type MaybeNull = T | null; export type MaybeDefined = T | undefined; export type MaybeEmpty = T | null | undefined; export function intoCallbackAPI( /* eslint-disable-next-line @typescript-eslint/no-explicit-any */ func: (...args: any[]) => Promise, cb: MaybeEmpty<(err: MaybeNull, value: MaybeEmpty) => void>, /* eslint-disable-next-line @typescript-eslint/no-explicit-any */ ...args: any[] ): void { func(...args) .then((value) => cb && cb(null, value)) .catch((err) => cb && cb(err, null)); } export function intoCallbackAPIWithIntercept( /* eslint-disable-next-line @typescript-eslint/no-explicit-any */ func: (...args: any[]) => Promise, interceptor: (v: T1) => T2, cb: MaybeEmpty<(err: MaybeNull, value: MaybeEmpty) => void>, /* eslint-disable-next-line @typescript-eslint/no-explicit-any */ ...args: any[] ): void { func(...args) .then((value) => cb && cb(null, interceptor(value))) .catch((err) => cb && cb(err, null)); }