duriso

A lightweight 658-byte package for parsing and serializing ISO 8601 Duration strings.


The Idea

Duriso is an ultra-lightweight JavaScript package designed to handle ISO 8601 duration strings with precision and efficiency. At just 658 bytes, it provides robust parsing and serialization capabilities without the bloat of larger date/time libraries. Whether you're working with API responses, scheduling systems, or time-based calculations, duriso offers a minimal footprint solution for duration handling.


What It Offers

ISO 8601 Duration Parsing

Convert duration strings to structured objects:

  • Parse full duration strings like P3Y6M2W4DT12H30M5S
  • Support for all duration components (years, months, weeks, days, hours, minutes, seconds)
  • Returns clean, typed duration objects
  • Handles time-only durations like PT12H30M5S

Duration Serialization

Transform duration objects back to ISO 8601 strings:

  • Serialize complete duration objects with all time components
  • Flexible input—include only the components you need
  • Generates compliant ISO 8601 formatted strings
  • Perfect for API communication and data persistence

Universal Module Support

Works in any JavaScript environment:

  • ES Modules - Modern import/export syntax (recommended)
  • CommonJS - Traditional Node.js require syntax
  • UMD - Direct browser usage via unpkg CDN
  • Zero configuration required for any environment

Key Features

  • Tiny footprint: Only 658 bytes—minimal impact on bundle size
  • Zero dependencies: No external packages required
  • TypeScript-ready: Full type definitions included
  • Bidirectional: Both parse and serialize operations
  • Standards-compliant: Follows ISO 8601 duration specification
  • Universal compatibility: ESM, CommonJS, and UMD builds included

Why Choose duriso

  • Smallest possible implementation without sacrificing functionality
  • No need for heavy date libraries when you only need duration handling
  • Battle-tested ISO 8601 compliance for reliable parsing
  • Clean API with just two functions—easy to learn and use
  • Perfect for performance-critical applications where bundle size matters

FAQs

  • What is ISO 8601 duration format? A standard format for representing time durations (e.g., P3Y6M4DT12H30M5S means 3 years, 6 months, 4 days, 12 hours, 30 minutes, 5 seconds)
  • Why not use a larger library? If you only need duration handling, why add megabytes when 658 bytes will do?
  • Does it handle fractional seconds? Yes, duriso supports decimal seconds in duration strings
  • Can I use only some components? Absolutely—include only the time components you need (e.g., just hours and minutes)
  • Is it production-ready? Yes—small size doesn't mean lack of robustness. It's fully tested and standards-compliant

Tech

Pure JavaScript with ESM, CommonJS, and UMD builds. TypeScript definitions included. Zero dependencies.