@apiref-examples/core package-index
@apiref-examples/core
Example package demonstrating apiref's documentation generation features.
This package showcases:
- Multi-signature methods and functions — Methods and functions with multiple overloads/call signatures
- Generic types and constraints — Generics with extends clauses, type parameters, and defaults
- Classes with various member types — Methods, properties, constructors, static members, abstract classes
- Interfaces and type aliases — Complex type definitions and unions
- Enums and namespaces — Categorized constants and module organization
- Decorators and metadata — JSDoc/TSDoc comments, tags, and examples
- Fluent APIs — Builder patterns and method chaining
- Error handling — Custom error types and exception handling
- Async patterns — Promises, async/await, and callback patterns
Building
Generate TypeDoc JSON:
vp dlx typedocRender documentation:
vp run renderModules
Core (index.ts)
Generic utilities and foundational types:
Cache<K, V>— Multi-signature generic cache with fallback factoryDataProcessor<T, R>— Generic data processor with sync/async overloadsBuilder<T>— Fluent builder patternparse()/parseAsync()— Functions with multiple signaturesResult<T, E>— Generic result type
Data (data.ts)
Data access and repository patterns:
Repository<T, ID>— Abstract repository with CRUD operationsQueryBuilder<T>— Fluent database query builder with multipleorderBysignaturesEventEmitter<Events>— Generic event system- Pagination and filtering utilities
Utils (utils.ts)
Functional utilities:
debounce<T>()— Function debouncingthrottle<T>()— Call throttlingretry<T>()— Exponential backoff retrydeepMerge<T>()— Recursive object mergingmemoize<T>()— Function memoizationgroupBy<T, K>()— Array grouping- Type guards:
isDefined(),isPromise() - Assertion helpers:
assert()
Features Demonstrated
Multi-Signature Methods
Methods like Cache.get() and QueryBuilder.orderBy() have multiple overloads:
// Cache with two signatures
get(key: K): V | undefined;
get<F extends () => V>(key: K, factory: F): V;
// QueryBuilder with single or multiple fields
orderBy(field: keyof T, direction?: "asc" | "desc"): this;
orderBy(fields: (keyof T)[], direction?: "asc" | "desc"): this;Generic Types with Constraints
Classes and functions use generic constraints:
class Cache<K extends string | number, V> { ... }
class Repository<T extends { id: ID }, ID extends string | number> { ... }
function createTuple<T extends readonly any[]>(items: T): T { ... }Complex Type Definitions
Result types, unions, and conditional types:
type Result<T, E = string> = { ok: true; value: T } | { ok: false; error: E };Async/Await and Promises
Multiple async patterns:
async function retry<T>(
operation: () => Promise<T>,
maxAttempts?: number
): Promise<T> { ... }
async function pipe<T>(
initial: T,
operations: Array<(value: T) => Promise<T>>
): Promise<T> { ... }Modules
@apiref-examples/core module
Example package demonstrating apiref's documentation generation features.
This package showcases:
- Multi-signature methods and functions
- Callable interfaces with multiple call signatures
- Generic types and constraints
- Mapped types with readonly and optional modifiers
- Classes with various member types
- Interfaces and type aliases
- Enums and deeply nested namespaces
- Re-exported modules as namespaces
@apiref-examples/core/plugins module
Plugin system with nested configuration.
@apiref-examples/core/utils module
Utility functions and helpers.
@apiref-examples/core/web module
An example Elysia application to demonstrate the capabilities of the API reference generator.