Properties
After documenting the property value data types and the property parameters, what follows now is the documentation of the properties themselves
According to the RFC, the following are the properties:
General Properties
- BEGIN
- END
- SOURCE
- KIND
- XML
Identification Properties
- FN
- N
- NICKNAME
- PHOTO
- BDAY
- ANNIVERSARY
- GENDER
- BIRTHPLACE
- DEATHPLACE
- DEATHDATE
- EXPERTISE
- HOBBY
- INTEREST
Delivery Addressing Properties
- ADR
Communications Properties
- TEL
- IMPP
- LANG
- CONTACT-URI
Geographical Properties
- TZ
- GEO
Organizational Properties
- TITLE
- ROLE
- LOGO
- ORG
- MEMBER
- RELATED
- ORG-DIRECTORY
Explanatory Properties
- CATEGORIES
- NOTE
- PRODID
- REV
- SOUND
- UID
- CLIENTPIDMAP
- URL
- VERSION
Security Properties
- KEY
Calendar Properties
- FBURL
- CALADRURI
- CALURI
Extended Properties
vcard4 treats BEGIN, VERSION and END properties as special. You do
not construct them manually as you do the other properties, it adds them to the
constructed vCard itself.
In the library, they are represented by the following classes:
SourcePropertyKindPropertyXMLPropertyFNPropertyNPropertyNicknamePropertyPhotoPropertyBdayPropertyAnniversaryPropertyGenderPropertyBirthPlacePropertyDeathPlacePropertyDeathDatePropertyExpertisePropertyHobbyPropertyInterestPropertyAdrPropertyTelPropertyEmailPropertyIMPPPropertyLangPropertyContactURIPropertyTzPropertyGeoPropertyTitlePropertyRolePropertyLogoPropertyOrgPropertyMemberPropertyRelatedPropertyOrgDirectoryPropertyCategoriesPropertyNotePropertyProdidPropertyRevPropertySoundPropertyUIDPropertyClientpidmapPropertyURLPropertyKeyPropertyFburlPropertyCaladruriPropertyCaluriPropertyExtendedProperty
The instance object is frozen and therefore its properties and methods cannot be modified after construction, neither can new ones be added
All of the classes, with the exception of a few, should generally be called with two arguments, the first being an array whose items are the parameters of the property and the second argument being the property's value.
API
All the classes listed above are provided as named exports from the main vcard4 module. For example, to import the
AdrPropertyclass:ESMimport { AdrProperty } from "vcard4";commonjsconst { AdrProperty } = require("vcard4");
Methods
The instance objects have the following methods:
repr
This method returns a string which is the representation of how the property will finally appear in the vCard.
note'>' in the examples below is just the terminal prompt.
> const genderPropValue = new SpecialValueType(
> 'GenderProperty',
> [
> new SexType('M'),
> new TextType('Male')
> ],
> );
> const genderPropValueParam = new ValueParameter(genderPropValue);
> const gender = new GenderProperty(
> [ genderPropValueParam ],
> genderPropValue
> );
> gender.repr();
'GENDER;VALUE=text:M;Male'reprXML
This method returns a string which is the representation of how the property will finally appear in the XML vCard.
> const genderPropValue = new SpecialValueType(
> 'GenderProperty',
> [
> new SexType('M'),
> new TextType('Male')
> ],
> );
> const genderPropValueParam = new ValueParameter(genderPropValue);
> const gender = new GenderProperty(
> [ genderPropValueParam ],
> genderPropValue
> );
> gender.reprXML();
'<gender><sex>M</sex><text>Male</text></gender>'reprJSON
This method returns an array showing how the property will finally appear in the jCard.
> const genderPropValue = new SpecialValueType(
> 'GenderProperty',
> [
> new SexType('M'),
> new TextType('Male')
> ],
> );
> const genderPropValueParam = new ValueParameter(genderPropValue);
> const gender = new GenderProperty(
> [ genderPropValueParam ],
> genderPropValue
> );
> gender.reprJSON();
[ 'gender', {}, 'text', [ 'M', 'Male' ] ]