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.
51 lines (39 loc) • 1.22 kB
JavaScript
import { BaseParameter } from "./BaseParameter.js";
import { MissingArgument } from "../errors/index.js";
export class TzParameter extends BaseParameter {
static param = "TZ";
static identifier = "TzParameter";
#tzValue;
get value() {
return this.#tzValue.constructor.identifier === "URIType"
? `"${this.#tzValue.repr()}"`
: this.#tzValue.repr();
}
get valueXML() {
return this.#tzValue.reprXML();
}
get valueJSON() {
return this.#tzValue.reprJSON();
}
#validate(tzValue) {
if (typeof tzValue === "undefined")
throw new MissingArgument("Value for TzParameter must be supplied");
if (
tzValue.constructor.identifier !== "ParameterValueType" &&
tzValue.constructor.identifier !== "URIType" &&
!(
tzValue.constructor.identifier === "DateTimeType" &&
tzValue.type === "UTC-OFFSET"
)
)
throw new TypeError("Invalid type for value for TzParameter");
}
constructor(tzValue) {
super();
this.#validate(tzValue);
this.#tzValue = tzValue;
this.checkAbstractPropertiesAndMethods();
Object.freeze(this);
}
}
Object.freeze(TzParameter);