main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
771 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 | var $ = require('../internals/export');
|
---|
3 | var aCallable = require('../internals/a-callable');
|
---|
4 | var aMap = require('../internals/a-map');
|
---|
5 | var MapHelpers = require('../internals/map-helpers');
|
---|
6 |
|
---|
7 | var get = MapHelpers.get;
|
---|
8 | var has = MapHelpers.has;
|
---|
9 | var set = MapHelpers.set;
|
---|
10 |
|
---|
11 | // `Map.prototype.getOrInsertComputed` method
|
---|
12 | // https://github.com/tc39/proposal-upsert
|
---|
13 | $({ target: 'Map', proto: true, real: true, forced: true }, {
|
---|
14 | getOrInsertComputed: function getOrInsertComputed(key, callbackfn) {
|
---|
15 | aMap(this);
|
---|
16 | aCallable(callbackfn);
|
---|
17 | if (has(this, key)) 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.