You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
783 B

4 years ago
  1. import _curry3 from "./internal/_curry3.js";
  2. import path from "./path.js";
  3. /**
  4. * Returns `true` if the specified object property at given path satisfies the
  5. * given predicate; `false` otherwise.
  6. *
  7. * @func
  8. * @memberOf R
  9. * @since v0.19.0
  10. * @category Logic
  11. * @typedefn Idx = String | Int
  12. * @sig (a -> Boolean) -> [Idx] -> {a} -> Boolean
  13. * @param {Function} pred
  14. * @param {Array} propPath
  15. * @param {*} obj
  16. * @return {Boolean}
  17. * @see R.propSatisfies, R.path
  18. * @example
  19. *
  20. * R.pathSatisfies(y => y > 0, ['x', 'y'], {x: {y: 2}}); //=> true
  21. * R.pathSatisfies(R.is(Object), [], {x: {y: 2}}); //=> true
  22. */
  23. var pathSatisfies =
  24. /*#__PURE__*/
  25. _curry3(function pathSatisfies(pred, propPath, obj) {
  26. return pred(path(propPath, obj));
  27. });
  28. export default pathSatisfies;