A lightweight JavaScript library for formatting durations (milliseconds) into human-readable strings using template patterns with placeholders for days, hours, minutes, seconds, and milliseconds. Version 0.0.2 is the latest and only release, with no active development. It differs from other duration formatters (e.g., moment.js duration, Intl.RelativeTimeFormat) by offering a simple, pattern-based syntax inspired by Ruby's String#% and does not depend on any external libraries. The library works in both Node.js and browser environments and supports zero-padding via number prefix in placeholders.
npm install duration-formatNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Formats a duration (in milliseconds) using templates with optional zero-padding placeholders.
Ensure width is large enough for expected values.
For locale-aware formatting, use Intl.DateTimeFormat or a library like moment.js.
Consider using a more maintained library like 'pretty-ms' or 'humanize-duration'.
Use only the exact placeholder names: #{D}, #{H}, #{M}, #{S}, #{MS}.Run 'npm install duration-format' in your project directory.
Use 'const df = require("duration-format")' instead of 'const { df } = require("duration-format")'.Use a bundler like webpack, or include the script via a <script> tag after converting to a browser-compatible file.
No dependency data recorded yet.