|
Last change
on this file since e4c61dd was e4c61dd, checked in by istevanoska <ilinastevanoska@…>, 6 months ago |
|
Prototype 1.1
|
-
Property mode
set to
100644
|
|
File size:
530 bytes
|
| Line | |
|---|
| 1 | export default function superset(values, other) {
|
|---|
| 2 | const iterator = values[Symbol.iterator](), set = new Set();
|
|---|
| 3 | for (const o of other) {
|
|---|
| 4 | const io = intern(o);
|
|---|
| 5 | if (set.has(io)) continue;
|
|---|
| 6 | let value, done;
|
|---|
| 7 | while (({value, done} = iterator.next())) {
|
|---|
| 8 | if (done) return false;
|
|---|
| 9 | const ivalue = intern(value);
|
|---|
| 10 | set.add(ivalue);
|
|---|
| 11 | if (Object.is(io, ivalue)) break;
|
|---|
| 12 | }
|
|---|
| 13 | }
|
|---|
| 14 | return true;
|
|---|
| 15 | }
|
|---|
| 16 |
|
|---|
| 17 | function intern(value) {
|
|---|
| 18 | return value !== null && typeof value === "object" ? value.valueOf() : value;
|
|---|
| 19 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.