Home

Awesome

is-empty-function npmjs.com The MIT License

Check that given string, function or arrow function have empty body, using parse-function.

code climate standard code style travis build status coverage status dependency status

Install

npm i is-empty-function --save

Usage

For more use-cases see the tests

const isEmptyFunction = require('is-empty-function')

isEmptyFunction

Check that given string, function or arrow function have empty body, using parse-function.

Example

const isEmptyFunction = require('is-empty-function')

const fixture = "function codeCov () {__cov_Ejgcx$XN18CSfmeWn$f7vQ.f['2']++;};"
isEmptyFunction(fixture)            // => true
isEmptyFunction('function () {}')   // => true
isEmptyFunction('z => {}')          // => true
isEmptyFunction('(a, b) => {}')     // => true
isEmptyFunction(z => {})            // => true
isEmptyFunction((a, b) => {})       // => true

// return `false`
isEmptyFunction('function () { return true }')      // => false
isEmptyFunction('z => { return z * z }')            // => false
isEmptyFunction('(a, b) => {}')                     // => false
isEmptyFunction(z => { return z + z })              // => false
isEmptyFunction((a, b) => { return a * b})          // => false
isEmptyFunction((a, b) => a * 2 * z)                // => false
isEmptyFunction(function () { return true })        // => false
isEmptyFunction(function named () { return true })  // => false

Related

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckocore.tk keybase tunnckocore tunnckoCore npm tunnckoCore twitter tunnckoCore github