Skip to main content

@std/fmt@1.0.6
Built and signed on GitHub Actions

Utilities for formatting values, such as adding colors to text, formatting durations, printf utils, formatting byte numbers.

This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score
100%
Published
3 weeks ago (1.0.6)

Format milliseconds to time duration.

import { format } from "@std/fmt/duration";
import { assertEquals } from "@std/assert";

assertEquals(format(99674, { style: "digital" }), "00:00:01:39:674:000:000");

assertEquals(format(99674), "0d 0h 1m 39s 674ms 0µs 0ns");

assertEquals(format(99674, { ignoreZero: true }), "1m 39s 674ms");

assertEquals(format(99674, { style: "full", ignoreZero: true }), "1 minute, 39 seconds, 674 milliseconds");

Functions

f
format

Format milliseconds to time duration.

Interfaces

Add Package

deno add jsr:@std/fmt

Import symbol

import * as mod from "@std/fmt/duration";

---- OR ----

Import directly with a jsr specifier

import * as mod from "jsr:@std/fmt/duration";

Add Package

npx jsr add @std/fmt

Import symbol

import * as mod from "@std/fmt/duration";

Add Package

yarn dlx jsr add @std/fmt

Import symbol

import * as mod from "@std/fmt/duration";

Add Package

pnpm dlx jsr add @std/fmt

Import symbol

import * as mod from "@std/fmt/duration";

Add Package

bunx jsr add @std/fmt

Import symbol

import * as mod from "@std/fmt/duration";