Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // generators are lazy so maxItems isn't needed anymore - you just take as many items as you need
- // 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`
- const uniqueMergeWithoutMax = function *(arrays, withoutValue) {
- const seen = new Set();
- for(const array of arrays) {
- for(const item of array) {
- if (item === withoutValue || seen.has(item)) continue;
- seen.add(item);
- yield item;
- }
- }
- };
Add Comment
Please, Sign In to add comment