@opra/common
Version:
Opra common package
12 lines (11 loc) • 351 B
JavaScript
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;
}