dd360-utils
TypeScript icon, indicating that this package has built-in type declarations

18.1.1 • Public • Published

DD360 Utils frontend

size minzip size version types license pipeline - jobs

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) // 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)

Package Sidebar

Install

npm i dd360-utils

Weekly Downloads

221

Version

18.1.1

License

ISC

Unpacked Size

104 kB

Total Files

7

Last publish

Collaborators

  • misael-arreola
  • dd3_otorres
  • tbor00
  • a.rodriguez
  • dav360