# toxic-utils

> utils

Latest version **0.4.3** (published 2019-06-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install toxic-utils
pnpm add toxic-utils
yarn add toxic-utils
bun add toxic-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.4.3 |
| Published | 2019-06-03 |
| First published | 2017-07-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 104.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | toxic-johann |
| Maintainers | toxicjohann |
| Keywords | utils |

## Links

- npm: https://www.npmjs.com/package/toxic-utils
- Repository: https://github.com/toxic-johann/toxic-utils
- Homepage: https://github.com/toxic-johann/toxic-utils#readme
- Issues: https://github.com/toxic-johann/toxic-utils/issues
- npm.io page: https://npm.io/package/toxic-utils

## Dependencies (1)

- [lodash-es](https://npm.io/package/lodash-es.md) ^4.17.11

## Recent versions

- 0.4.3 (latest) — 2019-06-03
- 0.3.0-alpha.1 (beta) — 2018-08-26
- 0.4.2 — 2019-06-02
- 0.4.0 — 2019-06-01
- 0.3.1 — 2019-04-25
- 0.3.0 — 2018-08-27
- 0.2.0 — 2017-11-25
- 0.1.6 — 2017-09-07
- 0.1.5 — 2017-07-24
- 0.1.4 — 2017-07-24
- 0.1.3 — 2017-07-06
- 0.1.2 — 2017-07-06
- 0.1.1 — 2017-07-02
- 0.1.0 — 2017-07-02

## README

# toxic-utils

[![Build Status](https://img.shields.io/travis/toxic-johann/toxic-utils/master.svg?style=flat-square)](https://travis-ci.org/toxic-johann/toxic-utils.svg?branch=master)
[![Coverage Status](https://img.shields.io/coveralls/toxic-johann/toxic-utils/master.svg?style=flat-square)](https://coveralls.io/github/toxic-johann/toxic-utils?branch=master)
[![npm](https://img.shields.io/npm/v/toxic-utils.svg?colorB=brightgreen&style=flat-square)](https://www.npmjs.com/package/toxic-utils)
[![dependency Status](https://david-dm.org/toxic-johann/toxic-utils.svg)](https://david-dm.org/toxic-johann/toxic-utils)
[![devDependency Status](https://david-dm.org/toxic-johann/toxic-utils/dev-status.svg)](https://david-dm.org/toxic-johann/toxic-utils?type=dev) [![Greenkeeper badge](https://badges.greenkeeper.io/toxic-johann/toxic-utils.svg)](https://greenkeeper.io/)

utils collection

## get started

```shell
npm install toxic-utils --save
```

if you are using `flow`, you should import our flow defination, by adding this to your `.flowconfig`.

```ya
[ignore]

[include]

[libs]
./node_modules/toxic-utils/lib/index.flow.js
[options]

[lints]
```

## doc

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### genTraversalHandler

[src/index.js:8-20](https://github.com/toxic-johann/toxic-utils/blob/2b6844986d149e8d81d0c29eb28c4d5a2b92e5f6/src/index.js#L8-L20 "Source code on GitHub")

the handler to generate an deep traversal handler

**Parameters**

-   `fn` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** the function you wanna run when you reach in the deep property

Returns **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** the handler

### deepClone

[src/index.js:27-32](https://github.com/toxic-johann/toxic-utils/blob/2b6844986d149e8d81d0c29eb28c4d5a2b92e5f6/src/index.js#L27-L32 "Source code on GitHub")

deeply clone an object

**Parameters**

-   `source` **([Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) \| [Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object))** if you pass in other type, it will throw an error

Returns **clone-target** the new Object

### deepAssign

[src/index.js:38-50](https://github.com/toxic-johann/toxic-utils/blob/2b6844986d149e8d81d0c29eb28c4d5a2b92e5f6/src/index.js#L38-L50 "Source code on GitHub")

merge multiple objects

**Parameters**

-   `args` **...[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** [description]

Returns **merge-object** [description]

### camelize

[src/index.js:57-63](https://github.com/toxic-johann/toxic-utils/blob/2b6844986d149e8d81d0c29eb28c4d5a2b92e5f6/src/index.js#L57-L63 "Source code on GitHub")

camelize any string, e.g hello world -> helloWorld

**Parameters**

-   `str` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** only accept string!
-   `isBig` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** 

Returns **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** camelize string

### hypenate

[src/index.js:69-71](https://github.com/toxic-johann/toxic-utils/blob/2b6844986d149e8d81d0c29eb28c4d5a2b92e5f6/src/index.js#L69-L71 "Source code on GitHub")

hypenate any string e.g hello world -> hello-world

**Parameters**

-   `str` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** only accept string

Returns **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** 

### bind

[src/index.js:78-90](https://github.com/toxic-johann/toxic-utils/blob/2b6844986d149e8d81d0c29eb28c4d5a2b92e5f6/src/index.js#L78-L90 "Source code on GitHub")

bind the function with some context. we have some fallback strategy here

**Parameters**

-   `fn` **[function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** the function which we need to bind the context on
-   `context` **any** the context object

Returns **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** 

### uuid

[src/index.js:95-97](https://github.com/toxic-johann/toxic-utils/blob/2b6844986d149e8d81d0c29eb28c4d5a2b92e5f6/src/index.js#L95-L97 "Source code on GitHub")

generate an uuid

Returns **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** 

### S4

[src/index.js:101-103](https://github.com/toxic-johann/toxic-utils/blob/2b6844986d149e8d81d0c29eb28c4d5a2b92e5f6/src/index.js#L101-L103 "Source code on GitHub")

generate an random number which length is 4

Returns **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** 

### rand

[src/index.js:108-114](https://github.com/toxic-johann/toxic-utils/blob/2b6844986d149e8d81d0c29eb28c4d5a2b92e5f6/src/index.js#L108-L114 "Source code on GitHub")

generate an random number with specific length

**Parameters**

-   `length` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** 

Returns **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** 

### getDeepProperty

[src/index.js:119-147](https://github.com/toxic-johann/toxic-utils/blob/2b6844986d149e8d81d0c29eb28c4d5a2b92e5f6/src/index.js#L119-L147 "Source code on GitHub")

get an deep property

**Parameters**

-   `obj` **any** 
-   `keys` **([string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) \| [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)>)** 
-   `$2` **any**  (optional, default `{}`)
    -   `$2.throwError`   (optional, default `false`)
    -   `$2.backup`

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