Open this example in the interactive library
Source code
const load = async (id: number): Promise<{ id: number; ready: boolean }> => ({
id,
ready: true,
});
console.log(
await ((fn: () => number | Promise<number>) => Promise.resolve(fn()))(
() => 8,
),
);
Sample output
8
