Reference · On-demand flag loading
flagOnfunction
The flag of a day with its drawing and the reason for a blank: flag(code, { date }) and flagOn(code, date) from /manifest in one call. Where another
flag exists for the day (Canada in 1962: the Union Flag is legal and the Red Ensign was flown) variant.other says which and why; where there is no
drawing (no flag known that day, or a restricted flag without allowRestricted) svg is null and none says why, in a sentence.
Import it
import { flagOn } from "@johnmorrisdotca/hata/load";
Definition
function flagOn(code: string, date: string | Date, options?: Omit<FlagOptions, "variant" | "date">): Promise<LoadedFlagOn>
Parameters
| Name | Type | Description |
|---|---|---|
code | string | A flag's code, in any case. |
date | string | Date | The day: a |
options (optional) | Omit<FlagOptions, "variant" | "date"> | undefined |
|
Returns
Promise<LoadedFlagOn>
A promise of the day's answer, never null.
Examples
import { flagOn } from "@johnmorrisdotca/hata/load";
const day = await flagOn("DE", "1940");
console.log(day.svg); // null: restricted
console.log(day.none?.reason); // "Flag of Nazi Germany, 1935–1945. Shown for history and education. …"
const shown = await flagOn("DE", "1940", { allowRestricted: true });
console.log(shown.svg?.startsWith("<svg")); // truenull
Flag of Nazi Germany, 1935–1945. Shown for history and education. Displaying it is restricted by law in Germany and Austria outside those purposes.
trueWhat it prints (run when this page was built)