00001 00002 var FUNC_ERROR_TEXT = 'Expected a function'; 00003 00024 function negate(predicate) { 00025 if (typeof predicate != 'function') { 00026 throw new TypeError(FUNC_ERROR_TEXT); 00027 } 00028 return function() { 00029 var args = arguments; 00030 switch (args.length) { 00031 case 0: return !predicate.call(this); 00032 case 1: return !predicate.call(this, args[0]); 00033 case 2: return !predicate.call(this, args[0], args[1]); 00034 case 3: return !predicate.call(this, args[0], args[1], args[2]); 00035 } 00036 return !predicate.apply(this, args); 00037 }; 00038 } 00039 00040 module.exports = negate;