Skip to content

Instantly share code, notes, and snippets.

@neall
Last active August 29, 2015 13:59

Revisions

  1. neall revised this gist Apr 14, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion methToFunc.js
    Original file line number Diff line number Diff line change
    @@ -3,8 +3,9 @@ Object.defineProperty(Object.prototype, 'methToFunc', {
    var method = this[methodName];
    if (typeof method === 'function') {
    var curryArgs = [].slice.call(arguments, 1);
    var that = this;
    return function() {
    return method.apply(this, curryArgs.concat(arguments));
    return method.apply(that, curryArgs.concat(arguments));
    };
    } else {
    return function() {
  2. neall created this gist Apr 14, 2014.
    15 changes: 15 additions & 0 deletions methToFunc.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    Object.defineProperty(Object.prototype, 'methToFunc', {
    value: function(methodName) {
    var method = this[methodName];
    if (typeof method === 'function') {
    var curryArgs = [].slice.call(arguments, 1);
    return function() {
    return method.apply(this, curryArgs.concat(arguments));
    };
    } else {
    return function() {
    return method;
    };
    }
    }
    });