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
| Name | Type | Description |
|---|---|---|
id | string | A flag's id, in any case, with or without |
options (optional) | { allowRestricted?: boolean; } |
|
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,"));trueWhat it prints (run when this page was built)