Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 26x 6x 20x 20x | /**
* Checks whether a value is a plain object: an object literal or `Object.create(null)`. Arrays, class
* instances, dates and maps are excluded.
*
* @param value - The value to check.
* @returns `true` for a plain object.
* @example
* isRecord({ a: 1 }); // true
* isRecord([]); // false
* isRecord(new Date()); // false
*/
export function isRecord(value: unknown): value is Record<string, unknown> {
if (typeof value !== 'object' || value === null) {
return false;
}
const prototype: unknown = Object.getPrototypeOf(value);
return prototype === Object.prototype || prototype === null;
}
|