UNPKG

@razorpay/blade

Version:

The Design System that powers Razorpay

9 lines (6 loc) 1.71 kB
import _slicedToArray from '@babel/runtime/helpers/slicedToArray'; import isObject from '../lodashButBetter/isObject.js'; import { logger } from '../logger/logger.js'; var isPartialMatchObjectKeys=function isPartialMatchObjectKeys(_ref){var objectToMatch=_ref.objectToMatch,objectToInspect=_ref.objectToInspect;var matchResponses=[];var matchObjectKeys=function matchObjectKeys(_ref2){var innerObjectToMatch=_ref2.innerObjectToMatch,innerObjectToInspect=_ref2.innerObjectToInspect;for(var _ref3 of Object.entries(innerObjectToMatch)){var _ref4=_slicedToArray(_ref3,2);var key=_ref4[0];var valueToMatch=_ref4[1];var valueToInspect=innerObjectToInspect[key];if(innerObjectToInspect.hasOwnProperty(key)){if(valueToMatch===null||valueToMatch===undefined||valueToMatch===''||Array.isArray(valueToMatch)||!(valueToMatch instanceof Object)&&typeof valueToMatch!==typeof valueToInspect){if(__DEV__){logger({message:`Unexpected value: ${JSON.stringify(valueToMatch)} of type ${typeof valueToMatch} for key: ${key}`,moduleName:'isPartialMatchObjectKeys',type:'error'});}matchResponses.push(false);}if(typeof valueToMatch==='string'){matchResponses.push(true);}if(isObject(valueToMatch)&&isObject(valueToInspect)){matchObjectKeys({innerObjectToMatch:valueToMatch,innerObjectToInspect:valueToInspect});}}else {if(__DEV__){logger({message:`${key} doesn't exist in ${JSON.stringify(innerObjectToInspect,null,2)}`,moduleName:'isPartialMatchObjectKeys',type:'error'});}matchResponses.push(false);}}};matchObjectKeys({innerObjectToMatch:objectToMatch,innerObjectToInspect:objectToInspect});return matchResponses.every(Boolean);}; export { isPartialMatchObjectKeys }; //# sourceMappingURL=isPartialMatchObjectKeys.js.map