We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 792d0b4 commit 813a80cCopy full SHA for 813a80c
src/utils/isPlainObject.ts
@@ -3,12 +3,13 @@
3
* @returns True if the argument appears to be a plain object.
4
*/
5
export default function isPlainObject(obj: any): boolean {
6
- if (typeof obj !== 'object' || obj === null) return false
+ if (!obj) return false
7
8
- let proto = obj
9
- while (Object.getPrototypeOf(proto) !== null) {
10
- proto = Object.getPrototypeOf(proto)
11
- }
+ const proto = Object.getPrototypeOf(obj)
12
13
- return Object.getPrototypeOf(obj) === proto
+ return (
+ proto === null ||
+ (Object.getPrototypeOf(proto) === null &&
+ proto.constructor === obj.constructor)
14
+ )
15
}
0 commit comments