import { ImageInfo } from './models' ; export type Callback = ( error : Error | null , info ? : ImageInfo ) => void ; type PromiseResolver < T > = ( value : T ) => void ; type PromiseRejecter = ( error : Error ) => void ; export function ensurePromiseCallback ( callback ? ) { if ( typeof callback === 'function' ) { return [ callback ] ; } let promiseResolve , promiseReject ; const promise = new Promise ( ( resolve , reject ) => { promiseResolve = resolve ; promiseReject = reject ; } ) ; return [ ( err , info ? ) => { if ( err ) { return promiseReject ( err ) ; } return promiseResolve ( info ! ) ; } , promise ] ; }