Skip to content

Commit

Permalink
fix: isPlainObject: add quick comparison between input and Object t…
Browse files Browse the repository at this point in the history
…o short-circuit taxing `Function.toString` invocations (#805)
  • Loading branch information
benelliott authored Jun 9, 2021
1 parent 5cb208b commit 07575f3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 07575f3

Please sign in to comment.