Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const tagsReducer = (tags, name) => {
- const taggedAlready = tags.find(t => t.name === name);
- const incrementIfFound = t =>
- t === taggedAlready
- ? Object.assign(t, {count: t.count + 1})
- : t;
- return [
- ...tags.map(incrementIfFound),
- ...(taggedAlready ? [] : [{name, count: 1}]),
- ];
- };
- const reduce = (f, init) => as => as.reduce(f, init);
- const flatten = (a, b) => [...a, ...b];
- const allTags =
- compose(
- reduce(tagsReducer, []),
- reduce(flatten, []),
- map(option([])),
- map(prop('tags')),
- option([]),
- prop('clips')
- );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement