Sha256: ce053497d2d23d99b3a2e6cf94f87c6ad478c110081c47784597bae0ffcf703f
Contents?: true
Size: 799 Bytes
Versions: 4
Compression:
Stored size: 799 Bytes
Contents
'use strict'; var $ = require('../internals/export'); var aWeakMap = require('../internals/a-weak-map'); var WeakMapHelpers = require('../internals/weak-map-helpers'); var get = WeakMapHelpers.get; var has = WeakMapHelpers.has; var set = WeakMapHelpers.set; // `WeakMap.prototype.emplace` method // https://github.com/tc39/proposal-upsert $({ target: 'WeakMap', proto: true, real: true, forced: true }, { emplace: function emplace(key, handler) { var map = aWeakMap(this); var value, inserted; if (has(map, key)) { value = get(map, key); if ('update' in handler) { value = handler.update(value, key, map); set(map, key, value); } return value; } inserted = handler.insert(key, map); set(map, key, inserted); return inserted; } });
Version data entries
4 entries across 4 versions & 1 rubygems