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>
引数
| 名前 | 型 | 説明 |
|---|---|---|
props | FlagProps | 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" })); // nulltrue
null出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。