Sha256: 15ffcde652839216d96fe5ad2bfe3a70d84c781b1f4a18603933b0833ce73165

Contents?: true

Size: 1.96 KB

Versions: 40

Compression:

Stored size: 1.96 KB

Contents

'use strict';
var global = require('./_global');
var each = require('./_array-methods')(0);
var redefine = require('./_redefine');
var meta = require('./_meta');
var assign = require('./_object-assign');
var weak = require('./_collection-weak');
var isObject = require('./_is-object');
var validate = require('./_validate-collection');
var NATIVE_WEAK_MAP = require('./_validate-collection');
var IS_IE11 = !global.ActiveXObject && 'ActiveXObject' in global;
var WEAK_MAP = 'WeakMap';
var getWeak = meta.getWeak;
var isExtensible = Object.isExtensible;
var uncaughtFrozenStore = weak.ufstore;
var InternalMap;

var wrapper = function (get) {
  return function WeakMap() {
    return get(this, arguments.length > 0 ? arguments[0] : undefined);
  };
};

var methods = {
  // 23.3.3.3 WeakMap.prototype.get(key)
  get: function get(key) {
    if (isObject(key)) {
      var data = getWeak(key);
      if (data === true) return uncaughtFrozenStore(validate(this, WEAK_MAP)).get(key);
      return data ? data[this._i] : undefined;
    }
  },
  // 23.3.3.5 WeakMap.prototype.set(key, value)
  set: function set(key, value) {
    return weak.def(validate(this, WEAK_MAP), key, value);
  }
};

// 23.3 WeakMap Objects
var $WeakMap = module.exports = require('./_collection')(WEAK_MAP, wrapper, methods, weak, true, true);

// IE11 WeakMap frozen keys fix
if (NATIVE_WEAK_MAP && IS_IE11) {
  InternalMap = weak.getConstructor(wrapper, WEAK_MAP);
  assign(InternalMap.prototype, methods);
  meta.NEED = true;
  each(['delete', 'has', 'get', 'set'], function (key) {
    var proto = $WeakMap.prototype;
    var method = proto[key];
    redefine(proto, key, function (a, b) {
      // store frozen objects on internal weakmap shim
      if (isObject(a) && !isExtensible(a)) {
        if (!this._f) this._f = new InternalMap();
        var result = this._f[key](a, b);
        return key == 'set' ? this : result;
      // store all the rest on native weakmap
      } return method.call(this, a, b);
    });
  });
}

Version data entries

40 entries across 17 versions & 4 rubygems

Version Path
immosquare-cleaner-0.1.51 node_modules/core-js/modules/es6.weak-map.js
immosquare-cleaner-0.1.51 node_modules/core-js/library/modules/es6.weak-map.js
immosquare-cleaner-0.1.50 node_modules/core-js/modules/es6.weak-map.js
immosquare-cleaner-0.1.50 node_modules/core-js/library/modules/es6.weak-map.js
immosquare-cleaner-0.1.49 node_modules/core-js/library/modules/es6.weak-map.js
immosquare-cleaner-0.1.49 node_modules/core-js/modules/es6.weak-map.js
immosquare-cleaner-0.1.48 node_modules/core-js/modules/es6.weak-map.js
immosquare-cleaner-0.1.48 node_modules/core-js/library/modules/es6.weak-map.js
immosquare-cleaner-0.1.47 node_modules/core-js/modules/es6.weak-map.js
immosquare-cleaner-0.1.47 node_modules/core-js/library/modules/es6.weak-map.js
immosquare-cleaner-0.1.46 node_modules/core-js/modules/es6.weak-map.js
immosquare-cleaner-0.1.46 node_modules/core-js/library/modules/es6.weak-map.js
immosquare-cleaner-0.1.45 node_modules/core-js/modules/es6.weak-map.js
immosquare-cleaner-0.1.45 node_modules/core-js/library/modules/es6.weak-map.js
immosquare-cleaner-0.1.44 node_modules/core-js/modules/es6.weak-map.js
immosquare-cleaner-0.1.44 node_modules/core-js/library/modules/es6.weak-map.js
immosquare-cleaner-0.1.43 node_modules/core-js/modules/es6.weak-map.js
immosquare-cleaner-0.1.43 node_modules/core-js/library/modules/es6.weak-map.js
immosquare-cleaner-0.1.42 node_modules/core-js/library/modules/es6.weak-map.js
immosquare-cleaner-0.1.42 node_modules/core-js/modules/es6.weak-map.js