18 lines
444 B
JavaScript
18 lines
444 B
JavaScript
|
var ignoredChar = /[\s_\-\/\(\)]/g;
|
||
|
export default function match(obj, key) {
|
||
|
if (obj[key]) {
|
||
|
return obj[key];
|
||
|
}
|
||
|
var keys = Object.keys(obj);
|
||
|
var lkey = key.toLowerCase().replace(ignoredChar, '');
|
||
|
var i = -1;
|
||
|
var testkey, processedKey;
|
||
|
while (++i < keys.length) {
|
||
|
testkey = keys[i];
|
||
|
processedKey = testkey.toLowerCase().replace(ignoredChar, '');
|
||
|
if (processedKey === lkey) {
|
||
|
return obj[testkey];
|
||
|
}
|
||
|
}
|
||
|
}
|