Last active
August 29, 2015 14:16
-
-
Save aaronshaf/560fc9168ca72d1059a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Confused? See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Array_comprehensions | |
| function flatten(previous, current) { | |
| return previous.concat(current) | |
| } | |
| var productImages = [ | |
| for(section of CatalogSections) [ | |
| for(placement of section.ProductPlacements) [ | |
| for(item of placement.ProductPlacementItems) [ | |
| for(image of item.Product.ProductImages) { | |
| manufacturerName: item.Product && item.Product.Manufacturer ? | |
| item.Product.Manufacturer.name : null, | |
| distributorPartNumber: item.distributor_part_number, | |
| manufacturerPartNumber: item.manufacturer_part_number, | |
| imageName: image.name | |
| } | |
| ].reduce(flatten, []).filter((product) => product.imageName) | |
| ].reduce(flatten, []) | |
| ].reduce(flatten, []) | |
| ].reduce(flatten, []) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment