UNPKG

vcard-generator

Version:

VCard v4.0 rfc6350 compliant generator from JSON.

56 lines (43 loc) 2.12 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _util = require('./util'); exports.default = function (_ref) { var geo = _ref.geo, type = _ref.type, label = _ref.label, pref = _ref.pref, pobox = _ref.pobox, ext = _ref.ext, street = _ref.street, locality = _ref.locality, city = _ref.city, region = _ref.region, state = _ref.state, code = _ref.code, postalCode = _ref.postalCode, country = _ref.country, formatted = _ref.formatted, multiline = _ref.multiline; return ['ADR', geo && ';GEO="geo:' + (0, _util.encodeQuotedText)(geo) + '"', (formatted || multiline) && ';LABEL="' + (0, _util.encodeQuotedText)(formatted || multiline) + '"', (0, _util.formatPref)(pref), (0, _util.formatType)(type || label), ':', (0, _util.encodeText)(pobox) + ';', (0, _util.encodeText)(ext) + ';', (0, _util.encodeText)(street) + ';', (0, _util.encodeText)(locality || city) + ';', (0, _util.encodeText)(region || state) + ';', (0, _util.encodeText)(code || postalCode) + ';', (0, _util.encodeText)(country)].filter(_util.isSet).join(''); }; /* Cardinality: 0+ (*) ADR-value = ADR-component-pobox ";" ADR-component-ext ";" ADR-component-street ";" ADR-component-locality ";" ADR-component-region ";" ADR-component-code ";" ADR-component-country ADR;GEO="geo:12.3457,78.910";LABEL="Mr. John Q. Public, Esq.\nMail Drop: TNE QB\n123 Main Street\nAny Town, CA 91921-1234\nU.S.A.":;;123 Main Street;Any Town;CA;91921-1234;U.S.A. ADR;WORK;CHARSET=utf-8:;;738 tuhbenaran Ave, Apt 123;Mountain View;California;94040;United States of America ADR;type=HOME;type=pref:;;124 st\n234;City;Ca;98765;United States item2.ADR;type=HOME;type=pref:;;123 Catamaran St\nApt 1234;San Francisco;CA;12345;United States item2.X-ABADR:us item3.ADR;type=WORK:;;정자동 대림아파트\n123동 102호;성남시;경기도;123-456;South Korea item3.X-ABADR:kr ADR:;;Physical Address;;;; ADR;HOME:;;700 Jameson St;;;; */