@shopgate/pwa-common-commerce
Version:
Commerce library for the Shopgate Connect PWA.
22 lines • 1.97 kB
JavaScript
function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function");}}function _defineProperties(target,props){for(var i=0;i<props.length;i++){var descriptor=props[i];descriptor.enumerable=descriptor.enumerable||false;descriptor.configurable=true;if("value"in descriptor)descriptor.writable=true;Object.defineProperty(target,descriptor.key,descriptor);}}function _createClass(Constructor,protoProps,staticProps){if(protoProps)_defineProperties(Constructor.prototype,protoProps);if(staticProps)_defineProperties(Constructor,staticProps);return Constructor;}/**
* Class to maintain the image formats
* @deprecated not used anymore. Kept for backwards compatibility.
*/var ProductImageFormats=/*#__PURE__*/function(){/**
* Constructor.
*/function ProductImageFormats(){_classCallCheck(this,ProductImageFormats);this.formats=[];this.map=new Map();}/**
* Returns all formats.
* @returns {Array}
*/return _createClass(ProductImageFormats,[{key:"getAllUniqueFormats",value:function getAllUniqueFormats(){var hashes=[];return Array.from(this.map.values()).reduce(function(prev,val){return[].concat(prev,val);},[]).filter(function(val){var hash=JSON.stringify(val);if(hashes.indexOf(hash)===-1){hashes.push(hash);return true;}return false;});}/**
* @param {string} key key of format to get
* @returns {Object} format
*/},{key:"get",value:function get(key){return this.map.get(key);}/**
* @param {string} key key of format
* @param {Object} value value of format
* @returns {Object}
*/},{key:"set",value:function set(key,value){return this.map.set(key,value);}/**
* Removes a format from the list of persisted formats.
* @param {string} key The key of the format to remove.
* @returns {ProductImageFormats}
*/},{key:"remove",value:function remove(key){this.map.remove(key);return this;}}]);}();/**
* @deprecated
*/export default new ProductImageFormats();