File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed
Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ Provides utilities for formatting text of different types:
2+
3+ - [ Human-readable bytes] ( https://jsr.io/@std/fmt/doc/bytes/~ )
4+ - [ Styles for the CLI] ( https://jsr.io/@std/fmt/doc/colors/~ )
5+ - [ Time duration] ( https://jsr.io/@std/fmt/doc/duration/~ )
6+ - [ Printing formatted strings to stdout] ( https://jsr.io/@std/fmt/doc/printf/~ )
7+
8+ ``` ts
9+ import { format } from " @std/fmt/bytes" ;
10+ import { red } from " @std/fmt/colors" ;
11+
12+ console .log (red (format (1337 ))); // Prints "1.34 kB"
13+ ```
Original file line number Diff line number Diff line change 44// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
55// This module is browser compatible.
66
7+ /**
8+ * Convert bytes to a human-readable string: 1337 → 1.34 kB
9+ *
10+ * Based on {@link https://github.com/sindresorhus/pretty-bytes | pretty-bytes}.
11+ * A utility for displaying file sizes for humans.
12+ *
13+ * ```ts
14+ * import { format } from "@std/fmt/bytes";
15+ * import { assertEquals } from "@std/assert";
16+ *
17+ * assertEquals(format(1337), "1.34 kB");
18+ * assertEquals(format(100), "100 B");
19+ * ```
20+ * @module
21+ */
22+
723type LocaleOptions = {
824 minimumFractionDigits ?: number ;
925 maximumFractionDigits ?: number ;
Original file line number Diff line number Diff line change 66/**
77 * String formatters and utilities for dealing with ANSI color codes.
88 *
9+ * > ![IMPORTANT]
10+ * > If printing directly to the console, it's recommended to style console
11+ * > output using CSS (guide
12+ * > {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/console#styling_console_output | here}).
13+ *
914 * This module supports `NO_COLOR` environmental variable disabling any coloring
1015 * if `NO_COLOR` is set.
1116 *
You can’t perform that action at this time.
0 commit comments