Comprehensive API documentation for the Stackpress Library - a shared library used across Stackpress projects that standardizes type definitions and provides common utilities for developers.
npm install @stackpress/lib
Data structures in programming are specialized formats for organizing, processing, storing, and retrieving data within a computer's memory.
Key Features:
- Type-safe nested object manipulation
- Path-based data access with dot notation
- Built-in parsers for query strings, form data, and arguments
- Chainable API for fluent data operations
Event driven designed to support event chain reactions.
Key Features:
- Priority-based event listeners
- Type-safe event maps with TypeScript generics
- Before/after hooks for event execution
- Task queue management for event handling
Enhanced error handling with expressive error reporting and stack trace support. Provides better error information than standard JavaScript errors.
Key Features:
- Template-based error messages
- Validation error aggregation
- Enhanced stack trace parsing
- HTTP status code integration
Priority-based queue implementations for managing items and tasks with FIFO ordering. Includes both generic item queues and specialized task queues.
Key Features:
- Priority-based ordering (higher numbers execute first)
- FIFO ordering within same priority levels
- Task execution with before/after hooks
- Chainable API for queue operations
Event-driven routing system with generic Request and Response wrappers that work across different platforms (HTTP, terminal, web sockets).
Key Features:
- Cross-platform request/response handling
- Parameter extraction from routes
- Event-driven architecture
- Generic type support for different mediums
Cross-platform file loading utilities for locating, loading, and importing files throughout your project and node_modules.
Key Features:
- Cross-platform path resolution
- Node modules discovery
- Dynamic import support
- Project root (@/) path shortcuts
The library is built with TypeScript and provides comprehensive type definitions. All components support generic types for enhanced type safety:
// Type-safe nested data
type ConfigMap = {
database: { host: string; port: number };
cache: { ttl: number };
};
const config = new Nest<ConfigMap>();
// Type-safe event handling
type EventMap = {
'user-login': [string, Date];
'data-update': [object];
};
const emitter = new EventEmitter<EventMap>();
// Type-safe queue operations
const queue = new TaskQueue<[number, string]>();
Most components work in both Node.js and browser environments:
- ✅ Nest - Full browser support
- ✅ EventEmitter - Full browser support
- ✅ Exception - Full browser support
- ✅ Queue - Full browser support
⚠️ FileLoader/NodeFS - Node.js only