How ignromanov/big-decimal works
Main Components Identification
The system should be represented as a modular library with these core components:
a) Core Layer:
• Base Module (Abstract implementations and types)
• Config Module (Configuration and rounding modes)
• Implementations Module (Concrete implementations)
b) Operations Layer:
• Formatting Operations
• Mathematical Operations (implied by the README's API section)
c) Utils Layer:
• Parsing Utilities
d) Error Handling System:
• Various Error Types (Decimal, Factory, etc.)
┌─ External Interface Layer ─────────────────┐
• (Public API - BigDecimal & BD namespace) │
• ┬───────────────────────┘
• ↓
┌─ Core Layer ──────────────────────────────┐
• ┌─────────────┐ ┌──────────┐ ┌──────────┐ │
• Base Abstract│ │ Config │ │ Impl │ │
• ┘ └──────────┘ └──────────┘ │
• ┬───────────────────────┘
• ↓
┌─ Operations Layer ────────────────────────┐
• ┌─────────────┐ ┌──────────────────────┐ │
• Formatting │ │ Mathematical Ops │ │
• ┘ └──────────────────────┘ │
• ┬───────────────────────┘
• ↓
┌─ Utils Layer ──────────────────────────────┐
• ┌─────────────┐ │
• Parsing │ │
• ┘ │
• ┬───────────────────────┘
• ↓
┌─ Error Handling Layer ──────────────────────┐
• ┌─────────────┐ ┌──────────┐ ┌──────────┐ │
• Decimal Error│ │Factory Er│ │Type Error │ │
• ┘ └──────────┘ └──────────┘ │
• ┘
Key Architectural Patterns to Highlight
• Immutable data pattern (all operations return new instances)
• Factory pattern (static creation methods)
• Strategy pattern (for different rounding modes)
• Chain of responsibility (for operation handling)
Implementation Details
• Tree-shaking support indication
• TypeScript type safety implementation
• Arbitrary precision handling mechanism
• Error handling flow
The type safety system
• How the different components interact
• The flow of data through the system
• Where to find specific functionality
• How to extend the system
• The error handling mechanisms
• The type safety implementation