UNPKG

@thi.ng/checks

Version:
14 lines (13 loc) 323 B
const OBJP = Object.getPrototypeOf; /** * Similar to {@link isObject}, but also checks if prototype is that of * `Object` (or `null`). * * @param x - */ export const isPlainObject = (x) => { let p; return (x != null && typeof x === "object" && ((p = OBJP(x)) === null || OBJP(p) === null)); };