Spaces:
Sleeping
Sleeping
File size: 466 Bytes
90cbf22 |
1 2 3 4 5 6 7 8 9 10 11 12 |
export function isSimpleObject(value: unknown) {
const isObject = typeof value === 'object';
const prototype = Object.getPrototypeOf(value);
const isSimple =
prototype === null ||
prototype === Object.prototype ||
// Objects generated from other contexts (e.g. across Node.js `vm` modules) will not satisfy the previous
// conditions but are still simple objects.
prototype?.constructor?.name === 'Object';
return isObject && isSimple;
}
|