UNPKG

776 BJavaScriptView Raw
1'use strict';
2var aSet = require('../internals/a-set');
3var has = require('../internals/set-helpers').has;
4var size = require('../internals/set-size');
5var getSetRecord = require('../internals/get-set-record');
6var iterateSimple = require('../internals/iterate-simple');
7var iteratorClose = require('../internals/iterator-close');
8
9// `Set.prototype.isSupersetOf` method
10// https://tc39.github.io/proposal-set-methods/#Set.prototype.isSupersetOf
11module.exports = function isSupersetOf(other) {
12 var O = aSet(this);
13 var otherRec = getSetRecord(other);
14 if (size(O) < otherRec.size) return false;
15 var iterator = otherRec.getIterator();
16 return iterateSimple(iterator, function (e) {
17 if (!has(O, e)) return iteratorClose(iterator, 'normal', false);
18 }) !== false;
19};