Advertisement
Guest User

edgesux

a guest
Apr 26th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. /*!*************************************************!*\
  2. !*** ./node_modules/@wgsn/products/products.js ***!
  3. \*************************************************/
  4. /*! no static exports found */
  5. /***/ (function(module, exports, __webpack_require__) {
  6.  
  7. "use strict";
  8. eval("\n\n// Module dependencies.\nconst lodash = __webpack_require__(/*! lodash */ \"./node_modules/lodash/lodash.js\");\n\n// \"code\" is the historical product name from SS/Constant.php in ci_packages.\nconst products = {\n \"4820\": {\n \"code\": \"INSTOCK\",\n \"name\": \"Instock\",\n \"nicename\": \"instock\",\n \"uri\": \"/instock\"\n },\n \"4821\": {\n \"code\": \"INSIGHT\",\n \"name\": \"Insight\",\n \"nicename\": \"insight\",\n \"uri\": \"/insight\"\n },\n \"4822\": {\n \"code\": \"WGSN\",\n \"name\": \"Fashion\",\n \"nicename\": \"fashion\",\n \"uri\": \"/fashion\"\n },\n \"4823\": {\n \"code\": \"HBL\",\n \"name\": \"Lifestyle & Interiors\",\n \"nicename\": \"li\",\n \"uri\": \"/li\"\n },\n \"4826\": {\n \"code\": \"BRANDTRACKER\",\n \"name\": \"Barometer\",\n \"nicename\": \"barometer\",\n \"uri\": \"https://barometer.wgsn.com\"\n },\n \"4839\": {\n \"code\": \"BEAUTY\",\n \"name\": \"Beauty\",\n \"nicename\": \"beauty\",\n \"uri\": \"/beauty\"\n }\n};\n\n/**\n * Get one product by its ID.\n *\n * @param {number} id - The product ID\n *\n * @return {Object|null} The product data\n */\nconst getById = (id) => {\n if (!products[id]) {\n return null;\n }\n\n return {\n id,\n ...products[id]\n };\n};\n\n/**\n * Get all of the products.\n *\n * @return {Object} The products data\n */\nconst getAll = () => Object.keys(products)\n .map((product) => getById(parseInt(product, 10)));\n\n/**\n * Get one product by its nicename.\n *\n * @param {string} nicename - The product nicename\n *\n * @return {Object|null} The product data\n */\nconst getByNicename = (nicename) => {\n const foundProduct = lodash.find(\n getAll(),\n (product) => product.nicename === nicename\n );\n\n if (!foundProduct) {\n return null;\n }\n\n return getById(foundProduct.id);\n};\n\nmodule.exports = {\n getAll,\n getById,\n getByNicename\n};\n\n\n//# sourceURL=webpack://lib/./node_modules/@wgsn/products/products.js?");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement