esnext.iterator.every.js 533 B

12345678910111213141516
  1. 'use strict';
  2. // https://github.com/tc39/proposal-iterator-helpers
  3. var $ = require('../internals/export');
  4. var iterate = require('../internals/iterate');
  5. var aFunction = require('../internals/a-function');
  6. var anObject = require('../internals/an-object');
  7. $({ target: 'Iterator', proto: true, real: true }, {
  8. every: function every(fn) {
  9. anObject(this);
  10. aFunction(fn);
  11. return !iterate(this, function (value, stop) {
  12. if (!fn(value)) return stop();
  13. }, { IS_ITERATOR: true, INTERRUPTED: true }).stopped;
  14. }
  15. });