summaryrefslogtreecommitdiff
path: root/op_crates/console/01_colors.js
diff options
context:
space:
mode:
authorAndy Hayden <andyhayden1@gmail.com>2021-04-30 12:51:48 -0700
committerGitHub <noreply@github.com>2021-04-30 15:51:48 -0400
commit684c357136fd44f9d5a1b8bb4402400ed1354677 (patch)
treeebc14b1d01b6643dd4d588516692dffc0f8fcb52 /op_crates/console/01_colors.js
parentabaec7a88e991188d885bede652f35d76ab4f340 (diff)
Rename crate_ops to extensions (#10431)
Diffstat (limited to 'op_crates/console/01_colors.js')
-rw-r--r--op_crates/console/01_colors.js94
1 files changed, 0 insertions, 94 deletions
diff --git a/op_crates/console/01_colors.js b/op_crates/console/01_colors.js
deleted file mode 100644
index 66dcb6e23..000000000
--- a/op_crates/console/01_colors.js
+++ /dev/null
@@ -1,94 +0,0 @@
-// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
-
-"use strict";
-
-((window) => {
- function code(open, close) {
- return {
- open: `\x1b[${open}m`,
- close: `\x1b[${close}m`,
- regexp: new RegExp(`\\x1b\\[${close}m`, "g"),
- };
- }
-
- function run(str, code) {
- return `${code.open}${str.replace(code.regexp, code.open)}${code.close}`;
- }
-
- function bold(str) {
- return run(str, code(1, 22));
- }
-
- function italic(str) {
- return run(str, code(3, 23));
- }
-
- function yellow(str) {
- return run(str, code(33, 39));
- }
-
- function cyan(str) {
- return run(str, code(36, 39));
- }
-
- function red(str) {
- return run(str, code(31, 39));
- }
-
- function green(str) {
- return run(str, code(32, 39));
- }
-
- function bgRed(str) {
- return run(str, code(41, 49));
- }
-
- function white(str) {
- return run(str, code(37, 39));
- }
-
- function gray(str) {
- return run(str, code(90, 39));
- }
-
- function magenta(str) {
- return run(str, code(35, 39));
- }
-
- function dim(str) {
- return run(str, code(2, 22));
- }
-
- // https://github.com/chalk/ansi-regex/blob/2b56fb0c7a07108e5b54241e8faec160d393aedb/index.js
- const ANSI_PATTERN = new RegExp(
- [
- "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
- "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))",
- ].join("|"),
- "g",
- );
-
- function stripColor(string) {
- return string.replace(ANSI_PATTERN, "");
- }
-
- function maybeColor(fn) {
- return !(globalThis.Deno?.noColor ?? false) ? fn : (s) => s;
- }
-
- window.__bootstrap.colors = {
- bold,
- italic,
- yellow,
- cyan,
- red,
- green,
- bgRed,
- white,
- gray,
- magenta,
- dim,
- stripColor,
- maybeColor,
- };
-})(this);