MCPcopy Create free account
hub / github.com/denoland/std / createColor

Function createColor

internal/build_message.ts:26–44  ·  view source on GitHub ↗
(
  diffType: DiffType,
  /**
   * TODO(@littledivy): Remove this when we can detect true color terminals. See
   * https://github.com/denoland/std/issues/2575.
   */
  background = false,
)

Source from the content-addressed store, hash-verified

24 * ```
25 */
26export function createColor(
27 diffType: DiffType,
28 /**
29 * TODO(@littledivy): Remove this when we can detect true color terminals. See
30 * https://github.com/denoland/std/issues/2575.
31 */
32 background = false,
33): (s: string) => string {
34 switch (diffType) {
35 case "added":
36 return (s) => background ? bgGreen(white(s)) : green(bold(s));
37 case "removed":
38 return (s) => background ? bgRed(white(s)) : red(bold(s));
39 case "truncation":
40 return gray;
41 default:
42 return white;
43 }
44}
45
46/**
47 * Prefixes `+` or `-` in diff output.

Callers 2

buildMessageFunction · 0.85

Calls 6

bgGreenFunction · 0.90
whiteFunction · 0.90
greenFunction · 0.90
boldFunction · 0.90
bgRedFunction · 0.90
redFunction · 0.90

Tested by

no test coverage detected