artdaq_node_server  v1_00_09
 All Classes Namespaces Files Variables Pages
negate.js
1 
2 var FUNC_ERROR_TEXT = 'Expected a function';
3 
24 function negate(predicate) {
25  if (typeof predicate != 'function') {
26  throw new TypeError(FUNC_ERROR_TEXT);
27  }
28  return function() {
29  var args = arguments;
30  switch (args.length) {
31  case 0: return !predicate.call(this);
32  case 1: return !predicate.call(this, args[0]);
33  case 2: return !predicate.call(this, args[0], args[1]);
34  case 3: return !predicate.call(this, args[0], args[1], args[2]);
35  }
36  return !predicate.apply(this, args);
37  };
38 }
39 
40 module.exports = negate;