Functions
Convert bytes to a human-readable string: 1337 → 1.34 kB
Interfaces
Options for format.
- binary: boolean
Uses binary bytes (e.g. kibibyte).
- bits: boolean
Uses bits representation.
- locale: boolean | string | string[]
Uses localized number formatting. If it is set to true, uses default locale on the system. If it's set to string, uses that locale. The given string should be a BCP 47 language tag. You can also give the list of language tags.
- maximumFractionDigits: number
The maximum number of fraction digits to display. If neither
minimumFractionDigitsormaximumFractionDigitsare set, the default behavior is to round to 3 significant digits. - minimumFractionDigits: number
The minimum number of fraction digits to display. If neither
minimumFractionDigitsormaximumFractionDigitsare set, the default behavior is to round to 3 significant digits. - signed: boolean
Include plus sign for positive numbers.
String formatters and utilities for dealing with ANSI color codes.
Examples
Example 1
Example 1
import { bgBlue, bgRgb24, bgRgb8, bold, italic, red, rgb24, rgb8, } from "@std/fmt/colors"; console.log(bgBlue(italic(red(bold("Hello, World!"))))); // also supports 8bit colors console.log(rgb8("Hello, World!", 42)); console.log(bgRgb8("Hello, World!", 42)); // and 24bit rgb console.log(rgb24("Hello, World!", { r: 41, g: 42, b: 43, })); console.log(bgRgb24("Hello, World!", { r: 41, g: 42, b: 43, }));
Functions
Set background color to black.
Set background color to blue.
Set background color to bright black.
Set background color to bright blue.
Set background color to bright cyan.
Set background color to bright green.
Set background color to bright magenta.
Set background color to bright red.
Set background color to bright white.
Set background color to bright yellow.
Set background color to cyan.
Set background color to green.
Set background color to magenta.
Set background color to red.
Set background color using 24bit rgb.
color can be a number in range 0x000000 to 0xffffff or
an Rgb.
Set background color using paletted 8bit colors. https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
Set background color to white.
Set background color to yellow.
Set text color to black.
Set text color to blue.
Make the text bold.
Set text color to bright black.
Set text color to bright blue.
Set text color to bright cyan.
Set text color to bright green.
Set text color to bright magenta.
Set text color to bright red.
Set text color to bright white.
Set text color to bright yellow.
Set text color to cyan.
The text emits only a small amount of light.
Get whether text color change is enabled or disabled.
Set text color to gray.
Set text color to green.
Invert background color and text color.
Make the text italic.
Set text color to magenta.
Set text color to red.
Reset the text modified.
Set text color using 24bit rgb.
color can be a number in range 0x000000 to 0xffffff or
an Rgb.
Set text color using paletted 8bit colors. https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
Set changing text color to enabled or disabled
Put horizontal line through the center of the text.
Remove ANSI escape codes from the string.
Make the text underline.
Set text color to white.
Set text color to yellow.
Remove ANSI escape codes from the string.
Interfaces
Format milliseconds to time duration.
Functions
Format milliseconds to time duration.
Interfaces
Options for format.
- ignoreZero: boolean
Whether to ignore zero values. With style="narrow" | "full", all zero values are ignored. With style="digital", only values in the ends are ignored.
- style: "narrow" | "digital" | "full"
"narrow" for "0d 0h 0m 0s 0ms..." "digital" for "00:00:00:00:000..." "full" for "0 days, 0 hours, 0 minutes,..."
sprintf and printf for printing formatted strings to
stdout.
Functions
Converts and format a variable number of args as is specified by format.
printf writes the formatted string to standard output.
Converts and format a variable number of args as is specified by format.
sprintf returns the formatted string.