macalinao / Functionize
Licence: mit
Turns an object into an object that can be called as a function.
Programming Languages
javascript
184084 projects - #8 most used programming language
Functionize
Turns an object into an object that can be called as a function.
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!
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].