MCPcopy Create free account
hub / github.com/Snapchat/Valdi / getCaseInsensitiveProperty

Function getCaseInsensitiveProperty

valdi/vscode_debugger/src/common/objUtils.ts:166–182  ·  view source on GitHub ↗
(
  obj: { [key: string]: R },
  prop: string,
)

Source from the content-addressed store, hash-verified

164 * Does a case-insensitive lookup on the given object.
165 */
166export function getCaseInsensitiveProperty<R>(
167 obj: { [key: string]: R },
168 prop: string,
169): R | undefined {
170 if (obj.hasOwnProperty(prop)) {
171 return obj[prop]; // fast path
172 }
173
174 const normalized = prop.toLowerCase();
175 for (const key of Object.keys(obj)) {
176 if (key.toLowerCase() === normalized) {
177 return obj[key];
178 }
179 }
180
181 return undefined;
182}
183
184const unset = Symbol('unset');
185

Callers 1

lookupMethod · 0.90

Calls 1

keysMethod · 0.65

Tested by

no test coverage detected