ramda-extension
Version:
Helpful functions built on top of the mighty Ramda
34 lines (29 loc) • 1.03 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _ramda = require("ramda");
var _isNotNil = _interopRequireDefault(require("./isNotNil"));
/**
* Returns true if the argument is a plain object.
*
* @func
* @category Type
*
* @param {any} x value to test
* @return {boolean} whether the argument is a plain object
*
* @example
*
* R_.isPlainObject({}) // true
* R_.isPlainObject([]) // false
* R_.isPlainObject(null) // false
*
* @sig a -> Boolean
*/
var isPlainObject = (0, _ramda.allPass)([(0, _ramda.o)((0, _ramda.equals)('Object'), _ramda.type), _isNotNil.default, (0, _ramda.either)((0, _ramda.o)((0, _ramda.equals)(Object.prototype), Object.getPrototypeOf), // NOTE: prototype is null if created using Object.create(null)
(0, _ramda.o)(_ramda.isNil, Object.getPrototypeOf))]);
var _default = isPlainObject;
exports.default = _default;