export interface AmpersandMethodOptions { success: (model: T) => void; error: (model: T, error: Error) => void; validate?: boolean; } export function promisifyAmpersandMethod( fn: (options: AmpersandMethodOptions) => void ): () => Promise { return (...args) => new Promise((resolve, reject) => { fn(...args, { success: (model: T) => { resolve(model); }, error: (model: T, error: Error) => { reject(error); }, }); }); }