var ArgumentError = require('./ArgumentError');
var topiarist = require('topiarist');

function verifierMethod(verifier, methodName) {
  return function() {
    if(!this.skipVerification) {
      if(this.argValue === undefined) throw new ArgumentError(this.argName + ' argument must be provided.');

      verifier[methodName].apply(this, arguments);
    }

    if(this.argsVerifier.argIndex < this.argsVerifier.arguments.length) {
      this.argsVerifier.constructor.pendingVerifier = this.argsVerifier;
    }

    return this.argsVerifier;
  };
}

function ArgVerifier(argsVerifier, argName, argValue) {
  this.argsVerifier = argsVerifier;
  this.argName = argName;
  this.argValue = argValue;
}

ArgVerifier.addVerifier = function(verifier) {
  for(var methodName in verifier) {
    ArgVerifier.prototype[methodName] = verifierMethod(verifier, methodName);
  }
};

Object.defineProperty(ArgVerifier.prototype, 'optionally', {
  get: function optionally() {
    if((this.argValue === undefined) || (this.argValue === null)) {
      this.skipVerification = true;
    }

    return this;
  }
});

module.exports = ArgVerifier;

@@ -112,28 +112,22 @@
 verifier
-, m
+M
 ethod
-Name
 ) %7B%0A  re
@@ -140,16 +140,19 @@
 unction(
+arg
 ) %7B%0A    
@@ -308,26 +308,19 @@
 fier
-%5Bm
+M
 ethod
-Name%5D.apply
+.call
 (thi
@@ -325,22 +325,16 @@
 his, arg
-uments
 );%0A    %7D
@@ -822,18 +822,17 @@
 verifier
-, 
+%5B
 methodNa
@@ -833,16 +833,17 @@
 thodName
+%5D
 );%0A  %7D%0A%7D

Use call() rather than apply() to improve performance.