UNPKG

@shopgate/pwa-common-commerce

Version:

Commerce library for the Shopgate Connect PWA.

63 lines (59 loc) 1.51 kB
import "core-js/modules/es.array.reduce.js"; /** * Class to maintain the image formats * @deprecated not used anymore. Kept for backwards compatibility. */ let ProductImageFormats = /*#__PURE__*/function () { /** * Constructor. */ function ProductImageFormats() { this.formats = []; this.map = new Map(); } /** * Returns all formats. * @returns {Array} */ var _proto = ProductImageFormats.prototype; _proto.getAllUniqueFormats = function getAllUniqueFormats() { const hashes = []; return Array.from(this.map.values()).reduce((prev, val) => [].concat(prev, val), []).filter(val => { const 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 */; _proto.get = function get(key) { return this.map.get(key); } /** * @param {string} key key of format * @param {Object} value value of format * @returns {Object} */; _proto.set = 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} */; _proto.remove = function remove(key) { this.map.remove(key); return this; }; return ProductImageFormats; }(); /** * @deprecated */ export default new ProductImageFormats();