npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vcf

v2.1.2

Published

Parse and construct vCards, jCards

Downloads

75,763

Readme

VCF / vCard

npm npm license npm downloads build status

Install via npm

$ npm install --save vcf

Index

Usage

var vCard = require( 'vcf' )

Parsing a Single vCard

var card = new vCard().parse( string )
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: '[email protected]'],
    rev: [String: '20080424T195243Z']
  }
}

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 )

Formats

Format: jCard

var card = vCard.fromJSON( data )
var jcard = card.toJSON()
[ "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", "[email protected]" ],
    [ "rev", {}, "text", "20080424T195243Z" ]
  ]
]

Format: VCF

var vcf = card.toString()
var vcf = card.toString( '4.0' )
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:[email protected]
REV:20080424T195243Z
END:VCARD

API Reference

vCard

Kind: global class


new vCard()

vCard


vCard.version : String

Version number

Kind: instance property of vCard


vCard.data : Object

Card data

Kind: instance property of vCard


vCard.get(key) ⇒ Object | Array

Get a vCard property

Kind: instance method of vCard

| Param | Type | | --- | --- | | key | String |


vCard.set(key, value, params)

Set a vCard property

Kind: instance method of vCard

| Param | Type | | --- | --- | | key | String | | value | String | | params | Object |


vCard.add(key, value, params)

Add a vCard property

Kind: instance method of vCard

| Param | Type | | --- | --- | | key | String | | value | String | | params | Object |


vCard.setProperty(prop)

Set a vCard property from an already constructed vCard.Property

Kind: instance method of vCard

| Param | Type | | --- | --- | | prop | Property |


vCard.addProperty(prop)

Add a vCard property from an already constructed vCard.Property

Kind: instance method of vCard

| Param | Type | | --- | --- | | prop | Property |


vCard.parse(value) ⇒ vCard

Parse a vcf formatted vCard

Kind: instance method of vCard

| Param | Type | | --- | --- | | value | String |


vCard.toString(version, charset) ⇒ String

Format the vCard as vcf with given version

Kind: instance method of vCard

| Param | Type | | --- | --- | | version | String | | charset | String |


vCard.toJCard(version) ⇒ Array

Format the card as jCard

Kind: instance method of vCard
Returns: Array - jCard

| Param | Type | Default | | --- | --- | --- | | version | String | '4.0' |


vCard.toJSON() ⇒ Array

Format the card as jCard

Kind: instance method of vCard
Returns: Array - jCard


vCard.Property

Kind: static class of vCard


new Property(field, value, params)

vCard Property

| Param | Type | | --- | --- | | field | String | | value | String | | params | Object |


property.is(type) ⇒ Boolean

Check whether the property is of a given type

Kind: instance method of Property

| Param | Type | | --- | --- | | type | String |


property.isEmpty() ⇒ Boolean

Check whether the property is empty

Kind: instance method of Property


property.clone() ⇒ Property

Clone the property

Kind: instance method of Property


property.toString(version) ⇒ String

Format the property as vcf with given version

Kind: instance method of Property

| Param | Type | | --- | --- | | version | String |


property.valueOf() ⇒ String

Get the property's value

Kind: instance method of Property


property.toJSON() ⇒ Array

Format the property as jCard data

Kind: instance method of Property


Property.prototype : Object

Property prototype

Kind: static property of Property


Property.fromJSON(data) ⇒ Property

Constructs a vCard.Property from jCard data

Kind: static method of Property

| Param | Type | | --- | --- | | data | Array |


vCard.mimeType : String

vCard MIME type

Kind: static property of vCard


vCard.extension : String

vCard file extension

Kind: static property of vCard


vCard.versions : Array

vCard versions

Kind: static property of vCard


vCard.foldLine ⇒ String

Folds a long line according to the RFC 5322.

Kind: static property of vCard
See: http://tools.ietf.org/html/rfc5322#section-2.1.1

| Param | Type | | --- | --- | | input | String | | maxLength | Number | | hardWrap | Boolean |


vCard.parseLines : function

Parse an array of vcf formatted lines

Kind: static property of vCard
Internal: used by vCard#parse()


vCard.normalize(input) ⇒ String

Normalizes input (cast to string, line folding, whitespace)

Kind: static method of vCard

| Param | Type | | --- | --- | | input | String |


vCard.isSupported(version) ⇒ Boolean

Check whether a given version is supported

Kind: static method of vCard

| Param | Type | | --- | --- | | version | String |


vCard.parse(value) ⇒ Array.<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

| Param | Type | | --- | --- | | jcard | Array |


vCard.format(card, version) ⇒ String

Format a card object according to the given version

Kind: static method of vCard

| Param | Type | | --- | --- | | card | vCard | | version | String |