rsnext/packages/next/lib/is-plain-object.ts
JJ Kasper 57a87050e7
Add util for normalizing errors (#33159)
* JSON.stringify generic errors

* Add util for normalizing errors

* lint-fix

* Add better error for null case as well

Co-authored-by: Michael Ozeryansky <mozeryansky@users.noreply.github.com>
2022-01-11 14:40:03 -06:00

12 lines
354 B
TypeScript

export function getObjectClassLabel(value: any): string {
return Object.prototype.toString.call(value)
}
export function isPlainObject(value: any): boolean {
if (getObjectClassLabel(value) !== '[object Object]') {
return false
}
const prototype = Object.getPrototypeOf(value)
return prototype === null || prototype === Object.prototype
}