UNPKG

ramda.hasin

Version:

R.hasIn exported as a module

100 lines (91 loc) 2.74 kB
// Ramda v0.26.1 // https://github.com/ramda/ramda // (c) 2013-2019 Scott Sauyet, Michael Hurley, and David Chambers // Ramda may be freely distributed under the MIT license. (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (factory((global.R = {}))); }(this, (function (exports) { 'use strict'; function _isPlaceholder(a) { return a != null && typeof a === 'object' && a['@@functional/placeholder'] === true; } /** * Optimized internal one-arity curry function. * * @private * @category Function * @param {Function} fn The function to curry. * @return {Function} The curried function. */ function _curry1(fn) { return function f1(a) { if (arguments.length === 0 || _isPlaceholder(a)) { return f1; } else { return fn.apply(this, arguments); } }; } /** * Optimized internal two-arity curry function. * * @private * @category Function * @param {Function} fn The function to curry. * @return {Function} The curried function. */ function _curry2(fn) { return function f2(a, b) { switch (arguments.length) { case 0: return f2; case 1: return _isPlaceholder(a) ? f2 : _curry1(function(_b) { return fn(a, _b); }); default: return _isPlaceholder(a) && _isPlaceholder(b) ? f2 : _isPlaceholder(a) ? _curry1(function(_a) { return fn(_a, b); }) : _isPlaceholder(b) ? _curry1(function(_b) { return fn(a, _b); }) : fn(a, b); } }; } /** * Returns whether or not an object or its prototype chain has a property with * the specified name * * @func * @memberOf R * @since v0.7.0 * @category Object * @sig s -> {s: x} -> Boolean * @param {String} prop The name of the property to check for. * @param {Object} obj The object to query. * @return {Boolean} Whether the property exists. * @example * * function Rectangle(width, height) { * this.width = width; * this.height = height; * } * Rectangle.prototype.area = function() { * return this.width * this.height; * }; * * const square = new Rectangle(2, 2); * R.hasIn('width', square); //=> true * R.hasIn('area', square); //=> true */ var hasIn = _curry2(function hasIn(prop, obj) { return prop in obj; }); exports.hasIn = hasIn; Object.defineProperty(exports, '__esModule', { value: true }); })));