1.0.0 • Published 8 years ago

function-equal v1.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

function-equal npmjs.com The MIT License

Compares two functions, are they equal? Checks their names, bodies and argument names. Powered by parse-function.

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

Install

npm i function-equal --save

Usage

For more use-cases see the tests

const functionEqual = require('function-equal')

functionEqual

Check two functions are strictly the same.

Params

  • a {Function}
  • b {Function}
  • returns {Boolean}

Example

var fnEqual = require('function-equal')

// returns true
console.log(fnEqual(fnEqual, fnEqual))
console.log(fnEqual(console.log, console.log))
console.log(fnEqual(function a (b, c) { return b + c }, function a (b, c) { return b + c }))

console.log(fnEqual(console.log, console.dir)) // => false
console.log(fnEqual(function a (foo) {}, function c (foo) {})) // => false
console.log(fnEqual(function a (foo) {}, function a (foo) {})) // => true
console.log(fnEqual(function a (foo) {return foo}, function a (foo) {return foo})) // => true
console.log(fnEqual(function a (foo) {}, function a (bar) {})) // => 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