All files / src/preds isPlainObj.js

0% Statements 0/8
0% Branches 0/6
0% Functions 0/1
0% Lines 0/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23                                             
var isObj = require( './isObj' );
 
function isPlainObject( x ) {
// Basic check for Type object that's not null
  if ( isObj( x ) ) {
 
    // If Object.getPrototypeOf supported, use it
    if ( typeof Object.getPrototypeOf == 'function' ) {
      var proto = Object.getPrototypeOf( x );
      return proto === Object.prototype || proto === null;
    }
 
    // Otherwise, use internal class
    // This should be reliable as if getPrototypeOf not supported, is pre-ES5
    return Object.prototype.toString.call( x ) == '[object Object]';
  }
 
  // Not an object
  return false;
}
 
module.exports = isPlainObject;