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 · Flags by their colours

flagsWithfunction

The flags that have every colour and every tag asked for. A flag has a colour when the colours of that name cover at least 1% of it. With only, the flags with those colours and no other: no other name covers more than 3% of the flag, so a small emblem does not keep Mexico out of "green, white and red". A flag has a tag when one of the sources gives it: every source when left out, or only the ones named, to leave the guesses out.

Import it

import { flagsWith } from "@johnmorrisdotca/hata/search";

Definition

function flagsWith(query: { colours?: readonly ColourName[]; only?: boolean; tags?: readonly TagName[]; sources?: readonly TagSource[]; }): string[]

Parameters

NameTypeDescription
query{ colours?: readonly ColourName[]; only?: boolean; tags?: readonly TagName[]; sources?: readonly TagSource[]; }

colours: the names to look for, of COLOUR_NAMES. only: true to leave out a flag with another colour. tags: the tags to look for, of FLAG_TAGS. sources: the tag sources that count, of TAG_SOURCES. With no colours and no tags, every flag is found (with only, none).

Returns

string[]

The codes, in the order of FLAG_CODES; a place's default flag is the one looked at.

Examples

import { flagsWith } from "@johnmorrisdotca/hata/search";

console.log(flagsWith({ colours: ["red", "white"], only: true }).includes("JP")); // true
console.log(flagsWith({ colours: ["green", "white", "orange"], only: true }));    // Ireland, Côte d'Ivoire, India, Niger …
console.log(flagsWith({ tags: ["nordic-cross"] }));                               // Denmark, Finland, Iceland, Norway, Sweden …
console.log(flagsWith({ tags: ["stripes-horizontal"], sources: ["reviewed", "computed"], colours: ["yellow"] })); // Germany, Ukraine …
true
[ 'CI', 'CY', 'IE', 'IN', 'NE' ]
[
  'AX',   'BV', 'DK',
  'FI',   'FO', 'IS',
  'NO',   'SE', 'SJ',
  'NQAQ'
]
[
  'AM',    'BO',   'CO',
  'DE',    'GA',   'LT',
  'MU',    'UA',   'AT-1',
  'AT-2',  'AT-3', 'DE-BW',
  'DE-MV', 'FRG',  'XSV'
]

What it prints (run when this page was built)

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