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 · Military flags (naval ensigns, jacks and war flags)

militaryFlagfunction

A military flag as an SVG string: it has a viewBox and no width or height. frame() and toDataUri() from the main entry take it like any other. A restricted flag (MILITARY_RESTRICTED_IDS) is null unless allowRestricted is true, for a page of history or teaching.

Import it

import { militaryFlag } from "@johnmorrisdotca/hata/military";

Definition

function militaryFlag(id: string, options?: { allowRestricted?: boolean; }): Promise<string | null>

Parameters

NameTypeDescription
idstring

A flag's id, in any case, with or without mil:.

options (optional){ allowRestricted?: boolean; }

{ allowRestricted: true } to draw a flag shipped for history and education only.

Returns

Promise<string | null>

The SVG string, loaded when it is asked for (the drawing is a module of its own, so a page carries only the drawings it asks for), or null when the set has no such flag or the flag is restricted and not asked for.

Examples

import { toDataUri } from "@johnmorrisdotca/hata";
import { militaryFlag } from "@johnmorrisdotca/hata/military";

const ensign = await militaryFlag("mil:gb-white-ensign"); // "<svg …>"
console.log(ensign === null ? null : toDataUri(ensign)?.startsWith("data:image/svg+xml,"));
true

What it prints (run when this page was built)

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