MCPcopy
hub / github.com/facebook/react / getAllEnumerableKeys

Function getAllEnumerableKeys

packages/react-devtools-shared/src/utils.js:111–131  ·  view source on GitHub ↗
(
  obj: Object,
)

Source from the content-addressed store, hash-verified

109}
110
111export function getAllEnumerableKeys(
112 obj: Object,
113): Set<string | number | symbol> {
114 const keys = new Set<string | number | symbol>();
115 let current = obj;
116 while (current != null) {
117 const currentKeys = [
118 ...Object.keys(current),
119 ...Object.getOwnPropertySymbols(current),
120 ];
121 const descriptors = Object.getOwnPropertyDescriptors(current);
122 currentKeys.forEach(key => {
123 // $FlowFixMe[incompatible-type]: key can be a Symbol https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor
124 if (descriptors[key].enumerable) {
125 keys.add(key);
126 }
127 });
128 current = Object.getPrototypeOf(current);
129 }
130 return keys;
131}
132
133// Mirror https://github.com/facebook/react/blob/7c21bf72ace77094fd1910cc350a548287ef8350/packages/shared/getComponentName.js#L27-L37
134export function getWrappedDisplayName(

Callers 2

dehydrateFunction · 0.90
formatDataForPreviewFunction · 0.85

Calls 3

keysMethod · 0.80
addMethod · 0.80
forEachMethod · 0.65

Tested by

no test coverage detected