esnext.map.every.js 857 B

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