About: Started coding at the age of 13, now a professional software engineer and Scrum Master, creating and maintaining enterprise solutions. Eat - Sleep - Code - Lift - Repeat 💪🏾
Location:
Mannheim, Germany
Joined:
Nov 14, 2017
MeCardGenerator - my first npm package!
Publish Date: Jan 20 '20
9 2
I just published my first npm package!
The package is called MeCardGenerator and can be installed via:
npm i --save mecardgenerator
At the current version 1.0.6 the package contains only one function to create a MeCard string.
The idea came up while working on the third side project where I copied my function from a previous project.
Since I wanted to publish a package ever since but had no idea what, I thought why not use this as first package?
So here is the usage:
constMeCardGen=require("mecardgenerator");constmcs=MeCardGen("Jon",// First name"Doe",// Last name"jon.doe@acme.com",// email address"1-316-019-2128",// phone number (can be formatted)"https://acme.com/",// website / url"758 Elmo Gateway",// Street address"Murphyborough",// city"WY",// state"80562",// zip code"United States of America"// country);console.log(mcs);
Which will output the following string:
MECARD:N:Jon,Doe;EMAIL:jon.doe@acme.com;TEL:1-316-019-2128;URL:https://acme.com/;ADR:,,758 Elmo Gateway,80562 Murphyborough,WY,United States of America;;
This string is usually used with a QR-Code generator to enable phones to add contacts by scanning this QR-Code.
I will update the package with a QR Function. But it's just this one function for now.
This package provides a helper to generate MeCards to use it with a QR code for phones.
Install
npm i --save mecardgenerator
Usage
MeCard only
importMeCardGenfrom"mecardgenerator";constmcs=MeCardGen("Jon",// First name"Doe",// Last name"jon.doe@acme.com",// email address"1-316-019-2128",// phone number (can be formatted)"https://acme.com/",// website / url"758 Elmo Gateway",// Street address"Murphyborough",// city"WY",// state"80562",// zip code"United States of America"// country);
MeCard with QR Code (react)
To generate a QR Code, use the qrcode.react library in combination with this package:
importQRCodefrom"qrcode.react";importMeCardGenfrom"mecardgenerator";constmcs=MeCardGen("Jon",// First name"Doe",// Last name"jon.doe@acme.com",// email address"1-316-019-2128",// phone number (can be formatted)
Congrats man. I will test it out. One day I will do my own