UNPKG

actionhero

Version:

actionhero.js is a multi-transport API Server with integrated cluster capabilities and delayed tasks

43 lines (42 loc) 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isPlainObject = void 0; /** * Is the JS Object passed in truly just an object? */ function isPlainObject(o) { const safeTypes = [ Boolean, Number, String, Function, Array, Date, RegExp, Buffer, ]; const safeInstances = ["boolean", "number", "string", "function"]; const expandPreventMatchKey = "_toExpand"; // set `_toExpand = false` within an object if you don't want to expand it let i; if (!o) { return false; } if (o instanceof Object === false) { return false; } for (i in safeTypes) { if (o instanceof safeTypes[i]) { return false; } } for (i in safeInstances) { if (typeof o === safeInstances[i]) { return false; } } if (o[expandPreventMatchKey] === false) { return false; } return o.toString() === "[object Object]"; } exports.isPlainObject = isPlainObject;