Property Value Data Types
According to the RFC, the standard value data types are:
- text
- text-list
- date
- date-list
- time
- time-list
- date-time
- date-time-list
- date-and-or-time
- date-and-or-time-list
- timestamp
- timestamp-list
- boolean
- integer
- integer-list
- float
- float-list
- URI
- utc-offset
- Language-Tag
- iana-valuespec
In the library, these are represented by the following classes:
The instance object is frozen and therefore its properties and methods cannot be modified after construction, neither can new ones be added.
noteThe actual value type depends on property name and VALUE parameter. For example, the
FN
property only acceptstext
values.
API
All the classes listed above are provided as named exports from the main vcard4 module. For example, to import the
BooleanType
class:ESMimport { BooleanType } from "vcard4";
commonjsconst { BooleanType } = require("vcard4");
Methods
The instance objects have the following methods:
repr
This method returns a string which is the representation of how the value type will finally appear in the vCard.
note'>' in the examples below is just the terminal prompt.
> const textValue = new TextType('Hello, world');
> textValue.repr();
'Hello\\, world'reprXML
This method returns a string which is the representation of how the value type will finally appear in the XML vCard.
> const textValue = new TextType('Hello, world');
> textValue.reprXML();
'<text>Hello, world</text>'reprJSON
This method returns an array showing how the value type will finally appear in the jCard.
> const textValue = new TextType('Hello, world');
> textValue.reprJSON();
[ 'text', 'Hello, world' ]