Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stater/repeat
A simple promise based function repeater.
https://github.com/stater/repeat
loop repeat repeatr
Last synced: 13 days ago
JSON representation
A simple promise based function repeater.
- Host: GitHub
- URL: https://github.com/stater/repeat
- Owner: stater
- License: mit
- Created: 2021-03-14T14:21:53.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-03-14T15:38:38.000Z (almost 4 years ago)
- Last Synced: 2024-12-10T02:39:56.057Z (about 1 month ago)
- Topics: loop, repeat, repeatr
- Language: TypeScript
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
A simple promise based function repeater.
**Example**
```typescript
import { repeat } from '@stater/repeat';// Repeat console log 10 times.
repeat(console.log).repeat(10);// Repeat console log until finished = true.
let finished = false;
repeat(rt => {
console.log(rt);if (rt >= 10) {
finished = true;
}
}).every('5s').until(() => finished);// Run maintenance checker every 5s.
let complete = false;
await repeat(async (rt) => {
console.log(`[Retries: ${rt}] Checking maintenance state.`);
complete = await server.checkMaintenance();
}).every('5s').until(complete);
console.log('Server maintenance completed!');
```