esnext.map.includes.js 702 B

12345678910111213141516
  1. 'use strict';
  2. var $ = require('../internals/export');
  3. var anObject = require('../internals/an-object');
  4. var getMapIterator = require('../internals/get-map-iterator');
  5. var sameValueZero = require('../internals/same-value-zero');
  6. var iterate = require('../internals/iterate');
  7. // `Map.prototype.includes` method
  8. // https://github.com/tc39/proposal-collection-methods
  9. $({ target: 'Map', proto: true, real: true, forced: true }, {
  10. includes: function includes(searchElement) {
  11. return iterate(getMapIterator(anObject(this)), function (key, value, stop) {
  12. if (sameValueZero(value, searchElement)) return stop();
  13. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).stopped;
  14. }
  15. });