1 | 'use strict';
|
---|
2 | var $ = require('../internals/export');
|
---|
3 | var IS_PURE = require('../internals/is-pure');
|
---|
4 | var getBuiltIn = require('../internals/get-built-in');
|
---|
5 | var anObject = require('../internals/an-object');
|
---|
6 | var aFunction = require('../internals/a-function');
|
---|
7 | var getIterator = require('../internals/get-iterator');
|
---|
8 | var iterate = require('../internals/iterate');
|
---|
9 |
|
---|
10 | // `Set.prototype.isSubsetOf` method
|
---|
11 | // https://tc39.github.io/proposal-set-methods/#Set.prototype.isSubsetOf
|
---|
12 | $({ target: 'Set', proto: true, real: true, forced: IS_PURE }, {
|
---|
13 | isSubsetOf: function isSubsetOf(iterable) {
|
---|
14 | var iterator = getIterator(this);
|
---|
15 | var otherSet = anObject(iterable);
|
---|
16 | var hasCheck = otherSet.has;
|
---|
17 | if (typeof hasCheck != 'function') {
|
---|
18 | otherSet = new (getBuiltIn('Set'))(iterable);
|
---|
19 | hasCheck = aFunction(otherSet.has);
|
---|
20 | }
|
---|
21 | return !iterate(iterator, function (value, stop) {
|
---|
22 | if (hasCheck.call(otherSet, value) === false) return stop();
|
---|
23 | }, { IS_ITERATOR: true, INTERRUPTED: true }).stopped;
|
---|
24 | }
|
---|
25 | });
|
---|