Launch Week Day 2: Introducing Reports: An Extensible Reporting Framework for Socket Data.Learn More
Socket
Book a DemoSign in
Socket

methodize

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

methodize

Makes a function behaves as a method.

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

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

method

FAQs

Package last updated on 16 Jul 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts