UNPKG

vcard4

Version:

An RFC 6350 compliant JavaScript library for generating and parsing version 4.0 vCards. Can also generate RFC 6351 compliant XML vCards and RFC 7095 compliant jCards. TypeScript type declarations are provided.

45 lines (34 loc) 1.04 kB
import { BaseParameter } from "./BaseParameter.js"; import { MissingArgument } from "../errors/index.js"; export class LanguageParameter extends BaseParameter { static param = "LANGUAGE"; static identifier = "LanguageParameter"; #langTag; get value() { return this.#langTag.repr(); } get valueXML() { return this.#langTag.reprXML(); } get valueJSON() { return this.#langTag.reprJSON(); } #validate(langTag) { if (typeof langTag === "undefined") throw new MissingArgument( "Language Tag for LanguageParameter must be supplied" ); else if (langTag.constructor.identifier !== "LanguageTagType") throw new TypeError( "The value of the LANGUAGE property parameter should be of type LanguageTagType" ); } constructor(langTag) { super(); this.#validate(langTag); this.#langTag = langTag; this.checkAbstractPropertiesAndMethods(); Object.freeze(this); } } Object.freeze(LanguageParameter);