Function createColor

  • Colors the output of assertion diffs.

    Parameters

    • diffType: DiffType

      Difference type, either added or removed.

    • background: boolean = false

      If true, colors the background instead of the text.

    Returns ((s: string) => string)

    A function that colors the input string.

      • (s): string
      • Parameters

        • s: string

        Returns string

    import { createColor } from "@std/internal";
    import { assertEquals } from "@std/assert";
    import { bold, green, red, white } from "@std/fmt/colors";

    assertEquals(createColor("added")("foo"), green(bold("foo")));
    assertEquals(createColor("removed")("foo"), red(bold("foo")));
    assertEquals(createColor("common")("foo"), white("foo"));