run-objfun

1.0.6 • Public • Published

run-objFun

Node Version Build Status Coverage Status Npm Downlaod

NPM

Functions in running objects

install

# Install with npm
$ npm install run-objfun --save
 
# Install with yarn
$ yarn add run-objfun
 
# Install with bower
$ bower install run-objfun --save

Usage

function is ES5 or ES6

const runObjFun = require('run-objfun')
 
let arr = []
const fun1 = () => {
  arr.push(1)
}
const fun2 = function() {
  arr.push(2)
}
const obj = {
  fun1,
  fun2,
  fun3: function() {
    arr.push(3)
  },
  fun4: () => {
    arr.push(4)
  }
}
 
runObjFun(obj) //=> true
console.log(arr) //=> [1, 2, 3, 4]

Skip non object

const runObjFun = require('run-objfun')
 
let i = 0
const fun1 = () => {  // Run successfully
  ++i
}
const fun2 = () => {  // Run successfully
  ++i
}
const generator1 = function * () {
  ++i
}
const array1 = [1, 2, 3]
const number1 = 123
const regexp1 = /foo/
const string1 = 'string'
const bool1 = true
const bool2 = false
const undefined1 = undefined
const null1 = null
 
const obj = {
  fun1,
  fun2,
  generator1,
  array1,
  number1,
  regexp1,
  string1,
  bool1,
  bool2,
  undefined1,
  null1
}
 
runObjFun(obj) //=> true
console.log(i) //=> 2

Type judgment

const runObjFun = require('run-objfun')
 
const arr = []
 
runObjFun(arr) //=> false

Running tests

Install dev dependencies:

$ npm i -d && npm test

Contributing

Commits Contributor
7 Black-Hole

Author

Black-Hole

Package Sidebar

Install

npm i run-objfun

Weekly Downloads

8

Version

1.0.6

License

MIT

Unpacked Size

6.41 kB

Total Files

6

Last publish

Collaborators

  • black_hole