import { MaybePromiseLike } from './maybe-promise-like'; export type Resolvable = MaybePromiseLike | (() => MaybePromiseLike); /** * Resolves a value that could be a raw value, a Promise, a function returning a value, * or a function returning a Promise. */ export async function resolve(value: Resolvable): Promise { // If it's a function, call it to get the value/promise if (typeof value === 'function') { value = (value as Function)(); } // Otherwise just resolve whatever we got (value or promise) return Promise.resolve(value as T); }