# daton-lib

> Functional lib for easier JS usage

Latest version **1.0.10** (published 2021-06-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install daton-lib
pnpm add daton-lib
yarn add daton-lib
bun add daton-lib
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.10 |
| Published | 2021-06-21 |
| First published | 2021-04-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=10 |
| Dependencies | 0 |
| Unpacked size | 65.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Milan Poznan |
| Maintainers | brothersrbin |

## Links

- npm: https://www.npmjs.com/package/daton-lib
- npm.io page: https://npm.io/package/daton-lib

## Recent versions

- 1.0.10 (latest) — 2021-06-21
- 1.0.9 — 2021-06-17
- 1.0.8 — 2021-06-15
- 1.0.7 — 2021-06-15
- 1.0.6 — 2021-04-24
- 1.0.5 — 2021-04-21
- 1.0.4 — 2021-04-21
- 1.0.3 — 2021-04-21
- 1.0.2 — 2021-04-19
- 1.0.1 — 2021-04-12
- 1.0.0 — 2021-04-12

## README

# daton-lib

## Table of contents
* [Usage](#usage)
* [custom logs](#custom-logs)
* [custom hooks](#custom-hooks)


> Functional lib for easier JS usage

[![NPM](https://img.shields.io/npm/v/daton-lib.svg)](https://www.npmjs.com/package/daton-lib) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## Install

```bash
npm install --save daton-lib
```

## Usage

### CUSTOM LOGS

customColorLog will log in the console custom message in color which you can set

Example: 

```javascript
customColorLog('Log me green', 'green')
```

yellLog use it if you want to log something very important, console will yell at you 

Example: 

```javascript
yellLog('Yell at me ')
```

conditionLog has 3 params, first 2 are items in condition, third one is message
 This it will log only if condition is false

Example: 

```javascript
yellLog( 5, 10 , 'Will be logged' ) 
yellLog( 5, 5 , 'Not be logged' )
```


### custom hooks 

getScrollPosition

useScrollPosition

useCurrentWidth


#### DATES

**icelandicDays** - array with icleandic days [mon-sun]

**monthNames** - array with Icelandic months [jan-dec]

**convertNumbersArrToDatesArr** -  recieve one arg ( array with numbers ) and returns array with object ready for graph shape

```js script
let testArray = [1,2,3,4,5,6,7]
convertNumbersArrToDatesArr(testArray)
```

**convertDateToIcelandic** - convert current date to Icelandic date. It recieve 2 params (postDate: string | Date & format: DateFormat). 
DateFormat can be 'DDMMYY' | 'MMDDYY' | 'MMYY' | 'DDMM'
 
**calculateDayBeforeXDays** - calculate days before today, so it recieve one param ( xDays ). Function will return Date (xDays before today).
```js script
calculateDayBeforeXDays(4) //It will return 4 days before today in date format
```

**convertMonthsToGraphData** - convert array with numbers and returns array with objects in right shape for graph
   
#### Arrays & Objects

**compareIds** 
compare two numbers & return boolean
```jsx 
compareIds(1, 2)
```

**changeObjectPropAndReturnNewObject** - params (object, key, value)
Change property of existing object, but without mutating. This function returns new object 

```js script

const testObj = {
  a: 1,
  b: 2,
  c: 3
  }
  const newObj = changeObjectPropAndReturnNewObject(testObj, 'c', 10) 
  console.log(testObj)/// {a: 1, b: 2, c: 3}
  console.log(newObj)/// {a: 1, b: 2, c: 10}
```

**changeObjectPropAndMutateObject** - 3 params (object, key, value)
Change property of existing object, but without mutating. This function returns new object 

```js script

const testObj = {
  a: 1,
  b: 2,
  c: 3
  }
  const newObj = changeObjectPropAndMutateObject(testObj, 'c', 10) 
  console.log(testObj)/// {a: 1, b: 2, c: 10}
  console.log(newObj)/// {a: 1, b: 2, c: 10}
```

**splitArr** - 2 params (array, size). 
First param is array which needs to be splited 
Second param is size of children array

```jsx 
let testArr = [1,2,3,4,5,6,7,8]
splitArr(1, 2) //Result [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ], [ 7,8 ] ]
splitArr(1, 4)// Result [ [ 1, 2, 3, 4 ], [ 5, 6, 8, 7 ] ]
splitArr(1, 5) //Result [ [ 1, 2, 3, 4, 5 ], [ 6, 8, 7 ] ]
```

**convertArrToString** - param (array)  
Return string from array

```js script
const testArr = ['T', 'e', 's', 't'] 
convertArrToString(testArr) // => return Test
```

**flipArr** - param (array)
Reverse items in array

## License

MIT © [Milan Poznan](https://github.com/Milan Poznan)

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