(obj: object)
| 1 | /** @internal */ |
| 2 | export const getAllObjectKeys = (obj: object): Set<PropertyKey> => { |
| 3 | const keys = new Set<PropertyKey>(Reflect.ownKeys(obj)) |
| 4 | if (obj.constructor === Object) return keys |
| 5 | |
| 6 | if (obj instanceof Error) { |
| 7 | keys.delete("stack") |
| 8 | } |
| 9 | |
| 10 | const proto = Object.getPrototypeOf(obj) |
| 11 | let current = proto |
| 12 | |
| 13 | while (current !== null && current !== Object.prototype) { |
| 14 | const ownKeys = Reflect.ownKeys(current) |
| 15 | for (let i = 0; i < ownKeys.length; i++) { |
| 16 | keys.add(ownKeys[i]) |
| 17 | } |
| 18 | current = Object.getPrototypeOf(current) |
| 19 | } |
| 20 | if (keys.has("constructor") && typeof obj.constructor === "function" && proto === obj.constructor.prototype) { |
| 21 | keys.delete("constructor") |
| 22 | } |
| 23 | |
| 24 | return keys |
| 25 | } |
| 26 | |
| 27 | /** @internal */ |
| 28 | export const byReferenceInstances = new WeakSet<object>() |
no test coverage detected