The method produces array intersection by keys, the same as array_intersect_key PHP function.
It can be simplified to the single line:
return _.pick(availableTypes, _.intersection(_.keys(availableTypes), _.keys(countrySpecificCardTypes)));
The method produces array intersection by keys, the same as array_intersect_key PHP function.
It can be simplified to the single line:
return _.pick(availableTypes, _.intersection(_.keys(availableTypes), _.keys(countrySpecificCardTypes)));
See also:
collectTypes() method from the Magento_Braintree's cc-form.js can be simplified from 8 lines to 1\Magento\Payment\Model\CcGenericConfigProvider::getCcAvailableTypes() can be simplifiedcollectTypes() method is duplicated in the Magento_Braintree's cc-form.js and Magento_BraintreeTwo's validator.js