Skip to content package
vcf v2.0.2 Parse and construct vCards, jCards
node any 2 deps cjs open source
overview readme
license MIT
deps 2
unpacked 27.9 kB
files 6
node any $ npm install vcf@2.0.2n npmREADME GitHub-flavored package documentation.
downloads Across all versions.
Download trend unavailable.
compatibility Runtime metadata.
versions Latest published Dec 14, 2023
maintainers Registry package owners.
install size Estimated unpacked size across 3 packages.
56.4 kB
Includes dependencies.
dependencies 2 direct · 2 outdated
$ npm install --save vcf copy
Index
Usage var vCard = require ( 'vcf' ) copy
Parsing a Single vCard var card = new vCard (). parse ( string ) copy vCard {
version : '4.0' ,
data : {
version : [String: '4.0' ],
n : [String: 'Gump;Forrest;;;' ],
fn : [String: 'Forrest Gump' ],
org : [String: 'Bubba Gump Shrimp Co.' ],
title : [String: 'Shrimp Man' ],
photo : { [String: 'http://www.example.com/dir_photos/my_photo.gif' ] mediatype : 'image/gif' },
tel : [
{ [String: 'tel:+11115551212' ] type: [ 'work' , 'voice' ], value: 'uri' },
{ [String: 'tel:+14045551212' ] type: [ 'home' , 'voice' ], value: 'uri' }
],
adr : [
{ [String: ';;100 Waters Edge;Baytown;LA;30314;United States of America' ]
type: 'work' ,
label: '"100 Waters Edge \\ nBaytown, LA 30314 \\ nUnited States of America"' },
{ [String: ';;42 Plantation St.;Baytown;LA;30314;United States of America' ]
type: 'home' ,
label: '"42 Plantation St. \\ nBaytown, LA 30314 \\ nUnited States ofAmerica"' }
],
email : [String: 'forrestgump@example.com' ],
rev : [String: '20080424T195243Z' ]
}
} copy
Parsing Multiple vCards In order to deal with a string that contains multiple vCards,
you will need to use a different function, which returns an array of cards:
var cards = vCard. parse ( string ) copy
var card = vCard. fromJSON ( data ) copy var jcard = card. toJSON () copy [ "vcard" ,
[
[ "version" , {}, "text" , "4.0" ],
[ "n" , {}, "text" , [ "Gump" , "Forrest" , "" , "" , "" ] ],
[ "fn" , {}, "text" , "Forrest Gump" ],
[ "org" , {}, "text" , "Bubba Gump Shrimp Co." ],
[ "title" , {}, "text" , "Shrimp Man" ],
[
"photo" , { "mediatype" : "image/gif" },
"text" , "http://www.example.com/dir_photos/my_photo.gif"
],
[ "tel" , { "type" : [ "work" , "voice" ], "value" : "uri" }, "uri" , "tel:+11115551212" ],
[ "tel" , { "type" : [ "home" , "voice" ], "value" : "uri" }, "uri" , "tel:+14045551212" ],
[
"adr" , { "type" : "work" , "label" : " \" 100 Waters Edge \\ nBaytown, LA 30314 \\ nUnited States of America \" " },
"text" , [ "" , "" , "100 Waters Edge" , "Baytown" , "LA" , "30314" , "United States of America" ]
],
[
"adr" , { "type" : "home" , "label" : " \" 42 Plantation St. \\ nBaytown, LA 30314 \\ nUnited States ofAmerica \" " },
"text" , [ "" , "" , "42 Plantation St." , "Baytown" , "LA" , "30314" , "United States of America" ]
],
[ "email" , {}, "text" , "forrestgump@example.com" ],
[ "rev" , {}, "text" , "20080424T195243Z" ]
]
] copy
var vcf = card. toString ()
var vcf = card. toString ( '4.0' ) copy BEGIN:VCARD
VERSION:4.0
N:Gump;Forrest;;;
FN:Forrest Gump
ORG:Bubba Gump Shrimp Co.
TITLE:Shrimp Man
PHOTO;MEDIATYPE=image/gif:http://www.example.com/dir_photos/my_photo.gif
TEL;TYPE=work,voice;VALUE=uri:tel:+11115551212
TEL;TYPE=home,voice;VALUE=uri:tel:+14045551212
ADR;TYPE=work;LABEL="100 Waters Edge\nBaytown, LA 30314\nUnited States
of America":;;100 Waters Edge;Baytown;LA;30314;United States of America
ADR;TYPE=home;LABEL="42 Plantation St.\nBaytown, LA 30314\nUnited
States ofAmerica":;;42 Plantation St.;Baytown;LA;30314;United States of
America
EMAIL:forrestgump@example.com
REV:20080424T195243Z
END:VCARD copy
API Reference
vCard
new vCard()
vCard.version : String Kind : instance property of vCard
vCard.data : Object Kind : instance property of vCard
vCard.get(key) ⇒ Object | Array Kind : instance method of vCard
vCard.set(key, value, params) Kind : instance method of vCard
Param Type key Stringvalue Stringparams Object
vCard.add(key, value, params) Kind : instance method of vCard
Param Type key Stringvalue Stringparams Object
vCard.setProperty(prop) Set a vCard property from an already
constructed vCard.Property
Kind : instance method of vCard
vCard.addProperty(prop) Add a vCard property from an already
constructed vCard.Property
Kind : instance method of vCard
vCard.parse(value) ⇒ vCard Parse a vcf formatted vCard
Kind : instance method of vCard
vCard.toString(version, charset) ⇒ String Format the vCard as vcf with given version
Kind : instance method of vCard
Param Type version Stringcharset String
vCard.toJCard(version) ⇒ Array Kind : instance method of vCard
Returns : Array - jCard
Param Type Default version String'4.0'
vCard.toJSON() ⇒ Array Kind : instance method of vCard
Returns : Array - jCard
vCard.Property Kind : static class of vCard
new Property(field, value, params) Param Type field Stringvalue Stringparams Object
property.is(type) ⇒ Boolean Check whether the property is of a given type
property.isEmpty() ⇒ Boolean Check whether the property is empty
property.clone() ⇒ Property
property.toString(version) ⇒ String Format the property as vcf with given version
property.valueOf() ⇒ String
property.toJSON() ⇒ Array Format the property as jCard data
Property.prototype : Object
Property.fromJSON(data) ⇒ Property Constructs a vCard.Property from jCard data
vCard.mimeType : String Kind : static property of vCard
vCard.extension : String Kind : static property of vCard
vCard.versions : Array Kind : static property of vCard
vCard.foldLine ⇒ String Folds a long line according to the RFC 5322.
Param Type input StringmaxLength NumberhardWrap Boolean
vCard.parseLines : function Parse an array of vcf formatted lines
Kind : static property of vCard
Internal : used by vCard#parse()
Normalizes input (cast to string, line folding, whitespace)
Kind : static method of vCard
vCard.isSupported(version) ⇒ Boolean Check whether a given version is supported
Kind : static method of vCard
Parses a string or buffer into a vCard object
Kind : static method of vCard
Param Type value String | Buffer
vCard.fromJSON(jcard) ⇒ vCard Constructs a vCard from jCard data
Kind : static method of vCard
Format a card object according to the given version
Kind : static method of vCard
Param Type card vCardversion String
Object