2.1.3 • Published 3 years ago
@zapiary/zhelperjs v2.1.3
zHelper JS
Installation
Using npm:
$ npm i @zapiary/zhelperjs
Development
- Modify code and run tests
npm test
- Commit changes
- Update CHANGELOG.md
- Run
sh publish.sh
Helpers
Capitalize first letter
const { capitalizeFirstLetter } from "@zapiary/zhelperjs"
const name = capitalizeFirstLetter("example");
// Returns "Example"
Name from email
const { nameFromEmail } from "@zapiary/zhelperjs"
const name = nameFromEmail("amy.andrews123@example.com");
// Returns "Amy Andrews"
Domain from email
const { domainFromEmail } from "@zapiary/zhelperjs"
const name = domainFromEmail("amy.andrews123@example.com");
// Returns "example.com"
Org name from email
const { orgNameFromEmail } from "@zapiary/zhelperjs"
const name = orgNameFromEmail("amy.andrews123@example.com");
// Returns "Example"
Validate LinkedIn URL
const { validateLinkedInUrl } from "@zapiary/zhelperjs"
const name = validateLinkedInUrl("https://www.linkedin.com/in/elishaterada/");
// Returns true
Validate LinkedIn Profile URL
const { validateLinkedInProfileUrl } from "@zapiary/zhelperjs"
const name = validateLinkedInProfileUrl("https://www.linkedin.com/in/elishaterada/");
// Returns true only if its a valid profile URL
Validate Twitter URL
const { validateTwitterUrl } from "@zapiary/zhelperjs"
const name = validateTwitterUrl("https://twitter.com/elonmusk");
// Returns true
Extract Twitter Username
const { extractTwitterUsername } from "@zapiary/zhelperjs"
const name = extractTwitterUsername("https://twitter.com/elonmusk");
// Returns "elonmusk", note that Twitter uses /whatever as username so it can also match /about
Convert Twitter handle to URL
const { convertTwitterHandleToUrl } from "@zapiary/zhelperjs"
const name = convertTwitterHandleToUrl("@elonmusk");
// Returns "https://twitter.com/elonmusk"
Validate Facebook URL
const { validateFacebookUrl } from "@zapiary/zhelperjs"
const name = validateFacebookUrl("https://www.facebook.com/friends");
// Returns true
Validate Facebook URL
const { validateFacebookUrl } from "@zapiary/zhelperjs"
const name = validateFacebookUrl("https://www.facebook.com/friends");
// Returns true
Validate Instagram URL
const { validateInstagramUrl } from "@zapiary/zhelperjs"
const name = validateInstagramUrl("https://www.instagram.com/elishaterada/");
// Returns true
Clean name
const { cleanName } from "@zapiary/zhelperjs"
const name = cleanName("first.last@example.com");
// Returns "First Last"
Detect IE
const { detectIe } from "@zapiary/zhelperjs"
const isIe = detectIe();
// Returns false
Detect Browser
const { isBrowser } from "@zapiary/zhelperjs"
const isBrowser = isBrowser();
// Returns false
Get file type
const { getFileType } from "@zapiary/zhelperjs"
const fileType = getFileType("file.jpg);
// Returns "jpg"
Get initials
const { getInitials } from "@zapiary/zhelperjs"
const initials = getInitials("Elisha Terada");
// Returns "ET"
Limit characters
const { limitCharacters } from "@zapiary/zhelperjs"
const originalText =
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
const isIe = limitCharacters({ text: originalText, length: 20 });
// Returns "Lorem ipsum dolor s..."
Name formatter
const { nameFormatter } from "@zapiary/zhelperjs"
const name = nameFormatter({ email: "elisha.terada@zapiary.com" });
// Returns "Elisha Terada"