UNPKG

323 BJavaScriptView Raw
1const OBJP = Object.getPrototypeOf;
2/**
3 * Similar to {@link isObject}, but also checks if prototype is that of
4 * `Object` (or `null`).
5 *
6 * @param x -
7 */
8export const isPlainObject = (x) => {
9 let p;
10 return (x != null &&
11 typeof x === "object" &&
12 ((p = OBJP(x)) === null || OBJP(p) === null));
13};