---
title: "abdellah hariti (@a-hariti) | Hashnode"
description: "I am a full stack web developer, with a focus on frontend. My main stack is Elm, Typescript, React, Svelte, and ofc node.js."
url: "https://hashnode.com/@a-hariti"
---

@a-hariti

# abdellah hariti

@a-hariti · Casablanca · Joined March 2022

### [Use Typescript generics for a type safe \`setTimeout\` and \`setInterval\`](https://abdellahcodes.com/use-typescript-generics-for-a-type-safe-settimeout-and-setinterval-1?utm_source=hashnode&utm_medium=feed)

TLDR; Here's the code: type Handler = ((...args: any\[\]) => any) | string; function safeSetTimeout<F extends Handler>( handler: F, timeout?: number, ...args: F extends string ? any\[\] : Parameters<F extends string ? never : F> ) { retu...

5 min read · [abdellahcodes.com](https://abdellahcodes.com/use-typescript-generics-for-a-type-safe-settimeout-and-setinterval-1?utm_source=hashnode&utm_medium=feed)

[Mar 23, 2022](https://hashnode.com/posts/use-typescript-generics-for-a-type-safe-settimeout-and-setinterval-1/623b018fe99839749d247905)

### [Use Typescript generics for a type safe \`setTimeout\` and \`setInterval\`](https://abdellahcodes.com/use-typescript-generics-for-a-type-safe-settimeout-and-setinterval?utm_source=hashnode&utm_medium=feed)

TLDR; Here's the code: type Handler = ((...args: any\[\]) => any) | string; function safeSetTimeout<F extends Handler>( handler: F, timeout?: number, ...args: F extends string ? any\[\] : Parameters<F extends string ? never : F> ) { retu...

5 min read · [abdellahcodes.com](https://abdellahcodes.com/use-typescript-generics-for-a-type-safe-settimeout-and-setinterval?utm_source=hashnode&utm_medium=feed)

[Mar 20, 2022](https://hashnode.com/posts/use-typescript-generics-for-a-type-safe-settimeout-and-setinterval/623720f6bef4c71aa6f11ed8)

### [Promises: run any promise with a timeout](https://abdellahcodes.com/promises-run-any-promise-with-a-timeout?utm_source=hashnode&utm_medium=feed)

Promise.race() provides a nice primitive to implement custom timeout logic for promises.

3 min read · [abdellahcodes.com](https://abdellahcodes.com/promises-run-any-promise-with-a-timeout?utm_source=hashnode&utm_medium=feed)

[Mar 18, 2022](https://hashnode.com/posts/promises-run-any-promise-with-a-timeout/62346817bef4c71aa6f0df79)

### [Promises: async/await vs .then(), how we got here and why I use both](https://abdellahcodes.com/promises-asyncawait-vs-then-how-we-got-here-and-why-i-use-both?utm_source=hashnode&utm_medium=feed)

How we got here Promises marked a huge turning point in async js, they enabled a new type of control flow that saved us from callback hell. But some people found that calling .then() multiple times was too much, too callbacky. Then after a while, we ...

3 min read · [abdellahcodes.com](https://abdellahcodes.com/promises-asyncawait-vs-then-how-we-got-here-and-why-i-use-both?utm_source=hashnode&utm_medium=feed)

[1](https://hashnode.com/posts/promises-asyncawait-vs-then-how-we-got-here-and-why-i-use-both/6231ea77dc2913039c754620) [Mar 16, 2022](https://hashnode.com/posts/promises-asyncawait-vs-then-how-we-got-here-and-why-i-use-both/6231ea77dc2913039c754620)
