{"id":20573313,"url":"https://github.com/joaocarmo/vcard-creator","last_synced_at":"2025-04-06T21:14:47.618Z","repository":{"id":24494322,"uuid":"101752630","full_name":"joaocarmo/vcard-creator","owner":"joaocarmo","description":"A JavaScript vCard creator library for both Node.js and the web","archived":false,"fork":false,"pushed_at":"2025-03-28T15:36:08.000Z","size":1041,"stargazers_count":41,"open_issues_count":3,"forks_count":15,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-28T16:33:33.615Z","etag":null,"topics":["javascript","nodejs","vcard"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joaocarmo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-08-29T11:14:21.000Z","updated_at":"2025-03-28T15:36:12.000Z","dependencies_parsed_at":"2024-06-18T18:13:40.423Z","dependency_job_id":"d2a4c42d-e2d9-4478-b0c1-e4b1cbb68112","html_url":"https://github.com/joaocarmo/vcard-creator","commit_stats":{"total_commits":60,"total_committers":6,"mean_commits":10.0,"dds":0.4666666666666667,"last_synced_commit":"8df04727a28e57a4a033f91a33aa93b6362b5ce3"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joaocarmo%2Fvcard-creator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joaocarmo%2Fvcard-creator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joaocarmo%2Fvcard-creator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joaocarmo%2Fvcard-creator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joaocarmo","download_url":"https://codeload.github.com/joaocarmo/vcard-creator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247550689,"owners_count":20956987,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["javascript","nodejs","vcard"],"created_at":"2024-11-16T05:26:53.875Z","updated_at":"2025-04-06T21:14:47.598Z","avatar_url":"https://github.com/joaocarmo.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# vcard-creator\n\n[![npm version](https://badge.fury.io/js/vcard-creator.svg)](https://badge.fury.io/js/vcard-creator)\n[![jest](https://jestjs.io/img/jest-badge.svg)](https://github.com/facebook/jest)\n![tests](https://github.com/joaocarmo/vcard-creator/workflows/Tests/badge.svg)\n\nA JavaScript vCard 3.0 creator library for both node.js and the web.\nIt outputs the vCard text that should be saved as a `*.vcf` file.\n\n## Origin\n\nThis is based on _jeroendesloovere_'s [vCard][jeroendesloovere] for PHP.\n\n## Installation\n\n```sh\npnpm add vcard-creator\n\n# or\n\nnpm install vcard-creator\n```\n\n## Usage\n\n### As an ESM module (web)\n\nLoad **vcard-creator** directly from [skypack][skypack] (CDN).\n\n```html\n\u003cscript type=\"module\"\u003e\n  import VCard from 'https://cdn.skypack.dev/vcard-creator'\n\u003c/script\u003e\n```\n\nDemo available in [codepen][codepen].\n\n### On the web (self-hosted)\n\nIt's exposed through the _window_ global object as explained below.\n\n`index.html`\n\n```html\n\u003chead\u003e\n  \u003cscript type=\"text/javascript\" src=\"./js/vcard-creator.js\"\u003e\u003c/script\u003e\n  \u003cscript type=\"text/javascript\" src=\"./js/main.js\"\u003e\u003c/script\u003e\n\u003c/head\u003e\n```\n\n`main.js`\n\n```js\n// Define a new vCard\nvar VCard = window.vcardcreator.default\nvar myVCard = new VCard()\n\n// ...rest of the code\n```\n\n### With a bundler / Node.js\n\nWith a bundler (e.g. webpack) or in Node.js you can just require / import it.\n\n```js\nconst VCard = require('vcard-creator').default\n\n// Define a new vCard\nconst myVCard = new VCard()\n```\n\nOr...\n\n```js\nimport VCard from 'vcard-creator'\n\n// Define a new vCard\nconst myVCard = new VCard()\n```\n\n### Including an image\n\nYou need to provide the image already properly encoded (base64). Note that most\napplications will probably ignore a photo URL, even if it adheres to the\nspecification.\n\n```js\n// Example in Node.js\n\nconst fs = require('fs')\nconst VCard = require('vcard-creator').default\n\nconst imagePath = './path/to/my/assets/sample.jpg'\nconst image = fs.readFileSync(imagePath, { encoding: 'base64', flag: 'r' })\n\nconst vCard = new VCard()\n\nvCard.addPhoto(image, 'JPEG')\n```\n\nInclude the proper [MIME type][mime-types] (defaults to `JPEG`).\n\n### [DEPRECATED] iCalendar format\n\nFor Apple devices that don't support the `vcf` file format, there is a\nworkaround. Specify the format of the output as `vcalendar` and then save it\nwith a `ics` file extension instead.\n\nThe trick is to create an iCalendar file with a vCard attached.\n\n```js\n// Define a new vCard as 'vcalendar'\nconst myVCalendar = new VCard('vcalendar')\n\n// ...or set it afterwards\nconst myOtherVCalendar = new VCard()\nmyOtherVCalendar.setFormat('vcalendar')\n```\n\n## Example\n\n```js\nimport VCard from 'vcard-creator'\n\n// Define a new vCard\nconst myVCard = new VCard()\n\n// Some variables\nconst lastname = 'Desloovere'\nconst firstname = 'Jeroen'\nconst additional = ''\nconst prefix = ''\nconst suffix = ''\n\nmyVCard\n  // Add personal data\n  .addName(lastname, firstname, additional, prefix, suffix)\n  // Add work data\n  .addCompany('Siesqo')\n  .addJobtitle('Web Developer')\n  .addRole('Data Protection Officer')\n  .addEmail('info@jeroendesloovere.be')\n  .addPhoneNumber(1234121212, 'PREF;WORK')\n  .addPhoneNumber(123456789, 'WORK')\n  .addAddress(null, null, 'street', 'worktown', null, 'workpostcode', 'Belgium')\n  .addSocial('https://twitter.com/desloovere_j', 'Twitter', 'desloovere_j')\n  .addURL('http://www.jeroendesloovere.be')\n\nconsole.log(myVCard.toString())\n```\n\nOutput\n\n```txt\nBEGIN:VCARD\nVERSION:3.0\nREV:2017-08-31T17:00:15.850Z\nN;CHARSET=utf-8:Desloovere;Jeroen;;;\nFN;CHARSET=utf-8:Jeroen Desloovere\nORG;CHARSET=utf-8:Siesqo\nTITLE;CHARSET=utf-8:Web Developer\nROLE;CHARSET=utf-8:Data Protection Officer\nEMAIL;INTERNET:info@jeroendesloovere.be\nTEL;PREF;WORK:1234121212\nTEL;WORK:123456789\nADR;WORK;POSTAL;CHARSET=utf-8:name;extended;street;worktown;state;workpos\n tcode;Belgium\nX-SOCIALPROFILE;type=Twitter;x-user=desloovere_j:https://twitter.com/desl\noovere_j\nURL:http://www.jeroendesloovere.be\nEND:VCARD\n```\n\n## Forking / Contributing\n\nIf you're interested in the development of this project, you can run some ready\nto use commands to compile and test your changes.\n\n```sh\n# Build\npnpm build\n\n# Test\npnpm test:unit\n\npnpm test:functional\n\npnpm test:web-build\n\npnpm test:web-export\n```\n\n\u003c!-- References --\u003e\n\n[codepen]: https://codepen.io/joaocarmo/pen/PozdprL\n[jeroendesloovere]: https://github.com/jeroendesloovere/vcard\n[mime-types]: https://www.iana.org/assignments/media-types/media-types.xhtml#image\n[skypack]: https://skypack.dev\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoaocarmo%2Fvcard-creator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoaocarmo%2Fvcard-creator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoaocarmo%2Fvcard-creator/lists"}