@shopify/hydrogen-react
Version:
React components, hooks, and utilities for creating custom Shopify storefronts
26 lines (25 loc) • 637 B
JavaScript
function flattenConnection(connection) {
if (!connection) {
const noConnectionErr = `flattenConnection(): needs a 'connection' to flatten, but received '${connection}' instead`;
{
console.error(noConnectionErr);
return [];
}
}
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;
});
}
return [];
}
export {
flattenConnection
};
//# sourceMappingURL=flatten-connection.mjs.map