copy-function

    1.0.1 • Public • Published

    copy-function Build Status js-standard-style

    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

    Install

    npm i copy-function

    DownloadsWeekly Downloads

    2

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • tjmehta