Suite of AT Protocol TypeScript libraries built on web standards
1const ObjectProto = Object.prototype;
2const ObjectToString = Object.prototype.toString;
3
4export function isObject(input: unknown): input is object {
5 return input != null && typeof input === "object";
6}
7
8export function isPlainObject(
9 input: unknown,
10): input is object & Record<string, unknown> {
11 if (!input || typeof input !== "object") return false;
12 const proto = Object.getPrototypeOf(input);
13 if (proto === null) return true;
14 return (
15 (proto === ObjectProto ||
16 Object.getPrototypeOf(proto) === null) &&
17 ObjectToString.call(input) === "[object Object]"
18 );
19}