Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interface GenericAsyncCallback<E, T> {
- (err: E | null, ...results: T[]): void
- }
- const asyncApi = (callback: GenericAsyncCallback<Error, number>) => {
- setTimeout(() => {
- const error = Math.random() > 0.5 ? new Error(`Connection Timeout`) : null;
- if (error) callback(error);
- else callback(null, Date.now());
- }, 1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement