1.0.6 • Published 6 years ago

run-objfun v1.0.6

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

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

CommitsContributor
7Black-Hole

Author

Black-Hole

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago