esnext.set.every.js 818 B

12345678910111213141516171819
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var anObject = require('../internals/an-object');
  4. var bind = require('../internals/function-bind-context');
  5. var getSetIterator = require('../internals/get-set-iterator');
  6. var iterate = require('../internals/iterate');
  7. // `Set.prototype.every` method
  8. // https://github.com/tc39/proposal-collection-methods
  9. $({ target: 'Set', proto: true, real: true, forced: true }, {
  10. every: function every(callbackfn /* , thisArg */) {
  11. var set = anObject(this);
  12. var iterator = getSetIterator(set);
  13. var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
  14. return !iterate(iterator, function (value, stop) {
  15. if (!boundFunction(value, value, set)) return stop();
  16. }, { IS_ITERATOR: true, INTERRUPTED: true }).stopped;
  17. }
  18. });