CoolFace
Datasetpublic

basant307/AI_Governance_Project

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes45downloads
negate.js41 linesDownload Raw Back to lodash
1/** Error message constants. */2var FUNC_ERROR_TEXT = 'Expected a function';3 4/**5 * Creates a function that negates the result of the predicate `func`. The6 * `func` predicate is invoked with the `this` binding and arguments of the7 * created function.8 *9 * @static10 * @memberOf _11 * @since 3.0.012 * @category Function13 * @param {Function} predicate The predicate to negate.14 * @returns {Function} Returns the new negated function.15 * @example16 *17 * function isEven(n) {18 *   return n % 2 == 0;19 * }20 *21 * _.filter([1, 2, 3, 4, 5, 6], _.negate(isEven));22 * // => [1, 3, 5]23 */24function 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 40module.exports = negate;41 
basant307/AI_Governance_Project · CoolFace