Skip to content

Annotations Design Patterns

Design patterns, resilience and caching for TypeScript, with standard TC39 decorators or composable functions. Zero runtime dependencies, strict types and granular imports.

Ventana de terminal
npm install annotations-design-patterns

These docs cover 2.3.0. The migration guide identifies new features and the APIs that retain experimental status.

import { Singleton, Retry, Timeout, Fallback } from 'annotations-design-patterns';
@Singleton
class ApiClient {
@Fallback<User[]>([])
@Retry({ attempts: 3, delayMs: 200, backoffFactor: 2 })
@Timeout(5000)
async fetchUsers(): Promise<User[]> {
/* ... */
}
}
import { fallback, retry, timeout } from 'annotations-design-patterns/operators';
import { pipe } from 'annotations-design-patterns/pipe';
const fetchUsers = pipe(
loadUsers,
fallback<object, readonly [], User[]>([]),
retry({ attempts: 3, delayMs: 200, backoffFactor: 2 }),
timeout(5000),
);

See the decorator, operator and 2.3 migration guides. The shared API reference has its own symbol search in English; guide search uses the selected language.