[utils] Add utility to wait for a designated amount of time
- Dominant language
- TypeScript
- Stars
- 413
- Forks
- 308
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 253
Description
It's fairly common in many of our projects to have some kind of helper that looks like this:
``` typescript
async function waitFor(duration: number): Promise {
return new Promise((resolve) => setTimeout(resolve, duration));
}
```
See:
- https://github.com/MetaMask/test-dapp/blob/0ea6cc7a496eb0049c735b4deffcc0ba9b234281/src/index.js#L624
- https://github.com/MetaMask/metamask-sdk/blob/55c1dd327affdef9dd6c308898d1f6b808a1ad8f/packages/sdk/src/utils/wait.ts#L1
- https://github.com/MetaMask/metamask-extension/blob/0e5c05ad3b68f80712b976583e4092551bc4aaee/development/lib/retry.js#L34
- https://github.com/MetaMask/metamask-desktop/blob/92fb331eea05004b03d810ba474dcd3e4d9f7fb1/packages/app/src/app/utils/sleep.ts#L1
- https://github.com/MetaMask/eth-json-rpc-infura/blob/dc19a35091a436f8c654514a40deac047866f9f5/src/create-infura-middleware.ts#L248C1-L248C1
We should add that here too.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing the wait implementations linked in test-dapp/src/index.js, metamask-sdk/packages/sdk/src/utils/wait.ts, metamask-extension/development/lib/retry.js, metamask-desktop/packages/app/src/app/utils/sleep.ts, and eth-json-rpc-infura/src/create-infura-middleware.ts. Then locate the appropriate shared utility package in this monorepo, add the reusable wait helper there, and run that package's tests and checks to confirm it is available and passes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100