MCPcopy Create free account
hub / github.com/Effect-TS/effect / getAllObjectKeys

Function getAllObjectKeys

packages/effect/src/internal/equal.ts:2–25  ·  view source on GitHub ↗
(obj: object)

Source from the content-addressed store, hash-verified

1/** @internal */
2export 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 */
28export const byReferenceInstances = new WeakSet<object>()

Callers 2

compareRecordsFunction · 0.90
structureFunction · 0.90

Calls 2

addMethod · 0.65
hasMethod · 0.45

Tested by

no test coverage detected