Sha256: c18db3a45b931415581ac0095b3fee718ae5dc30994ed26e1226f6950c6b1406

Contents?: true

Size: 1.37 KB

Versions: 36

Compression:

Stored size: 1.37 KB

Contents

// TODO: in core-js@4, move /modules/ dependencies to public entries for better optimization by tools like `preset-env`
var Map = require('../modules/es.map');
var WeakMap = require('../modules/es.weak-map');
var create = require('../internals/object-create');
var isObject = require('../internals/is-object');

var Node = function () {
  // keys
  this.object = null;
  this.symbol = null;
  // child nodes
  this.primitives = null;
  this.objectsByIndex = create(null);
};

Node.prototype.get = function (key, initializer) {
  return this[key] || (this[key] = initializer());
};

Node.prototype.next = function (i, it, IS_OBJECT) {
  var store = IS_OBJECT
    ? this.objectsByIndex[i] || (this.objectsByIndex[i] = new WeakMap())
    : this.primitives || (this.primitives = new Map());
  var entry = store.get(it);
  if (!entry) store.set(it, entry = new Node());
  return entry;
};

var root = new Node();

module.exports = function () {
  var active = root;
  var length = arguments.length;
  var i, it;
  // for prevent leaking, start from objects
  for (i = 0; i < length; i++) {
    if (isObject(it = arguments[i])) active = active.next(i, it, true);
  }
  if (this === Object && active === root) throw TypeError('Composite keys must contain a non-primitive component');
  for (i = 0; i < length; i++) {
    if (!isObject(it = arguments[i])) active = active.next(i, it, false);
  } return active;
};

Version data entries

36 entries across 35 versions & 9 rubygems

Version Path
optimacms-0.1.61 spec/dummy/node_modules/core-js/internals/composite-key.js
disco_app-0.18.0 test/dummy/node_modules/core-js/internals/composite-key.js
disco_app-0.18.2 test/dummy/node_modules/core-js/internals/composite-key.js
disco_app-0.16.1 test/dummy/node_modules/core-js/internals/composite-key.js
disco_app-0.15.2 test/dummy/node_modules/core-js/internals/composite-key.js
disco_app-0.18.4 test/dummy/node_modules/core-js/internals/composite-key.js
disco_app-0.18.1 test/dummy/node_modules/core-js/internals/composite-key.js
disco_app-0.12.7.pre.puma.pre.3 test/dummy/node_modules/core-js/internals/composite-key.js
disco_app-0.14.0 test/dummy/node_modules/core-js/internals/composite-key.js
disco_app-0.13.6.pre.puma.pre.3 test/dummy/node_modules/core-js/internals/composite-key.js
tang-0.2.1 spec/tang_app/node_modules/core-js/internals/composite-key.js
groonga-client-model-6.0.0 test/apps/rails6.0.3.5/node_modules/core-js/internals/composite-key.js
groonga-client-model-6.0.0 test/apps/rails6.1.3/node_modules/core-js/internals/composite-key.js
ruby2js-4.0.4 lib/tasks/testrails/node_modules/core-js/internals/composite-key.js
ruby2js-4.0.3 lib/tasks/testrails/node_modules/core-js/internals/composite-key.js
tang-0.2.0 spec/tang_app/node_modules/core-js/internals/composite-key.js
tang-0.1.0 spec/tang_app/node_modules/core-js/internals/composite-key.js
tang-0.0.9 spec/tang_app/node_modules/core-js/internals/composite-key.js
enju_library-0.3.8 spec/dummy/node_modules/core-js/internals/composite-key.js
condenser-0.3 lib/condenser/processors/node_modules/core-js-pure/internals/composite-key.js