本文へ移動

Hata旗

国や地域の旗を読み込み、対応する表示の形を選び、絵ごとの資料・作者・ライセンスを保てます。

「旗(はた)」は、旗を表す日本語です。 名前について(英語)

目次

リファレンス · /bind

resolveFlag関数

リファレンスの説明と例は英語です。見出しと目次は日本語です。

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 { resolveFlag } from "@johnmorrisdotca/hata/bind";

定義

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

引数

名前型説明
propsFlagProps

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

戻り値

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).

例

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

出力(このページを作ったときに実行した結果)

ソースを見るGitHub で編集@johnmorrisdotca/hata 1.31.0 のソースから作成しました。

この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。