Provides branded types and utilities for working with BCP 47 language tags (Tag) and RFC 4647 language
ranges (TagRange). Use asTag and asTagRange to create validated instances, isTag and
isTagRange as type guards, and matchTag to test tags against range patterns.
Language Tags
import { isTag, asTag } from"@metreeca/core";
if (isTag(value)) { // value is typed as Tag }
constlanguageTag = asTag("en-US"); // US English constsimpleTag = asTag("fr"); // French constcomplexTag = asTag("zh-Hans-CN"); // Simplified Chinese (China)
if (isTagRange(value)) { // value is typed as TagRange }
constwildcard = asTagRange("*"); // matches any language constenglish = asTagRange("en-*"); // matches any English variant constswiss = asTagRange("*-CH"); // matches any language in Switzerland
Language tags and ranges.
Provides branded types and utilities for working with BCP 47 language tags (Tag) and RFC 4647 language ranges (TagRange). Use asTag and asTagRange to create validated instances, isTag and isTagRange as type guards, and matchTag to test tags against range patterns.
Language Tags
Language Ranges
Matching
See