# vi-misc

> [![NPM version][npm-image]][npm-url] [![build status][travis-image]][travis-url] [![Test coverage][coveralls-image]][coveralls-url]

Latest version **1.14.1** (published 2018-05-04) · 0 weekly downloads

## Install

```sh
npm install vi-misc
pnpm add vi-misc
yarn add vi-misc
bun add vi-misc
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.14.1 |
| Published | 2018-05-04 |
| First published | 2015-01-31 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 7.6 |
| Dependencies | 2 |
| Unpacked size | 26.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Sun Haohao |
| Maintainers | viringbells |

## Links

- npm: https://www.npmjs.com/package/vi-misc
- Repository: h
- npm.io page: https://npm.io/package/vi-misc

## Dependencies (2)

- [extend](https://npm.io/package/extend.md) ^3.0.1
- [bluebird](https://npm.io/package/bluebird.md) ^3.5.1

## Recent versions

- 1.14.1 (latest) — 2018-05-04
- 1.14.0 — 2018-05-04
- 1.13.2 — 2017-11-21
- 1.13.1 — 2017-11-21
- 1.13.0 — 2017-11-21
- 1.12.0 — 2017-11-20
- 1.11.0 — 2017-11-20
- 1.10.0 — 2017-11-13
- 1.9.2 — 2017-07-19
- 1.9.1 — 2017-07-17
- 1.9.0 — 2017-07-17
- 1.8.0 — 2017-07-05
- 1.7.0 — 2017-07-05
- 1.6.0 — 2017-07-04
- 1.5.0 — 2017-06-27
- … 13 more at https://npm.io/package/vi-misc/versions

## README

# vi-misc

[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]

A set of utils...

# misc.function
Utils for functions

* function.once(...func_list) - make sure the given functions will not be executed more than onece.
* function.limit(func_list, options) - make sure the given functions will be executed more than a certain count.

# misc.number
The number utils

* number.th - Append 'th' on a number.

# misc.object
Utils for objects.

* clone(object) - Deep clone
* merge(object, ...sources) - Deep merge
* each(object, handler) - Apply handlers for each property of the object.
* hasByKey(object, ...keys) - Test if object.xxx.xxx.xxx exists, which xxx,xxx,xxx as just the param 'keys'
* setByKeys(object, value, ...keys)
* getByKeys(object, value, ...keys)
  * This is supposed to be used when keys are dynamic and uncertain. In other cases, use object.xx.xx.xx directly.

# misc.path
The path utils

* path.root - returns the app root, which is the directory of main module file.
* path.absolute(target) - make target into absolute form and return.
* path.split(target, sep = path.sep) - split target into array.

# misc.async
Promisify with bluebird

* all(target, options) - Promisify all method for callback(error, result) like cases.
* catchError(promise) - Catch and return the error the promise throws. Otherwise returns null.

# misc.time
The time utils

* time.format - format time, `time.format('YYYY-MM-DD HH:II:SS')`.

# misc.Error
The custom error

* new Error(message, code) - Create an error with custom code
* new Error(message, props) - Create an error with properties assigned with argument `props`


[npm-image]: https://img.shields.io/npm/v/vi-misc.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/vi-misc
[travis-image]: https://img.shields.io/travis/viRingbells/vi-misc/master.svg?style=flat-square
[travis-url]: https://travis-ci.org/viRingbells/vi-misc
[coveralls-image]: https://img.shields.io/codecov/c/github/viRingbells/vi-misc.svg?style=flat-square
[coveralls-url]: https://codecov.io/github/viRingbells/vi-misc?branch=master

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