Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dd360-utils

Package Overview
Dependencies
Maintainers
5
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dd360-utils

This library is a utils functions

  • 18.1.1
  • latest
  • npm
  • Socket score

Version published
Maintainers
5
Created
Source

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)

Keywords

FAQs

Package last updated on 23 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc