DD360 Utils frontend
This is DD360 library of utils functions based on Typescript.
This project is based IN:
TYPESCRIPT
Installation
npm i dd360-utils
How to imports?
import { formatCurrency, formatDecimal, unFormatCurrency, getLeftAndTopScreen, getQueryParams } from 'dd360-utils'
const { formatCurrency, formatDecimal, unFormatCurrency, getLeftAndTopScreen, getQueryParams } = require('dd360-utils')
Currency Helpers
Use format currency:
import { formatCurrency, unFormatCurrency, formatDecimal } from 'dd360-utils'
formatCurrency(4000)
unFormatCurrency('4,000')
formatDecimal(4000)
Use input format currency:
The format
and formatCents
methods expose a couple internal helper functions.
import { inputCurrency } from 'dd360-utils'
inputCurrency.format('2500')
inputCurrency.format(200)
inputCurrency.format(200, { removeSymbol: true, removeCents: true })
inputCurrency.formatCents('$2,500.55')
formatCurrencyInput.formatCents(2)
Processing Helpers
Use getQueryParams
const type = getQueryParams('type')
Use ObjectIsEmpty
import { objectIsEmpty } from 'dd360-utils'
objectIsEmpty({})
objectIsEmpty({ name: 'John' })
Use removeAccents
import { removeAccents } from 'dd360-utils'
removeAccents('ananá')
Maths Helpers (How to use)
import { sum, subtract, multiply } from 'dd360-utils'
sum(4, 4)
subtract(4, 2)
multiply(2, 2)
Storage Helpers (How to use)
LocalStorage Helpers
import { setLocalStorage, getLocalStorage, removeLocalStorage, removeKeysFromLocalStorage, clearLocalStorage } from 'dd360-utils'
setLocalStorage('theme', 'dark')
getLocalStorage('theme')
removeLocalStorage('theme')
removeKeysFromLocalStorage(['theme', 'access_token', 'etc'])
clearLocalStorage()
SessionStorage Helpers
import { setSessionStorage, getSessionStorage, removeSessionStorage, removeKeysFromSessionStorage, clearSessionStorage } from 'dd360-utils'
setSessionStorage('theme', 'dark')
getSessionStorage('theme')
removeSessionStorage('theme')
removeKeysFromSessionStorage(['theme', 'access_token', 'etc'])
clearSessionStorage()
Form Validations
Use password validations
import { passwordValidations } from 'dd360-utils'
passwordValidations.isValidPasswordlowerUpper('Asd')
passwordValidations.isValidPasswordNumbers(4)
passwordValidations.isValidPasswordCharacters('$')
Other validations
import { isValidEmail, isValidNumberPhone, isValidCURP, isValidRFC, userAgentIsMobile } from 'dd360-utils'
isValidEmail('correo@correo.com')
isValidEmail('correo')
isValidNumberPhone(1132678476)
isValidNumberPhone(223)
isValidCURP(YOUR_CURP)
isValidRFC(YOUR_RFC)
userAgentIsMobile()
Date Helpers
Use Name of months
import { getNameMonth } from 'dd360-utils'
getNameMonth(1, 'es')
getNameMonth(1, 'en')
Screen Events Helpers
Use screen events
const { left, top } = getLeftAndTopScreen(event)