Skip to the content

Hata旗

Load a native country or region flag, choose supported framing and keep each drawing’s source, author and licence.

Hata (旗) is Japanese for a flag. About the name

Contents

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

NameTypeDescription
codestring

A flag's code, in any case.

datestring | Date

The day: a Date, or "YYYY-MM-DD", "YYYY-MM" or "YYYY".

options (optional)Omit<FlagOptions, "variant" | "date"> | undefined

role, allowRestricted and how to frame it (shape, fit, label).

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")); // true
null
Flag of Nazi Germany, 1935–1945. Shown for history and education. Displaying it is restricted by law in Germany and Austria outside those purposes.
true

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/hata 1.31.0.