Sha256: 9b6484f9be39df1e7da9de099c24b458073eee2ffc11cc53dc26c7625201fe2e

Contents?: true

Size: 1.51 KB

Versions: 320

Compression:

Stored size: 1.51 KB

Contents

var META     = require('./_uid')('meta')
  , isObject = require('./_is-object')
  , has      = require('./_has')
  , setDesc  = require('./_object-dp').f
  , id       = 0;
var isExtensible = Object.isExtensible || function(){
  return true;
};
var FREEZE = !require('./_fails')(function(){
  return isExtensible(Object.preventExtensions({}));
});
var setMeta = function(it){
  setDesc(it, META, {value: {
    i: 'O' + ++id, // object ID
    w: {}          // weak collections IDs
  }});
};
var fastKey = function(it, create){
  // return primitive with prefix
  if(!isObject(it))return typeof it == 'symbol' ? it : (typeof it == 'string' ? 'S' : 'P') + it;
  if(!has(it, META)){
    // can't set metadata to uncaught frozen object
    if(!isExtensible(it))return 'F';
    // not necessary to add metadata
    if(!create)return 'E';
    // add missing metadata
    setMeta(it);
  // return object ID
  } return it[META].i;
};
var getWeak = function(it, create){
  if(!has(it, META)){
    // can't set metadata to uncaught frozen object
    if(!isExtensible(it))return true;
    // not necessary to add metadata
    if(!create)return false;
    // add missing metadata
    setMeta(it);
  // return hash weak collections IDs
  } return it[META].w;
};
// add metadata on freeze-family methods calling
var onFreeze = function(it){
  if(FREEZE && meta.NEED && isExtensible(it) && !has(it, META))setMeta(it);
  return it;
};
var meta = module.exports = {
  KEY:      META,
  NEED:     false,
  fastKey:  fastKey,
  getWeak:  getWeak,
  onFreeze: onFreeze
};

Version data entries

320 entries across 8 versions & 3 rubygems

Version Path
babel-schmooze-sprockets-0.1.3 node_modules/babel-plugin-transform-es2015-spread/node_modules/core-js/modules/_meta.js
babel-schmooze-sprockets-0.1.3 node_modules/babel-plugin-transform-es2015-sticky-regex/node_modules/core-js/library/modules/_meta.js
babel-schmooze-sprockets-0.1.3 node_modules/babel-core/node_modules/core-js/library/modules/_meta.js
babel-schmooze-sprockets-0.1.3 node_modules/babel-generator/node_modules/core-js/library/modules/_meta.js
babel-schmooze-sprockets-0.1.3 node_modules/babel-code-frame/node_modules/core-js/library/modules/_meta.js
babel-schmooze-sprockets-0.1.3 node_modules/babel-code-frame/node_modules/core-js/modules/_meta.js
babel-schmooze-sprockets-0.1.3 node_modules/babel-helper-call-delegate/node_modules/core-js/library/modules/_meta.js
babel-schmooze-sprockets-0.1.3 node_modules/babel-helper-call-delegate/node_modules/core-js/modules/_meta.js
babel-schmooze-sprockets-0.1.3 node_modules/babel-helper-define-map/node_modules/core-js/modules/_meta.js
babel-schmooze-sprockets-0.1.3 node_modules/babel-helper-function-name/node_modules/core-js/library/modules/_meta.js
babel-schmooze-sprockets-0.1.3 node_modules/babel-generator/node_modules/core-js/modules/_meta.js
babel-schmooze-sprockets-0.1.3 node_modules/babel-helper-hoist-variables/node_modules/core-js/library/modules/_meta.js
babel-schmooze-sprockets-0.1.3 node_modules/babel-helper-optimise-call-expression/node_modules/core-js/library/modules/_meta.js
babel-schmooze-sprockets-0.1.3 node_modules/babel-helper-optimise-call-expression/node_modules/core-js/modules/_meta.js
babel-schmooze-sprockets-0.1.3 node_modules/babel-helper-remap-async-to-generator/node_modules/core-js/library/modules/_meta.js
babel-schmooze-sprockets-0.1.3 node_modules/babel-helper-remap-async-to-generator/node_modules/core-js/modules/_meta.js
babel-schmooze-sprockets-0.1.3 node_modules/babel-helper-replace-supers/node_modules/core-js/modules/_meta.js
babel-schmooze-sprockets-0.1.3 node_modules/babel-helpers/node_modules/core-js/library/modules/_meta.js
babel-schmooze-sprockets-0.1.3 node_modules/babel-helper-get-function-arity/node_modules/core-js/modules/_meta.js
babel-schmooze-sprockets-0.1.3 node_modules/babel-plugin-check-es2015-constants/node_modules/core-js/library/modules/_meta.js