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 · /bind

resolveFlagfunction

A flag's inline SVG, loaded from its own module (flag(code, options) from /load) and kept, so that it is loaded once. The promise is the same for the same flag, which is what a framework's suspending hook wants.

Import it

import { resolveFlag } from "@johnmorrisdotca/hata/bind";

Definition

function resolveFlag(props: FlagProps): Promise<BoundFlag | null>

Parameters

NameTypeDescription
propsFlagProps

The flag, as the element's attributes give it.

Returns

Promise<BoundFlag | null>

A promise of the flag, or of null when the package has no flag for it (an unknown code, a restricted flag asked for without allowRestricted, a date with no flag).

Examples

import { resolveFlag } from "@johnmorrisdotca/hata/bind";

const japan = await resolveFlag({ code: "JP", label: "Japan" });
console.log(japan?.svg.startsWith("<svg")); // true
console.log(await resolveFlag({ code: "XX" })); // null
true
null

What it prints (run when this page was built)

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