omnibelt/none-pass.js

  1. const complement = require('ramda/src/complement');
  2. const anyPass = require('ramda/src/anyPass');
  3. /**
  4. * Takes a list of predicates and returns a predicate that returns true for a
  5. * given list of arguments if at none of the provided predicates is satisfied
  6. * by those arguments.
  7. *
  8. * The function returned is a curried function whose arity matches that of the
  9. * highest-arity predicate.
  10. *
  11. * @signature [(*... -> Boolean)] -> (*... -> Boolean)
  12. *
  13. * @example
  14. * const isClub = propEq('♣', 'suit');
  15. * const isSpade = propEq('♠', 'suit');
  16. * const isRedCard = nonePass([isClub, isSpade]);
  17. *
  18. * isRedCard({ rank: '10', suit: '♣' }); //=> false
  19. * isRedCard({ rank: 'Q', suit: '♠' }); //=> false
  20. * isRedCard({ rank: 'Q', suit: '♦' }); //=> true
  21. */
  22. const nonePass = (predicates) => complement(anyPass(predicates));
  23. module.exports = nonePass;