# the-pirate-js

> A general-purpuse javascript utils lib

Latest version **0.0.1** (published 2019-01-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install the-pirate-js
pnpm add the-pirate-js
yarn add the-pirate-js
bun add the-pirate-js
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2019-01-28 |
| First published | 2019-01-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | trickstival |
| Maintainers | trickstival |

## Links

- npm: https://www.npmjs.com/package/the-pirate-js
- npm.io page: https://npm.io/package/the-pirate-js

## Recent versions

- 0.0.1 (latest) — 2019-01-28

## README

# The Pirate JS

The Pirate is a lib that has some util functions that can abstract
logic and prevent errors

## Install
```bash
# Using npm
npm i the-pirate
# Using yarn
yarn add the-pirate
```

## General examples
```js
import * as pirate from 'the-pirate'

// General functions
pirate.truthyJoin(['Hey', undefined, 'You'], ', ') // 'Hey, You'
pirate.any(false, true, false) // true
pirate.any(false, false) // false

pirate.maybe({}, 'item.price') // undefined
pirate.maybe({ item: { price: '$10.00' } }, 'item.price') // '$10.00'
```

## DOM utils
```js
import { dom } from 'the-pirate'
/*
imagine this span is in a structure like this:
<h2 class="parent">
    <div>
        <span class="child"></span>
    </div>
</h2>
*/
const spanChild = document.querySelector('.child')
dom.closest(spanChild, '.parent') // returns the h2 that has the .parent class

```

## Numeric utils
```js
import { numeric as numPyrate } from 'the-pirate'

numPyrate.validateCNPJ('18.837.197/0001-83') // true
numPyrate.validateCNPJ('47.372.635/4756-32') // false

numPyrate.normalizeLocalCurrency('20,000.04') // 20000.04 float
numPyrate.normalizeLocalCurrency('20.000,04') // 20000.04 float
```

## String examples
```js
import { string as strPi } from 'the-pirate'
strPi.isURL('http://google.com') // true
strPi.isURL('this is not an url') // false
strPi.interpol('Hello', 'World') // 'Hello World'

```

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