* 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)
| 414 | * @returns {?string} The actual key name if found, otherwise null. |
| 415 | */ |
| 416 | function 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 | |
| 434 | const _global = (() => { |
| 435 | /*eslint no-undef:0*/ |
no test coverage detected