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:
571 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 | var $ = require('../internals/export');
|
---|
3 | var aWeakMap = require('../internals/a-weak-map');
|
---|
4 | var WeakMapHelpers = require('../internals/weak-map-helpers');
|
---|
5 |
|
---|
6 | var get = WeakMapHelpers.get;
|
---|
7 | var has = WeakMapHelpers.has;
|
---|
8 | var set = WeakMapHelpers.set;
|
---|
9 |
|
---|
10 | // `WeakMap.prototype.getOrInsert` method
|
---|
11 | // https://github.com/tc39/proposal-upsert
|
---|
12 | $({ target: 'WeakMap', proto: true, real: true, forced: true }, {
|
---|
13 | getOrInsert: function getOrInsert(key, value) {
|
---|
14 | if (has(aWeakMap(this), key)) return get(this, key);
|
---|
15 | set(this, key, value);
|
---|
16 | return value;
|
---|
17 | }
|
---|
18 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.