Ramda Adjunct 5.1.0

pathNotEq.js

  1. import { pathEq, complement } from 'ramda';
  2. /* eslint-disable max-len */
  3. /**
  4. * Determines whether a nested path on an object doesn't have a specific value,
  5. * in R.equals terms. Most likely used to filter a list.
  6. *
  7. * @func pathNotEq
  8. * @memberOf RA
  9. * @since {@link https://char0n.github.io/ramda-adjunct/2.4.0|v2.4.0}
  10. * @category Relation
  11. * @sig a => [Idx] => {a} => Boolean
  12. * @sig Idx = String | Int | Symbol
  13. * @param {a} val The value to compare the nested property with
  14. * @param {Array} path The path of the nested property to use
  15. * @param {Object} object The object to check the nested property in
  16. * @return {boolean} Returns Boolean `false` if the value equals the nested object property, `true` otherwise
  17. * @see {@link http://ramdajs.com/docs/#pathEq|R.pathEq}
  18. * @example
  19. *
  20. * const user1 = { address: { zipCode: 90210 } };
  21. * const user2 = { address: { zipCode: 55555 } };
  22. * const user3 = { name: 'Bob' };
  23. * const users = [ user1, user2, user3 ];
  24. * const isFamous = RA.pathNotEq(90210, ['address', 'zipCode']);
  25. * R.filter(isFamous, users); //=> [ user2, user3 ]
  26. */
  27. /* eslint-enable max-len */
  28. const pathNotEq = complement(pathEq);
  29. export default pathNotEq;