Reference · Codes, URLs and SVG helpers
isFlagCodefunction
True for one of the codes with a flag, written exactly as Kuni writes it: "JP", "JP-13", "CA-ON", "US-TX".
Lower case is not a code here; flagCode is the forgiving one.
Import it
import { isFlagCode } from "@johnmorrisdotca/hata";
Definition
function isFlagCode(value: unknown): value is FlagCode
Parameters
| Name | Type | Description |
|---|---|---|
value | unknown | Anything. |
Returns
boolean
true when value is a string in FLAG_CODES, and false for anything else, never throwing.
Examples
import { isFlagCode } from "@johnmorrisdotca/hata";
console.log(isFlagCode("JP-13")); // true
console.log(isFlagCode("jp-13")); // false: see flagCode
console.log(isFlagCode("EH")); // false: no flag in this version (see /manifest's leftOut)true
false
falseWhat it prints (run when this page was built)