Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@backpackjs/transform-product-feed

Package Overview
Dependencies
Maintainers
27
Versions
127
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@backpackjs/transform-product-feed - npm Package Compare versions

Comparing version 4.27.11-next.42 to 4.27.11

dist/index.test.d.ts

5

dist/index.d.ts

@@ -0,3 +1,8 @@

export function getProducts({ products, collections, options }: {
products: any;
collections: any;
options: any;
}): any;
declare function _default(input: any): Promise<any>;
export default _default;
//# sourceMappingURL=index.d.ts.map

29

dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getProducts = void 0;
const tslib_1 = require("tslib");

@@ -18,18 +19,20 @@ /* eslint-disable camelcase */

const filterDraft = (product) => product.status.toLowerCase() !== 'draft';
const getProduct = (products) => (handle) => {
return products.find((product) => product.handle === handle);
};
const getProducts = ({ products, collections, options }) => {
const optionCollection = options.collectionHandle;
const productByHandle = getProduct(products);
const byOptionsCollection = ({ handle }) => handle === optionCollection;
const collection = collections.find(byOptionsCollection);
const feedCollectionProducts = collection?.products
.map((product) => product.handle)
.map(productByHandle);
if (!feedCollectionProducts) {
const collection = collections.find((c) => options.collectionHandle === c.handle);
if (!collection || collection.products.length < 1) {
return products;
}
return feedCollectionProducts;
const productMapByHandle = new Map();
products.forEach((product) => {
productMapByHandle.set(product.handle, product);
});
const collectionProducts = [];
collection.products.forEach((product) => {
if (productMapByHandle.has(product.handle)) {
collectionProducts.push(productMapByHandle.get(product.handle));
}
});
return collectionProducts;
};
exports.getProducts = getProducts;
const getFeedItems = (product) => {

@@ -84,3 +87,3 @@ return product.variants.map((variant) => {

const { products, collections, context, options, log } = input;
const feedItems = getProducts({ products, collections, options })
const feedItems = (0, exports.getProducts)({ products, collections, options })
.filter(filterDraft)

@@ -87,0 +90,0 @@ .flatMap(getFeedItems);

{
"name": "@backpackjs/transform-product-feed",
"version": "4.27.11-next.42+4b2dc28e",
"version": "4.27.11",
"license": "MIT",

@@ -25,3 +25,3 @@ "author": "BackpackJS <dev@packdigial.com> (http://packdigital.com/)",

},
"gitHead": "4b2dc28ea9649ea00f0e795d3e0ac425200cd9dc"
"gitHead": "e062af030c5596da0686ca519c04baacb78529aa"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc