Skip to content

Commit

Permalink
chore: layer add async functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasRalee committed Dec 29, 2023
1 parent 7653d2c commit 0bb9259
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions layer/utils/async.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const sleep = (timeout: number): Promise<void> =>
new Promise((resolve) => setTimeout(resolve, timeout))

export const sharedDelayPromiseCall = async <T>(
promise: () => Promise<T>,
seconds: number
) => {
await sleep(seconds).then(async () => {
await promise()
})
}

export const sharedBackupPromiseCall = async <T>(promise: () => Promise<T>) => {
await promise()
await sleep(1000)

sleep(3000).then(async () => {
await promise()
})
}

0 comments on commit 0bb9259

Please sign in to comment.