source: node_modules/ramda/es/hasIn.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 961 bytes
RevLine 
[d24f17c]1import _curry2 from "./internal/_curry2.js";
2import isNil from "./isNil.js";
3/**
4 * Returns whether or not an object or its prototype chain has a property with
5 * the specified name
6 *
7 * @func
8 * @memberOf R
9 * @since v0.7.0
10 * @category Object
11 * @sig s -> {s: x} -> Boolean
12 * @param {String} prop The name of the property to check for.
13 * @param {Object} obj The object to query.
14 * @return {Boolean} Whether the property exists.
15 * @example
16 *
17 * function Rectangle(width, height) {
18 * this.width = width;
19 * this.height = height;
20 * }
21 * Rectangle.prototype.area = function() {
22 * return this.width * this.height;
23 * };
24 *
25 * const square = new Rectangle(2, 2);
26 * R.hasIn('width', square); //=> true
27 * R.hasIn('area', square); //=> true
28 */
29
30var hasIn =
31/*#__PURE__*/
32_curry2(function hasIn(prop, obj) {
33 if (isNil(obj)) {
34 return false;
35 }
36
37 return prop in obj;
38});
39
40export default hasIn;
Note: See TracBrowser for help on using the repository browser.