esnext.map.key-of.js 640 B

12345678910111213141516
  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 getMapIterator = require('../internals/get-map-iterator');
  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: IS_PURE }, {
  10. keyOf: function keyOf(searchElement) {
  11. return iterate(getMapIterator(anObject(this)), function (key, value) {
  12. if (value === searchElement) return iterate.stop(key);
  13. }, undefined, true, true).result;
  14. }
  15. });