functionize

0.1.1 • Public • Published

Functionize

Turns an object into an object that can be called as a function.

build status

Installation

This module is installed via npm:

$ npm install functionize --save

Or Bower:

$ bower install functionize --save

Example

var functionize = require('functionize');
 
var object = {
  counter: 1,
  add: function(amt) {
    return this.counter += amt;
  }
};
 
// The normal way
console.log(object.counter); // 1
console.log(object.add(9)); // 10
 
// The functionized way
object = functionize(object, object.add);
console.log(object.counter); // 10
console.log(object(9)); // 19
console.log(object.add(1)); // 20 -- still works!

Pretty cool, eh? Take control of your objects!

Package Sidebar

Install

npm i functionize

Weekly Downloads

0

Version

0.1.1

License

MIT

Last publish

Collaborators

  • simplyianm