rsnext/packages/next/shared/lib/is-plain-object.ts
Pieter Bogaerts 662fa6362a
fix: fixes #33314 move is-plain-object for es5 compilation (#33690)
## Bug

- [ ] Related issues linked using `fixes #33314` #33314
- [ ] Moved the `is-plain-object` file to the shared directory since it's emitted to the client and thus needs to be transpiled.

This is just my 2nd PR so if I'm missing something please let me know.
2022-01-27 17:59:42 +00: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
}