has.js 915 B

12345678910111213141516171819202122232425262728293031323334
  1. import _curry2 from "./internal/_curry2.js";
  2. import hasPath from "./hasPath.js";
  3. /**
  4. * Returns whether or not an object has an own property with the specified name
  5. *
  6. * @func
  7. * @memberOf R
  8. * @since v0.7.0
  9. * @category Object
  10. * @sig s -> {s: x} -> Boolean
  11. * @param {String} prop The name of the property to check for.
  12. * @param {Object} obj The object to query.
  13. * @return {Boolean} Whether the property exists.
  14. * @example
  15. *
  16. * const hasName = R.has('name');
  17. * hasName({name: 'alice'}); //=> true
  18. * hasName({name: 'bob'}); //=> true
  19. * hasName({}); //=> false
  20. *
  21. * const point = {x: 0, y: 0};
  22. * const pointHas = R.has(R.__, point);
  23. * pointHas('x'); //=> true
  24. * pointHas('y'); //=> true
  25. * pointHas('z'); //=> false
  26. */
  27. var has =
  28. /*#__PURE__*/
  29. _curry2(function has(prop, obj) {
  30. return hasPath([prop], obj);
  31. });
  32. export default has;