JSPM

  • Created
  • Published
  • Downloads 81
  • Score
    100M100P100Q93536F
  • License Apache-2.0

Shared library used across stackpress projects

Package Exports

  • @stackpress/lib
  • @stackpress/lib/EventEmitter
  • @stackpress/lib/Exception
  • @stackpress/lib/ExpressEmitter
  • @stackpress/lib/FileLoader
  • @stackpress/lib/ItemQueue
  • @stackpress/lib/Map
  • @stackpress/lib/Nest
  • @stackpress/lib/NodeFS
  • @stackpress/lib/ReadonlyMap
  • @stackpress/lib/ReadonlyNest
  • @stackpress/lib/ReadonlySet
  • @stackpress/lib/Reflection
  • @stackpress/lib/Request
  • @stackpress/lib/Response
  • @stackpress/lib/RouteEmitter
  • @stackpress/lib/Router
  • @stackpress/lib/Session
  • @stackpress/lib/Set
  • @stackpress/lib/Status
  • @stackpress/lib/TaskQueue
  • @stackpress/lib/Terminal
  • @stackpress/lib/cookie
  • @stackpress/lib/tsconfig/cjs
  • @stackpress/lib/tsconfig/esm
  • @stackpress/lib/types

Readme

📖 Stackpress Library

NPM Package Tests Status Coverage Status Commits License

Comprehensive API documentation for the Stackpress Library - a shared library used across Stackpress projects that standardizes type definitions and provides common utilities for developers.

Installation

npm install @stackpress/lib

API Reference

Data Structures

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

Events

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

Exception

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

Queues

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

Routing

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

File System

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

Type Safety

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]>();

Browser Compatibility

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