UNPKG

@shopify/hydrogen-react

Version:

React components, hooks, and utilities for creating custom Shopify storefronts

30 lines (29 loc) 909 B
"use strict"; Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } }); function flattenConnection(connection) { if (!connection) { const noConnectionErr = `flattenConnection(): needs a 'connection' to flatten, but received '${connection}' instead`; { throw new Error(noConnectionErr); } } if (connection.nodes) { return connection.nodes; } if (connection.edges) { return connection.edges.map((edge) => { if (!(edge == null ? void 0 : edge.node)) { throw new Error("Connection edges must contain nodes"); } return edge.node; }); } { console.warn( `The connection did not contain either "nodes" or "edges.node". A empty array will be returned in its place.` ); } return []; } exports.flattenConnection = flattenConnection; //# sourceMappingURL=flatten-connection.js.map