Guest User

Untitled

a guest
Jun 25th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. // generators are lazy so maxItems isn't needed anymore - you just take as many items as you need
  2. // it's also lazy, so if you need less items you will pay less for it. Naming a Set `set` is like naming a Number `number`
  3. const uniqueMergeWithoutMax = function *(arrays, withoutValue) {
  4. const seen = new Set();
  5. for(const array of arrays) {
  6. for(const item of array) {
  7. if (item === withoutValue || seen.has(item)) continue;
  8. seen.add(item);
  9. yield item;
  10. }
  11. }
  12. };
Add Comment
Please, Sign In to add comment