esnext.set.is-subset-of.js 1006 B

12345678910111213141516171819202122232425
  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. // `Set.prototype.isSubsetOf` method
  10. // https://tc39.github.io/proposal-set-methods/#Set.prototype.isSubsetOf
  11. $({ target: 'Set', proto: true, real: true, forced: IS_PURE }, {
  12. isSubsetOf: function isSubsetOf(iterable) {
  13. var iterator = getIterator(this);
  14. var otherSet = anObject(iterable);
  15. var hasCheck = otherSet.has;
  16. if (typeof hasCheck != 'function') {
  17. otherSet = new (getBuiltIn('Set'))(iterable);
  18. hasCheck = aFunction(otherSet.has);
  19. }
  20. return !iterate(iterator, function (value) {
  21. if (hasCheck.call(otherSet, value) === false) return iterate.stop();
  22. }, undefined, false, true).stopped;
  23. }
  24. });