UNPKG

@aikidosec/firewall

Version:

Zen by Aikido is an embedded Application Firewall that autonomously protects Node.js apps against common and critical attacks, provides rate limiting, detects malicious traffic (including bots), and more.

42 lines (41 loc) 1.29 kB
"use strict"; /** * Grabbed from https://github.com/jonschlinkert/is-plain-object */ Object.defineProperty(exports, "__esModule", { value: true }); exports.isPlainObject = isPlainObject; function isObject(o) { return Object.prototype.toString.call(o) === "[object Object]"; } /** * This function examines an object to check if it's a plain object. * @param o The object you want to examine * @returns True when it is a plain object, otherwise false * @example * isPlainObject(Object.create({})) // Returns true * @example * isPlainObject({ foo: "bar" }) // Returns true * @example * isPlainObject(new Foo()) // Returns false */ function isPlainObject(o) { let ctor, prot; if (isObject(o) === false) return false; // It has modified constructor // eslint-disable-next-line prefer-const ctor = o.constructor; if (ctor === undefined) return true; // It has modified prototype // eslint-disable-next-line prefer-const prot = ctor.prototype; if (isObject(prot) === false) return false; // Its constructor does not have an Object-specific method if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) { return false; } // Most likely a plain Object return true; }