UNPKG

@opra/common

Version:
12 lines (11 loc) 351 B
import { isConstructor } from '@jsopen/objects'; import promisify from 'putil-promisify'; export async function resolveThunk(thunk) { thunk = promisify.isPromise(thunk) ? await thunk : thunk; if (typeof thunk === 'function') { if (isConstructor(thunk)) return thunk; return await thunk(); } return thunk; }