2.1.3 • Published 3 years ago

@zapiary/zhelperjs v2.1.3

Weekly downloads
91
License
-
Repository
github
Last release
3 years ago

zHelper JS

Installation

Using npm:

$ npm i @zapiary/zhelperjs

Development

  1. Modify code and run tests npm test
  2. Commit changes
  3. Update CHANGELOG.md
  4. 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"