all files / src/ util.js

100% Statements 7/7
100% Branches 6/6
100% Functions 1/1
100% Lines 7/7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27                      210× 130×     80×     80×       76×    
/* eslint-disable-next-line no-redeclare */
/* global hasOwn, toString */
 
/**
 * Assert whether a value is a plain object or not.
 *
 * @memberof OO
 * @param {any} obj
 * @return {boolean}
 */
OO.isPlainObject = function ( obj ) {
	// Optimise for common case where internal [[Class]] property is not "Object"
	if ( !obj || toString.call( obj ) !== '[object Object]' ) {
		return false;
	}
 
	var proto = Object.getPrototypeOf( obj );
 
	// Objects without prototype (e.g., `Object.create( null )`) are considered plain
	if ( !proto ) {
		return true;
	}
 
	// The 'isPrototypeOf' method is set on Object.prototype.
	return hasOwn.call( proto, 'isPrototypeOf' );
};