From 07575f38f49babcc6014dc898e77d39e4a9347b1 Mon Sep 17 00:00:00 2001 From: Ben Elliott <4996462+benelliott@users.noreply.github.com> Date: Wed, 9 Jun 2021 10:53:27 +0100 Subject: [PATCH] fix: isPlainObject: add quick comparison between input and `Object` to short-circuit taxing `Function.toString` invocations (#805) --- src/utils/common.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/utils/common.ts b/src/utils/common.ts index 58de2b6f..f41ee0aa 100644 --- a/src/utils/common.ts +++ b/src/utils/common.ts @@ -46,6 +46,10 @@ export function isPlainObject(value: any): boolean { } const Ctor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor + + if (Ctor === Object) + return true + return ( typeof Ctor == "function" && Function.toString.call(Ctor) === objectCtorString