mirror of
https://github.com/denoland/std.git
synced 2024-11-21 20:50:22 +00:00
BREAKING(console): remove std/console
(#4643)
This commit is contained in:
parent
80cff5c3e7
commit
8f60a3546b
1
.github/workflows/title.yml
vendored
1
.github/workflows/title.yml
vendored
@ -43,7 +43,6 @@ jobs:
|
||||
bytes
|
||||
cli
|
||||
collections
|
||||
console
|
||||
crypto
|
||||
csv
|
||||
data_structures
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -5,7 +5,7 @@
|
||||
**/cov/
|
||||
crypto/_wasm/target
|
||||
deno.lock
|
||||
console/testdata/unicode_width_crate/target
|
||||
cli/testdata/unicode_width_crate/target
|
||||
html_cov/
|
||||
cov.lcov
|
||||
http/testdata/%25A.txt
|
||||
|
@ -99,7 +99,6 @@ requirements:
|
||||
| [bytes](https://jsr.io/@std/bytes) | Settled | [![JSR](https://jsr.io/badges/@std/bytes)](https://jsr.io/@std/bytes) |
|
||||
| [cli](https://jsr.io/@std/cli) | Unstable | [![JSR](https://jsr.io/badges/@std/cli)](https://jsr.io/@std/cli) |
|
||||
| [collections](https://jsr.io/@std/collections) | Settled | [![JSR](https://jsr.io/badges/@std/collections)](https://jsr.io/@std/collections) |
|
||||
| [console](https://jsr.io/@std/console) | Deprecated | [![JSR](https://jsr.io/badges/@std/console)](https://jsr.io/@std/console) |
|
||||
| [crypto](https://jsr.io/@std/crypto) | Settled | [![JSR](https://jsr.io/badges/@std/crypto)](https://jsr.io/@std/crypto) |
|
||||
| [csv](https://jsr.io/@std/csv) | Settled | [![JSR](https://jsr.io/badges/@std/csv)](https://jsr.io/@std/csv) |
|
||||
| [data_structures](https://jsr.io/@std/data_structures) | Unstable | [![JSR](https://jsr.io/badges/@std/data-structures)](https://jsr.io/@std/data-structures) |
|
||||
|
@ -38,7 +38,6 @@ type Mod =
|
||||
| "bytes"
|
||||
| "cli"
|
||||
| "collections"
|
||||
| "console"
|
||||
| "crypto"
|
||||
| "csv"
|
||||
| "data_structures"
|
||||
@ -79,7 +78,6 @@ const ENTRYPOINTS: Record<Mod, string[]> = {
|
||||
bytes: ["mod.ts"],
|
||||
cli: ["mod.ts"],
|
||||
collections: ["mod.ts"],
|
||||
console: ["mod.ts"],
|
||||
crypto: ["mod.ts"],
|
||||
csv: ["mod.ts"],
|
||||
data_structures: ["mod.ts"],
|
||||
@ -129,7 +127,6 @@ const STABILITY: Record<Mod, DepState> = {
|
||||
bytes: "Stable",
|
||||
cli: "Unstable",
|
||||
collections: "Stable",
|
||||
console: "Unstable",
|
||||
crypto: "Stable",
|
||||
csv: "Stable",
|
||||
data_structures: "Unstable",
|
||||
|
@ -1,25 +0,0 @@
|
||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
// This module is browser compatible.
|
||||
|
||||
/**
|
||||
* Functions for console-related tasks such as TTY text layout.
|
||||
*
|
||||
* ## Unicode width
|
||||
*
|
||||
* {@linkcode unicodeWidth} calculates the physical width of a string in a
|
||||
* TTY-like environment.
|
||||
*
|
||||
* ```ts
|
||||
* import { unicodeWidth } from "https://deno.land/std@$STD_VERSION/console/unicode_width.ts";
|
||||
*
|
||||
* unicodeWidth("天地玄黃宇宙洪荒"); // 16
|
||||
* ```
|
||||
*
|
||||
* @deprecated Use {@link https://jsr.io/@std/cli | std/cli} instead. This
|
||||
* module will be removed once the Standard Library migrates to
|
||||
* {@link https://jsr.io/ | JSR}.
|
||||
*
|
||||
* @module
|
||||
*/
|
||||
|
||||
export * from "./unicode_width.ts";
|
@ -1,48 +0,0 @@
|
||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
// This module is browser compatible.
|
||||
// Ported from unicode_width rust crate, Copyright (c) 2015 The Rust Project Developers. MIT license.
|
||||
|
||||
import { unicodeWidth as _unicodeWidth } from "../cli/unicode_width.ts";
|
||||
|
||||
/**
|
||||
* Calculate the physical width of a string in a TTY-like environment. This is
|
||||
* useful for cases such as calculating where a line-wrap will occur and
|
||||
* underlining strings.
|
||||
*
|
||||
* The physical width is given by the number of columns required to display
|
||||
* the string. The number of columns a given unicode character occupies can
|
||||
* vary depending on the character itself.
|
||||
*
|
||||
* @param str The string to measure.
|
||||
* @returns The unicode width of the string.
|
||||
*
|
||||
* @example Calculating the unicode width of a string
|
||||
* ```ts
|
||||
* import { unicodeWidth } from "https://deno.land/std@$STD_VERSION/console/unicode_width.ts";
|
||||
*
|
||||
* unicodeWidth("hello world"); // 11
|
||||
* unicodeWidth("天地玄黃宇宙洪荒"); // 16
|
||||
* unicodeWidth("fullwidth"); // 18
|
||||
* ```
|
||||
*
|
||||
* @example Calculating the unicode width of a color-encoded string
|
||||
* ```ts
|
||||
* import { unicodeWidth } from "https://deno.land/std@$STD_VERSION/console/unicode_width.ts";
|
||||
* import { stripAnsiCode } from "https://deno.land/std@$STD_VERSION/fmt/colors.ts";
|
||||
*
|
||||
* unicodeWidth(stripAnsiCode("\x1b[36mголубой\x1b[39m")); // 7
|
||||
* unicodeWidth(stripAnsiCode("\x1b[31m紅色\x1b[39m")); // 4
|
||||
* unicodeWidth(stripAnsiCode("\x1B]8;;https://deno.land\x07🦕\x1B]8;;\x07")); // 2
|
||||
* ```
|
||||
*
|
||||
* Use
|
||||
* {@linkcode https://jsr.io/@std/fmt/doc/colors/~/stripAnsiCode | stripAnsiCode}
|
||||
* to remove ANSI escape codes from a string before passing it to
|
||||
* {@linkcode unicodeWidth}.
|
||||
*
|
||||
* @deprecated Use {@linkcode unicodeWidth} from `std/cli` instead. This will be
|
||||
* removed once the Standard Library migrates to {@link https://jsr.io/ | JSR}.
|
||||
*/
|
||||
export function unicodeWidth(str: string): number {
|
||||
return _unicodeWidth(str);
|
||||
}
|
Loading…
Reference in New Issue
Block a user