18.1.1 • Published 12 months ago
dd360-utils v18.1.1
DD360 Utils frontend
This is DD360 library of utils functions based on Typescript.
This project is based IN:
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) // return 4,000
unFormatCurrency('4,000') // return 4000
formatDecimal(4000) // return 4,000.00
Use input format currency:
The format
and formatCents
methods expose a couple internal helper functions.
import { inputCurrency } from 'dd360-utils'
inputCurrency.format('2500') // $2,500.00
inputCurrency.format(200) // $200.00
inputCurrency.format(200, { removeSymbol: true, removeCents: true }) // 200
inputCurrency.formatCents('$2,500.55') // 250055
formatCurrencyInput.formatCents(2) // 200
Processing Helpers
Use getQueryParams
// get queryparams from url
const type = getQueryParams('type')
Use ObjectIsEmpty
import { objectIsEmpty } from 'dd360-utils'
objectIsEmpty({}) // true
objectIsEmpty({ name: 'John' }) // false
Use removeAccents
import { removeAccents } from 'dd360-utils'
removeAccents('ananá') // anana
Maths Helpers (How to use)
import { sum, subtract, multiply } from 'dd360-utils'
sum(4, 4) // 8
subtract(4, 2) // 2
multiply(2, 2) // 4
Storage Helpers (How to use)
LocalStorage Helpers
import { setLocalStorage, getLocalStorage, removeLocalStorage, removeKeysFromLocalStorage, clearLocalStorage } from 'dd360-utils'
setLocalStorage('theme', 'dark')
getLocalStorage('theme') // dark
removeLocalStorage('theme') // delete theme from localStorage
removeKeysFromLocalStorage(['theme', 'access_token', 'etc']) // remove this keys from localStorage
clearLocalStorage() // clear all keys from localStorage
SessionStorage Helpers
import { setSessionStorage, getSessionStorage, removeSessionStorage, removeKeysFromSessionStorage, clearSessionStorage } from 'dd360-utils'
setSessionStorage('theme', 'dark')
getSessionStorage('theme') // dark
removeSessionStorage('theme') // delete theme from sessionStorage
removeKeysFromSessionStorage(['theme', 'access_token', 'etc']) // remove this keys from sessionStorage
clearSessionStorage() // clear all keys from sessionStorage
Form Validations
Use password validations
import { passwordValidations } from 'dd360-utils'
passwordValidations.isValidPasswordlowerUpper('Asd') // true
passwordValidations.isValidPasswordNumbers(4) // true
passwordValidations.isValidPasswordCharacters('$') // true
Other validations
import { isValidEmail, isValidNumberPhone, isValidCURP, isValidRFC, userAgentIsMobile } from 'dd360-utils'
isValidEmail('correo@correo.com') // true
isValidEmail('correo') // false
isValidNumberPhone(1132678476) // true
isValidNumberPhone(223) // false
isValidCURP(YOUR_CURP) // true or false
isValidRFC(YOUR_RFC) // true or false
userAgentIsMobile() // if its mobile, return true
Date Helpers
Use Name of months
import { getNameMonth } from 'dd360-utils'
getNameMonth(1, 'es') // Enero
getNameMonth(1, 'en') // January
Screen Events Helpers
Use screen events
// get left and top of screen
const { left, top } = getLeftAndTopScreen(event)
18.1.1
12 months ago
18.1.0
1 year ago
1.0.18
2 years ago
1.0.17
2 years ago
1.0.16
2 years ago
1.0.15
2 years ago
1.0.14
2 years ago
1.0.13
2 years ago
1.0.12
2 years ago
1.0.11
2 years ago
1.0.10
2 years ago
1.0.9
2 years ago
1.0.8
2 years ago
1.0.7
2 years ago
1.0.6
2 years ago
1.0.5
2 years ago
1.0.4
2 years ago
1.0.3
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago