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

Function getAllObjectKeys

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

Source from the content-addressed store, hash-verified

13
14/** @internal */
15export const getAllObjectKeys = (obj: object): Array<PropertyKey> | Set<PropertyKey> => {
16 const own = ownKeys(obj)
17 const proto = Object.getPrototypeOf(obj)
18 if (proto === Object.prototype || proto === null) return own
19 const keys = new Set<PropertyKey>(own)
20
21 if (obj instanceof Error) {
22 keys.delete("stack")
23 for (const key of errorSiteKeys) {
24 if (!Object.prototype.propertyIsEnumerable.call(obj, key)) keys.delete(key)
25 }
26 }
27
28 let current = proto
29 while (current !== null && current !== Object.prototype) {
30 for (const key of ownKeys(current)) keys.add(key)
31 current = Object.getPrototypeOf(current)
32 }
33 if (typeof obj.constructor === "function" && proto === obj.constructor.prototype) {
34 keys.delete("constructor")
35 }
36
37 return keys
38}
39
40/** @internal */
41export const byReferenceInstances = new WeakSet<object>()

Callers 2

compareRecordsFunction · 0.90
structureFunction · 0.90

Calls 4

ownKeysFunction · 0.70
deleteMethod · 0.65
addMethod · 0.65
callMethod · 0.45

Tested by

no test coverage detected