Skip to content

techmmunity/utils

Repository files navigation

Techmmunity - Utils

Style Guide: Techmmunity CodeFactor Coveralls Tests Npm Downloads

Package of utils, make in a way to let you import only the functions that you really need, so it doesn't make your project heavier than it needs to be.

Install

With Yarn:

yarn add @techmmunity/utils

With NPM:

npm i @techmmunity/utils

Docs

Miscellaneous

function description
cleanObj Remove undefined and null values from an object

get*

function description
getArrayUniqueValues Remove duplicated values of an array (only work with primitive values)
getHexColorLuma Return the color luma of a hex color
getEnumValues Return the enum values
getTypeof Fix native "typeof"

has*

function description
hasEmojis Return true if value has emojis
hasHtmlTags Return true if value has html tags
hasRequiredEnvVars Verify if all env vars are defined
hasUrl Return true if value has a url

is*

function description
isBetween Return true if value is a number between 2 values
isBrazilianPhone Return true if value is a brazilian phone
isCpf Return true if value is a CPF
isDarkHexColor Return true if value is a dark hex color
isDate Return true if value is a valid date in the specified format
isDateDMY Return true if value is a valid date DD-MM-YYY
isDateDMYS Return true if value is a valid date DD/MM/YYY
isDateMDY Return true if value is a valid date MM-DD-YYY
isDateMDYS Return true if value is a valid date MM/DD/YYY
isDateYMD Return true if value is a valid date YYYY-MM-DD
isDateYMDS Return true if value is a valid date YYYY/MM/DD
isDivisibleByTen Return true if value is divisible by ten
isEmail Return true if value is a valid email
isEmoji Return true if value is an emoji (has some false-positives!)
isEmptyArray Checks if is an array and it's empty
isEmptyObject Checks if is an object and it's empty
isEven Return true if value is a even number
isFloat Return true if value is a float number (.0 numbers doesn't count)
isHerokuApiKey Return true if value is a heroku api key
isHexColor Return true if value is a valid hex color
isInt Return true if value is a float number
isIpv4 Return true if value is a valid ipv4
isIpv4WithMask Return true if value is a valid ipv4 with mask
isIsoDate Return true if value is a ISO Date
isLeap Return true if value is a leap year
isLightHexColor Return true if value is a light hex color
isMaskedCpf Return true if value is a masked CPF
isNumeric Return true if value is a numeric string
isOdd Return true if value is a odd number
isStrongPassword Return true if value is a strong password
isTimeWithFraction Return true if value is a time in the format hh:mm:ss.s
isTimezone Return true if value is a time zone (Ex: +01:00, UTC, -12:00)
isUrl Return true if value is a valid url
isUsername Return true if value is a valid username
isUuidV4 Return true if value is a valid uuid (v4)

isNot*

function description
isNotEmptyArray Checks if is an array and it's NOT empty
isNotEmptyObject Checks if is an object and it's NOT empty

Packages

No packages published

Contributors 2

  •  
  •  

Languages