diff --git a/layer/utils/async.ts b/layer/utils/async.ts new file mode 100644 index 00000000..8f18ee56 --- /dev/null +++ b/layer/utils/async.ts @@ -0,0 +1,20 @@ +const sleep = (timeout: number): Promise => + new Promise((resolve) => setTimeout(resolve, timeout)) + +export const sharedDelayPromiseCall = async ( + promise: () => Promise, + seconds: number +) => { + await sleep(seconds).then(async () => { + await promise() + }) +} + +export const sharedBackupPromiseCall = async (promise: () => Promise) => { + await promise() + await sleep(1000) + + sleep(3000).then(async () => { + await promise() + }) +}