November Perfect Moustache

    methodize

    0.1.0 • Public • Published

    methodize

    Build Status Dependency Status devDependency Status

    Makes a function behaves as a method.

    Install

    Download manually or with package-manager.

    npm

    npm install --save methodize
    

    bower

    bower install --save methodize
    

    Example

    var methodize = require('methodize');
     
    var person = {
      firstName: 'Gaius',
      lastName: 'Baltar',
    };
     
    function getFullName(person) {
      return person.firstName +' '+ person.lastName;
    };
     
    // Methodize the function and attaches it to the person object.
    //
    // The method name is retrieved from the original function if it is a
    // named function.
    //
    // A custom name can be specified as a second parameter to attachTo().
    methodize(getFullName).attachTo(person);
     
    // Profit :)
    console.log(person.getFullName());

    Contributions

    Contributions are very welcomed, either on the documentation or on the code.

    You may:

    • report any issue you've encountered;
    • fork and create a pull request.

    License

    ISC © Julien Fontanet

    Keywords

    Install

    npm i methodize

    DownloadsWeekly Downloads

    6

    Version

    0.1.0

    License

    ISC

    Last publish

    Collaborators

    • julien-f
    • marsaud