@storm-stack/types
Version:
⚡ The storm-stack monorepo contains utility applications, tools, and various libraries to create modern and scalable web applications.
18 lines (17 loc) • 509 B
JavaScript
import { getObjectTag } from "./get-object-tag.mjs";
export const isObjectLike = (obj) => {
return typeof obj === "object" && obj !== null;
};
export const isPlainObject = (obj) => {
if (!isObjectLike(obj) || getObjectTag(obj) !== "[object Object]") {
return false;
}
if (Object.getPrototypeOf(obj) === null) {
return true;
}
let proto = obj;
while (Object.getPrototypeOf(proto) !== null) {
proto = Object.getPrototypeOf(proto);
}
return Object.getPrototypeOf(obj) === proto;
};