Function.prototype.methodize >= 0.1.0

Purpose

Create a function that will call the given function with 'this' as the first argument

Syntax

Function#methodize ( Stringname );

Parameters

name
The name to use for the wrapper

Return values

Function

Examples

var fnc = function(obj){return obj.something;},
    test = {something: 'TEST'};

// Use the original function by passing the object manually
fnc(test);>>> "TEST"

// Add the methodized function to the object
test.fnc = fnc.methodize();

// Call the newly set method
test.fnc();>>> "TEST"