Function createColor
- create
Color (diffType, background?): ((s: string) => string) 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
Example: Usage
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"));- diffType: DiffType
Colors the output of assertion diffs.