sparkletown/sparkle

View on GitHub
src/utils/promise.ts

Summary

Maintainability
A
0 mins
Test Coverage
export const wait = async (ms: number): Promise<unknown> =>
  new Promise((resolve) => {
    setTimeout(resolve, ms);
  });

export const waitAtLeast = async <T>(
  ms: number,
  other: Promise<T>
): Promise<T> => (await Promise.all([other, wait(ms)]))[0] as T;