A lightweight utility to parse and format ISO 8601 duration strings (used by YouTube API v3) into human-readable time strings (e.g., '3:11') or total seconds. v1.0.0 is the current stable version. It focuses solely on duration formatting/conversion with no dependencies, making it ideal for serverless or browser projects. Unlike moment-duration-format, it is YouTube-API-tailored and much smaller.
npm install youtube-durationNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to import and use both format and toSecond functions with various ISO 8601 duration strings.
Validate duration format before calling functions. Use regex /^PT?\d+[HMS]/ or similar.
Check for zero second input and handle separately if needed.
Use require() or dynamic import. For ESM projects, consider a bundler that can consume CJS.
Run 'npm install youtube-duration' and use require('youtube-duration').Use named import: const { format } = require('youtube-duration');Double-check package name and install it.
No dependency data recorded yet.