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

Usage no npm install needed!

<script type="module">
  import viMisc from '';



NPM version build status Test coverage

A set of utils...


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.


The number utils

  • - Append 'th' on a number.


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 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.


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.


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.


The time utils

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


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