Reference · Map, locator and quiz elements
readMapColorsfunction
Parse region colours, including native CSS colours with commas inside rgb()/hsl().
Import it
import { readMapColors } from "@johnmorrisdotca/chizu/element";
Also exported from: @johnmorrisdotca/chizu/element/define
Definition
function readMapColors(text: string | null): Record<string, string> | null
Parameters
| Name | Type | Description |
|---|---|---|
text | string | null | Comma-separated code:colour pairs; null or empty means no overrides. |
Returns
Record<string, string> | null
The validated colour map, or null for malformed or unsafe values.
Examples
import { readMapColors } from "@johnmorrisdotca/chizu/element";
console.log(readMapColors("JP:#2f6b4f,GB:rgb(138,59,59)")?.JP);
console.log(readMapColors("JP:url(evil)"));
// #2f6b4f
// null#2f6b4f
nullWhat it prints (run when this page was built)