Last change
on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
397 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 | var anObject = require('../internals/an-object');
|
---|
3 |
|
---|
4 | // `Map.prototype.emplace` method
|
---|
5 | // https://github.com/thumbsupep/proposal-upsert
|
---|
6 | module.exports = function emplace(key, handler) {
|
---|
7 | var map = anObject(this);
|
---|
8 | var value = (map.has(key) && 'update' in handler)
|
---|
9 | ? handler.update(map.get(key), key, map)
|
---|
10 | : handler.insert(key, map);
|
---|
11 | map.set(key, value);
|
---|
12 | return value;
|
---|
13 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.