( data: data )
| 201 | > |
| 202 | |
| 203 | export const objectKindOf = <data extends object>( |
| 204 | data: data |
| 205 | ): objectKindOf<data> | undefined => { |
| 206 | // Realm-safe: cross-window/vm arrays fail `instanceof Array` but pass |
| 207 | // Array.isArray (https://github.com/arktypeio/arktype/issues/1597). |
| 208 | if (Array.isArray(data)) return "Array" as never |
| 209 | |
| 210 | let prototype: Partial<Object> | null = prototypeOf(data) |
| 211 | if (prototype === Object.prototype) return undefined |
| 212 | const constructors = builtinsOf() |
| 213 | while ( |
| 214 | prototype?.constructor && |
| 215 | (!hasOwn(constructors, prototype.constructor.name) || |
| 216 | constructors[prototype.constructor.name as BuiltinObjectKind] |
| 217 | ?.prototype !== prototype) |
| 218 | ) |
| 219 | prototype = Object.getPrototypeOf(prototype) |
| 220 | |
| 221 | const name = prototype?.constructor?.name |
| 222 | if (name === undefined || name === "Object") return undefined |
| 223 | |
| 224 | return name as never |
| 225 | } |
| 226 | |
| 227 | export const objectKindOrDomainOf = <data>( |
| 228 | data: data |
no test coverage detected