(obj)
| 19 | * @return {boolean} `true` if the object is plain, otherwise `false`. |
| 20 | */ |
| 21 | var IsPlainObject = function (obj) |
| 22 | { |
| 23 | // Not plain objects: |
| 24 | // - Any object or value whose internal [[Class]] property is not "[object Object]" |
| 25 | // - DOM nodes |
| 26 | // - window |
| 27 | if (!obj || typeof(obj) !== 'object' || obj.nodeType || obj === obj.window) |
| 28 | { |
| 29 | return false; |
| 30 | } |
| 31 | |
| 32 | // Support: Firefox <20 |
| 33 | // The try/catch suppresses exceptions thrown when attempting to access |
| 34 | // the "constructor" property of certain host objects, ie. |window.location| |
| 35 | // https://bugzilla.mozilla.org/show_bug.cgi?id=814622 |
| 36 | try |
| 37 | { |
| 38 | if (obj.constructor && !({}).hasOwnProperty.call(obj.constructor.prototype, 'isPrototypeOf')) |
| 39 | { |
| 40 | return false; |
| 41 | } |
| 42 | } |
| 43 | catch (e) |
| 44 | { |
| 45 | return false; |
| 46 | } |
| 47 | |
| 48 | // If the function hasn't returned already, we're confident that |
| 49 | // |obj| is a plain object, created by {} or constructed with new Object |
| 50 | return true; |
| 51 | }; |
| 52 | |
| 53 | module.exports = IsPlainObject; |
no outgoing calls
no test coverage detected
searching dependent graphs…