2 var anObject = require('../internals/an-object');
4 // `Map.prototype.upsert` method
5 // https://github.com/thumbsupep/proposal-upsert
6 module.exports = function upsert(key, updateFn /* , insertFn */) {
7 var map = anObject(this);
8 var insertFn = arguments.length > 2 ? arguments[2] : undefined;
10 if (typeof updateFn != 'function' && typeof insertFn != 'function') {
11 throw TypeError('At least one callback required');
15 if (typeof updateFn == 'function') {
16 value = updateFn(value);
19 } else if (typeof insertFn == 'function') {