UNPKG

escalade-price-store

Version:

An event-based store system for getting Escalade Sports pricing. Stores all fetched prices in a cookie for quick retrieval.

51 lines (43 loc) 1.17 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _extends2 = require('babel-runtime/helpers/extends'); var _extends3 = _interopRequireDefault(_extends2); var _usdFormatter = require('usd-formatter'); var _usdFormatter2 = _interopRequireDefault(_usdFormatter); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function formatPrice(price) { if (price === 'undefined') { return 'undefined'; } return (0, _usdFormatter2.default)(price); } exports.default = { getPrice: function getPrice(id) { id = id.toLowerCase(); if (id in this.store) { return this.store[id]; } }, getPrices: function getPrices() { return (0, _extends3.default)({}, this.store); }, getFormattedPrice: function getFormattedPrice(id) { var price = this.getPrice(id); if (price) { return formatPrice(price); } }, getFormattedPrices: function getFormattedPrices() { var prices = {}; for (var i in this.store) { if (this.store[i]) { prices[i] = formatPrice(this.store[i]); } } return prices; } }; module.exports = exports['default']; //# sourceMappingURL=getters.js.map