UNPKG

@mikezimm/npmfunctions

Version:
46 lines 1.68 kB
"use strict"; /** * findPropFromSimilarKey * @param obj * @param anyKeyCase * @param test contains means the obj.key is contained in the checkKey - * Original use case: Look to see if the current web Url is contained in DefaultBannerThemes * checkKey (aka findKey = full url: /sites/sitecollection/subsite/etc ) * Object.key ( /sites/sitecollection/ ) * Contains will find this Object.key in the checkKey string and return the value. * @param checkKey * @param defValue * @returns */ Object.defineProperty(exports, "__esModule", { value: true }); exports.findPropFromSimilarKey = void 0; function findPropFromSimilarKey(obj, anyKeyCase, checkKey, test, defValue) { var result = defValue; if (typeof obj !== 'object') { return result; } else { var findKey_1 = anyKeyCase === true ? checkKey.toLowerCase() : checkKey; Object.keys(obj).map(function (key) { var objKey = anyKeyCase === true ? key.toLowerCase() : key; if (test === 'eq') { if (findKey_1 === objKey) { result = obj[key]; } } else if (test === 'containsObjKey') { if (findKey_1.indexOf(objKey) > -1) { result = obj[key]; } } else if (test === 'isContainedInObjKey') { if (objKey.indexOf(findKey_1) > -1) { result = obj[key]; } } }); } return result; } exports.findPropFromSimilarKey = findPropFromSimilarKey; //# sourceMappingURL=functions.js.map