2.1.0 • Published 9 months ago

ms-humanizer v2.1.0

Weekly downloads
-
License
ISC
Repository
github
Last release
9 months ago

ms-humanizer

A package for formatting ms into a readable time format.

Installation

npm install ms-humanizer

Usage

/**
 * Formats a ms into a readable time format.
 * @param ms The input duration in milliseconds.
 * @param op Options = withMs?: boolean;
 *                     complete?: boolean;
 * @returns The formatted duration string.
 */

format(ms, op)

Examples

import { format } from 'ms-humanizer';

const durationInMilliseconds = 150000; // 2 minutes and 30 seconds

// Default formatting
const formattedDuration: string = format(durationInMilliseconds);
console.log(formattedDuration); // Output: '02:30'

// Custom formatting options
const customFormattedDuration: string = format(durationInMilliseconds, { withMs: true, complete: true });
console.log(customFormattedDuration); // Output: '02m 30s 00ms'
2.1.0

9 months ago

2.0.0

9 months ago