arcade-physics
Version:
Use Arcade Physics without Phaser.
44 lines • 1.56 kB
JavaScript
;
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2020 Photon Storm Ltd.
* @license {@link https://opensource.org/licenses/MIT|MIT License}
*/
Object.defineProperty(exports, "__esModule", { value: true });
/**
* This is a slightly modified version of jQuery.isPlainObject.
* A plain object is an object whose internal class property is [object Object].
*
* @function Phaser.Utils.Objects.IsPlainObject
* @since 3.0.0
*
* @param {object} obj - The object to inspect.
*
* @return {boolean} `true` if the object is plain, otherwise `false`.
*/
const IsPlainObject = obj => {
// Not plain objects:
// - Any object or value whose internal [[Class]] property is not "[object Object]"
// - DOM nodes
// - window
if (typeof obj !== 'object' || obj.nodeType || obj === obj.window) {
return false;
}
// Support: Firefox <20
// The try/catch suppresses exceptions thrown when attempting to access
// the "constructor" property of certain host objects, ie. |window.location|
// https://bugzilla.mozilla.org/show_bug.cgi?id=814622
try {
if (obj.constructor && !{}.hasOwnProperty.call(obj.constructor.prototype, 'isPrototypeOf')) {
return false;
}
}
catch (e) {
return false;
}
// If the function hasn't returned already, we're confident that
// |obj| is a plain object, created by {} or constructed with new Object
return true;
};
exports.default = IsPlainObject;
//# sourceMappingURL=IsPlainObject.js.map