esnext.map.key-of.js 622 B

123456789101112131415
  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 iterate = require('../internals/iterate');
  6. // `Map.prototype.keyOf` method
  7. // https://github.com/tc39/proposal-collection-methods
  8. $({ target: 'Map', proto: true, real: true, forced: true }, {
  9. keyOf: function keyOf(searchElement) {
  10. return iterate(getMapIterator(anObject(this)), function (key, value, stop) {
  11. if (value === searchElement) return stop(key);
  12. }, { AS_ENTRIES: true, IS_ITERATOR: true, INTERRUPTED: true }).result;
  13. }
  14. });