dthree / vorpal

Node's framework for interactive CLIs
http://vorpal.js.org
MIT License
5.64k stars 280 forks source link

Really weird behavior when using Function.prototype monkey-patch #255

Closed ORESoftware closed 7 years ago

ORESoftware commented 7 years ago

I have this patch in my codebase

Function.prototype.adhere = function () {

  let self = this;
  let args1 = Array.from(arguments);

  return function () {

    let args2 = Array.from(arguments);
    return self.apply(this, args1.concat(args2));
  }

};

When I use Vorpal like so:

 .action(function(args,cb){
      console.log('args =>',args);
       cb(null);
    });

for args I get:

args => { options: {}, adhere: [Function] }

when I remove the adhere monkey-patch on Function.prototype, I get:

args => { options: {}}

the heck is going on? :)