UNPKG

ramda-extension

Version:

Helpful functions built on top of the mighty Ramda

25 lines (24 loc) 797 B
import { allPass, type, o, equals, either, isNil } from 'ramda'; import isNotNil from './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 = /*#__PURE__*/allPass([/*#__PURE__*/o( /*#__PURE__*/equals('Object'), type), isNotNil, /*#__PURE__*/either( /*#__PURE__*/o( /*#__PURE__*/equals(Object.prototype), Object.getPrototypeOf), /*#__PURE__*/ // NOTE: prototype is null if created using Object.create(null) o(isNil, Object.getPrototypeOf))]); export default isPlainObject;