MCPcopy
hub / github.com/axios/axios / findKey

Function findKey

lib/utils.js:416–432  ·  view source on GitHub ↗

* Finds a key in an object, case-insensitive, returning the actual key name. * Returns null if the object is a Buffer or if no match is found. * * @param {Object} obj - The object to search. * @param {string} key - The key to find (case-insensitive). * @returns {?string} The actual key name if

(obj, key)

Source from the content-addressed store, hash-verified

414 * @returns {?string} The actual key name if found, otherwise null.
415 */
416function findKey(obj, key) {
417 if (isBuffer(obj)) {
418 return null;
419 }
420
421 key = key.toLowerCase();
422 const keys = Object.keys(obj);
423 let i = keys.length;
424 let _key;
425 while (i-- > 0) {
426 _key = keys[i];
427 if (key === _key.toLowerCase()) {
428 return _key;
429 }
430 }
431 return null;
432}
433
434const _global = (() => {
435 /*eslint no-undef:0*/

Callers 1

assignValueFunction · 0.85

Calls 1

isBufferFunction · 0.85

Tested by

no test coverage detected