# @savo/js-utils

> JS utils collection

Latest version **0.3.1** (published 2021-04-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install @savo/js-utils
pnpm add @savo/js-utils
yarn add @savo/js-utils
bun add @savo/js-utils
```

## Health

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

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2021-04-26 |
| First published | 2018-06-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | savokiss |
| Maintainers | savokiss |

## Links

- npm: https://www.npmjs.com/package/@savo/js-utils
- Repository: https://github.com/savokiss/js-utils
- Homepage: https://github.com/savokiss/js-utils#readme
- Issues: https://github.com/savokiss/js-utils/issues
- npm.io page: https://npm.io/package/@savo/js-utils

## Recent versions

- 0.3.1 (latest) — 2021-04-26
- 0.3.0 — 2018-07-02
- 0.2.0 — 2018-06-27
- 0.1.2 — 2018-06-25
- 0.1.1 — 2018-06-04
- 0.1.0 — 2018-06-04

## README

# js-utils

JS utils collection

## Install

```bash
npm i @savo/js-utils
```

## Usage

### Storage

```js
import { storage } from '@savo/js-utils'

storage.setItem(key, value) // value support object
storage.getItem(key) // auto convert to object
storage.removeItem(key)
storage.clear() // clear all
```

### Matrix

```js
import { Matrix } from '@savo/js-utils'

const matrix = new Matrix(list, rowCount, colCount)

matrix.getCol(0) // get the first col

matrix.getRow(1) // get the second row

```

### poller

#### using like setInterval

```js
import axios from 'axios'
import { poller } from '@savo/js-utils'

poller(retry => {
  axios.get(url).then(res => {
    retry() // retry when request finished
  })
}, 3000)
```

#### request retry

```js
import axios from 'axios'
import { poller } from '@savo/js-utils'

poller(retry => {
  axios.get(url).then(res => {
    if(res.data.ok) {
      doSomething(res)
    } else {
      retry() // only retry when request fail
    }
  })
}, 3000, 1.5)
```

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