-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
implementation.js
49 lines (37 loc) · 1.47 KB
/
implementation.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'use strict';
var $TypeError = require('es-errors/type');
var $Set = require('es-set/polyfill')();
var GetIteratorFromMethod = require('es-abstract/2024/GetIteratorFromMethod');
var GetSetRecord = require('./aos/GetSetRecord');
var IteratorClose = require('es-abstract/2024/IteratorClose');
var IteratorStepValue = require('es-abstract/2024/IteratorStepValue');
var NormalCompletion = require('es-abstract/2024/NormalCompletion');
var isSet = require('is-set');
var tools = require('es-set/tools');
var $setHas = tools.has;
var $setSize = tools.size;
module.exports = function isSupersetOf(other) {
var O = this; // step 1
// RequireInternalSlot(O, [[SetData]]); // step 2
if (!isSet(O) && !(O instanceof $Set)) {
throw new $TypeError('Method Set.prototype.isSupersetOf called on incompatible receiver ' + O);
}
var otherRec = GetSetRecord(other); // step 3
var thisSize = $setSize(O); // SetDataSize(O.[[SetData]]) // step 4
if (thisSize < otherRec['[[Size]]']) {
return false; // step 5
}
var keysIter = GetIteratorFromMethod(otherRec['[[SetObject]]'], otherRec['[[Keys]]']); // step 6
var next = true; // step 7
while (!keysIter['[[Done]]']) { // step 8
next = IteratorStepValue(keysIter); // step 8.a
if (!keysIter['[[Done]]']) { // step 8.b
// if (!SetDataHas(O.[[SetData]], next)) { // step 8.b.i
if (!$setHas(O, next)) {
IteratorClose(keysIter, NormalCompletion()); // step 8.b.i.1
return false; // step 8.b.ii.2
}
}
}
return true; // step 9
};