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 · Ship signal flags (International Code of Signals)

signalFlagfunction

A flag as an SVG string: it has a viewBox and no width or height, a square-ish letter flag, a tapering numeral pennant, a triangular substitute. frame() and toDataUri() from the main entry take it like any other.

Import it

import { signalFlag } from "@johnmorrisdotca/hata/signals";

Definition

function signalFlag(id: string): Promise<string | null>

Parameters

NameTypeDescription
idstring

A flag's id, in any case, with or without ics: ("ics:a", "A").

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 Code has no such flag.

Examples

import { toDataUri } from "@johnmorrisdotca/hata";
import { signalFlag } from "@johnmorrisdotca/hata/signals";

const alfa = await signalFlag("ics:a"); // "<svg …>"
console.log(alfa === null ? null : toDataUri(alfa)?.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.