async_retry.ts

TypeScript•Especialista

Explorer

C40
C++40
C#40
Dart40
Go40
Java40
JavaScript40
Kotlin40
Objective-C40
Perl40
PHP40
Python40
R40
Ruby40
Rust40
Shell40
Swift40
TypeScript
Iniciante10
Intermediário10
Avançado10
Especialista5
event_emitter.ts
async_retry.ts
builder_pattern.ts
type_validator.ts
generic_cache.ts
Mestre5
async_retry.ts
Click to focus
1
2
3
4
5
6
7
8
async function retry<T>(fn: () => Promise<T>, times = 3): Promise<T> {↵
   try {↵
       return await fn();↵
   } catch (e) {↵
       if (times <= 1) throw e;↵
       return retry(fn, times - 1);↵
   }↵
}
0WPM•0%•0:00•0/197(0%)|Ln 1, Col 1
UTF-8•TypeScript

Exercícios Relacionados