copy-function
v1.0.1
Published
copy a function by wrapping it with a closure
Downloads
17
Maintainers
Readme
copy-function
copy a function by wrapping it w/ a closure
Installation
npm install copy-function
Usage
var copyFunc = require('copy-function')
function add (a, b) {
return a + b
}
var addCopy = copyFunc(add)
console.log(addCopy === add) // false
console.log(addCopy(1, 2)) // 3
console.log(addCopy.name) // "add"
console.log(addCopy.length) // 2
// give the copy a custom name
var addCopy = copyFunc(add, 'addCopy')
console.log(addCopy.name) // "addCopy"
License
MIT