Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export maps (objects) in addition to arrays #104

Open
Gideonnn opened this issue Mar 25, 2024 · 0 comments
Open

Export maps (objects) in addition to arrays #104

Gideonnn opened this issue Mar 25, 2024 · 0 comments

Comments

@Gideonnn
Copy link
Contributor

Currently products and productTypes are exported as arrays, but they are used more often as maps. To prevent every consumer of the sdk having to reduce the products into an object, they should be exported as a map too.

// This can probably be made more type safe (e.g. product id's `as const`)
export const productsMap = generatedProducts.reduce((map, product: any) => {
  map[product.id] = product;
  return map;
}, {} as Record<string, any>);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant