UNPKG

704 BJavaScriptView Raw
1'use strict';
2var $ = require('../internals/export');
3var bind = require('../internals/function-bind-context');
4var aMap = require('../internals/a-map');
5var iterate = require('../internals/map-iterate');
6
7// `Map.prototype.findKey` method
8// https://github.com/tc39/proposal-collection-methods
9$({ target: 'Map', proto: true, real: true, forced: true }, {
10 findKey: function findKey(callbackfn /* , thisArg */) {
11 var map = aMap(this);
12 var boundFunction = bind(callbackfn, arguments.length > 1 ? arguments[1] : undefined);
13 var result = iterate(map, function (value, key) {
14 if (boundFunction(value, key, map)) return { key: key };
15 }, true);
16 return result && result.key;
17 }
18});