# dd360-utils

> This library is a utils functions

Latest version **18.1.1** (published 2023-05-23) · ISC license · 0 weekly downloads

## Install

```sh
npm install dd360-utils
pnpm add dd360-utils
yarn add dd360-utils
bun add dd360-utils
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 18.1.1 |
| Published | 2023-05-23 |
| First published | 2022-06-17 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=14.17.0 |
| Dependencies | 0 |
| Unpacked size | 101.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Timoteo Borgobello |
| Maintainers | misael-arreola, dd3_otorres, tbor00, a.rodriguez, dav360 |
| Keywords | format dates, format currency, input validations, get queryParams, file size, utils, utils global |

## Links

- npm: https://www.npmjs.com/package/dd360-utils
- npm.io page: https://npm.io/package/dd360-utils

## Alternatives

- [unionfs](https://npm.io/package/unionfs.md) — 2.2M weekly downloads
- [path-starts-with](https://npm.io/package/path-starts-with.md) — 35.9K weekly downloads
- [redzip](https://npm.io/package/redzip.md) — 1.2K weekly downloads
- [vscode-anymatch](https://npm.io/package/vscode-anymatch.md) — 848 weekly downloads
- [@ledgerhq/coin-filecoin](https://npm.io/package/@ledgerhq/coin-filecoin.md) — 793 weekly downloads

## Recent versions

- 18.1.1 (latest) — 2023-05-23
- 18.1.0 — 2022-12-22
- 1.0.18 — 2022-08-02
- 1.0.17 — 2022-08-02
- 1.0.16 — 2022-06-30
- 1.0.15 — 2022-06-30
- 1.0.14 — 2022-06-30
- 1.0.13 — 2022-06-22
- 1.0.12 — 2022-06-20
- 1.0.11 — 2022-06-20
- 1.0.10 — 2022-06-20
- 1.0.9 — 2022-06-20
- 1.0.8 — 2022-06-17
- 1.0.7 — 2022-06-17
- 1.0.6 — 2022-06-17
- … 5 more at https://npm.io/package/dd360-utils/versions

## README

# DD360 Utils frontend

[![size](https://badgen.net/bundlephobia/min/dd360-utils)](https://badgen.net/bundlephobia/min/dd360-utils)
[![minzip size](https://badgen.net/bundlephobia/minzip/dd360-utils)](https://badgen.net/bundlephobia/minzip/dd360-utils)
[![version](https://badgen.net/npm/v/dd360-utils)](https://www.npmjs.com/package/dd360-utils)
[![types](https://badgen.net/npm/types/dd360-utils)](https://www.npmjs.com/package/dd360-utils)
[![license](https://badgen.net/npm/license/dd360-utils)](https://www.npmjs.com/package/dd360-utils)
[![pipeline - jobs](https://gitlab.com/dd3tech/dd360/dd360-utils-front/badges/main/pipeline.svg)](https://gitlab.com/dd3tech/dd360/dd360-utils-front)

This is DD360 library of utils functions based on Typescript.

## This project is based IN:

[TYPESCRIPT](https://www.typescriptlang.org/)

# Installation

```
 npm i dd360-utils
```

# How to imports?

```jsx
import { formatCurrency, formatDecimal, unFormatCurrency, getLeftAndTopScreen, getQueryParams } from 'dd360-utils'

const { formatCurrency, formatDecimal, unFormatCurrency, getLeftAndTopScreen, getQueryParams } = require('dd360-utils')
```

## Currency Helpers

Use format currency:

```jsx
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.

```jsx
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

```jsx
// get queryparams from url
const type = getQueryParams('type')
```

Use ObjectIsEmpty

```jsx
import { objectIsEmpty } from 'dd360-utils'

objectIsEmpty({}) // true
objectIsEmpty({ name: 'John' }) // false
```

Use removeAccents

```jsx
import { removeAccents } from 'dd360-utils'

removeAccents('ananá') // anana
```

## Maths Helpers (How to use)

```jsx
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

```jsx
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

```jsx
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

```jsx
import { passwordValidations } from 'dd360-utils'

passwordValidations.isValidPasswordlowerUpper('Asd') // true
passwordValidations.isValidPasswordNumbers(4) // true
passwordValidations.isValidPasswordCharacters('$') // true
```

Other validations

```jsx
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

```jsx
import { getNameMonth } from 'dd360-utils'

getNameMonth(1, 'es') // Enero
getNameMonth(1, 'en') // January
```

## Screen Events Helpers

Use screen events

```jsx
// get left and top of screen
const { left, top } = getLeftAndTopScreen(event)
```

---
_Source: https://npm.io/package/dd360-utils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
