Skip to content

Instantly share code, notes, and snippets.

@nagyadam2092
Last active December 7, 2020 15:57
Show Gist options
  • Save nagyadam2092/69edb762d427e54d0dc41110f68854a0 to your computer and use it in GitHub Desktop.
Save nagyadam2092/69edb762d427e54d0dc41110f68854a0 to your computer and use it in GitHub Desktop.
const movieLists = [
// ...
];
const boxartSizeRestrictions = boxart =>
boxart.width === 150 && boxart.height === 200;
const videoBoxartMapper = (boxart, video) => ({
id: video.id,
title: video.title,
boxart: boxart.url
});
const videosIterator = video =>
video.boxarts
.filter(boxartSizeRestrictions)
.map(boxart => videoBoxartMapper(boxart, video));
const movieListIterator = movieList => movieList.videos.flatMap(videosIterator);
const result = movieLists.flatMap(movieListIterator);
console.log(result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment