import { cancelable } from './cancellable-promise.utils'; type CbLike = (res: (res: T) => void) => void; export const promisify = async ( cb: CbLike, _this?: Object ): Promise => { return cancelable( new Promise((res) => { let _cb = cb; if (_this) { _cb = cb.bind(_this); } _cb((_r) => res(_r)); }) ); };