|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
811 bytes
|
| Line | |
|---|
| 1 | 'use strict';
|
|---|
| 2 | var $ = require('../internals/export');
|
|---|
| 3 | var aCallable = require('../internals/a-callable');
|
|---|
| 4 | var MapHelpers = require('../internals/map-helpers');
|
|---|
| 5 | var IS_PURE = require('../internals/is-pure');
|
|---|
| 6 |
|
|---|
| 7 | var get = MapHelpers.get;
|
|---|
| 8 | var has = MapHelpers.has;
|
|---|
| 9 | var set = MapHelpers.set;
|
|---|
| 10 |
|
|---|
| 11 | // `Map.prototype.getOrInsertComputed` method
|
|---|
| 12 | // https://tc39.es/ecma262/#sec-map.prototype.getorinsertcomputed
|
|---|
| 13 | $({ target: 'Map', proto: true, real: true, forced: IS_PURE }, {
|
|---|
| 14 | getOrInsertComputed: function getOrInsertComputed(key, callbackfn) {
|
|---|
| 15 | var hasKey = has(this, key);
|
|---|
| 16 | aCallable(callbackfn);
|
|---|
| 17 | if (hasKey) return get(this, key);
|
|---|
| 18 | // CanonicalizeKeyedCollectionKey
|
|---|
| 19 | if (key === 0 && 1 / key === -Infinity) key = 0;
|
|---|
| 20 | var value = callbackfn(key);
|
|---|
| 21 | set(this, key, value);
|
|---|
| 22 | return value;
|
|---|
| 23 | }
|
|---|
| 24 | });
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.