@shopgate/engage
Version:
Shopgate's ENGAGE library.
7 lines • 877 B
JavaScript
function _extends(){_extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key];}}}return target;};return _extends.apply(this,arguments);}import iso3166 from"./iso-3166-2";/**
* Returns a list of provinces based on the given country id
*
* @param {string} countryCode Country code of the country to fetch provinces from
* @param {?Object} optional object to prepend optional choice
* @return {Object}
*/export default(function(countryCode){var optional=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;if(!iso3166){return{};}/** @property {iso3166} divisions */var provinceList=iso3166[countryCode]?iso3166[countryCode].divisions:{};if(!optional){return provinceList;}return _extends({},optional,{},provinceList);});