UNPKG

445 BPlain TextView Raw
1/**
2 * @param obj The object to inspect.
3 * @returns True if the argument appears to be a plain object.
4 */
5export default function isPlainObject(obj: any): obj is object {
6 if (typeof obj !== 'object' || obj === null) return false
7
8 let proto = obj
9 while (Object.getPrototypeOf(proto) !== null) {
10 proto = Object.getPrototypeOf(proto)
11 }
12
13 return (
14 Object.getPrototypeOf(obj) === proto || Object.getPrototypeOf(obj) === null
15 )
16}