Skip to content

macalinao/functionize

Repository files navigation

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!

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published